Skip to content

Commit

Permalink
Added PHP 8.3 Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
micszo committed Apr 22, 2024
1 parent f17458e commit db8cc10
Show file tree
Hide file tree
Showing 2 changed files with 155 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ jobs:
- "8.0"
- "8.1"
- "8.2"
- "8.3"
node:
- "18"
product-version:
Expand Down
154 changes: 154 additions & 0 deletions php/Dockerfile-8.3
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
FROM php:8.3-fpm-bullseye

# Container containing php-fpm and php-cli to run and interact with Ibexa DXP

# Set defaults for variables used by run.sh
ENV COMPOSER_HOME=/root/.composer

# Get packages that we need in container
RUN apt-get update -q -y \
&& apt-get install -q -y --no-install-recommends \
ca-certificates \
curl \
acl \
sudo \
# Needed for the php extensions we enable below
# gd
libfreetype6 \
libjpeg62-turbo \
libxpm4 \
libpng16-16 \
# intl
libicu67 \
# xslt
libxslt1.1 \
# memcached
libmemcachedutil2 \
# zip
libzip4 \
# imagick
imagemagick \
# mbstring
libonig5 \
# PostgreSQL
libpq5 \
# git & unzip needed for composer, unless we document to use dev image for composer install
# unzip needed due to https://github.com/composer/composer/issues/4471
unzip \
git \
# packages useful for dev
less \
mariadb-client \
vim \
wget \
tree \
gdb-minimal \
&& rm -rf /var/lib/apt/lists/*

# Install and configure php plugins
RUN set -xe \
&& buildDeps=" \
# gd
libjpeg62-turbo-dev \
libpng-dev \
libxpm-dev \
libfreetype6-dev \
# PostgreSQL
libpq-dev \
# mbstring \
libonig-dev \
# intl
libicu-dev \
# xsl
libxslt1-dev \
# zip
libzip-dev \
# imagick
libmagickwand-dev \
# memcached
libmemcached-dev \
" \
&& apt-get update -q -y && apt-get install -q -y --no-install-recommends $buildDeps && rm -rf /var/lib/apt/lists/* \
# Extract php source and install missing extensions
&& docker-php-source extract \
&& docker-php-ext-configure mysqli --with-mysqli=mysqlnd \
&& docker-php-ext-configure pdo_mysql --with-pdo-mysql=mysqlnd \
&& docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql \
&& docker-php-ext-configure gd --with-freetype=/usr/include/ --with-jpeg=/usr/include/ --with-xpm=/usr/include/ --enable-gd-jis-conv \
&& docker-php-ext-install exif gd mbstring intl xsl zip mysqli pdo_mysql pdo_pgsql pgsql soap bcmath sockets \
&& docker-php-ext-enable opcache \
&& cp /usr/src/php/php.ini-production ${PHP_INI_DIR}/php.ini \
\
# Install imagemagick
&& for i in $(seq 1 3); do pecl install -o imagick && s=0 && break || s=$? && sleep 1; done; (exit $s) \
&& docker-php-ext-enable imagick \
# Install xdebug
&& for i in $(seq 1 3); do echo yes | pecl install -o "xdebug" && s=0 && break || s=$? && sleep 1; done; (exit $s) \
# Install blackfire: https://blackfire.io/docs/integrations/docker
&& version=$(php -r "echo PHP_MAJOR_VERSION.PHP_MINOR_VERSION;") \
&& curl -A "Docker" -o /tmp/blackfire-probe.tar.gz -D - -L -s https://blackfire.io/api/v1/releases/probe/php/linux/amd64/$version \
&& tar zxpf /tmp/blackfire-probe.tar.gz -C /tmp \
&& mv /tmp/blackfire-*.so $(php -r "echo ini_get('extension_dir');")/blackfire.so \
&& rm -f /tmp/blackfire-probe.tar.gz \
\
# Install igbinary (for more efficient serialization in redis/memcached)
&& for i in $(seq 1 3); do pecl install -o igbinary && s=0 && break || s=$? && sleep 1; done; (exit $s) \
&& docker-php-ext-enable igbinary \
\
# Install redis (manualy build in order to be able to enable igbinary)
&& for i in $(seq 1 3); do pecl install -o --nobuild redis && s=0 && break || s=$? && sleep 1; done; (exit $s) \
&& cd "$(pecl config-get temp_dir)/redis" \
&& phpize \
&& ./configure --enable-redis-igbinary \
&& make \
&& make install \
&& docker-php-ext-enable redis \
&& cd - \
\
# Install memcached (manualy build in order to be able to enable igbinary)
&& for i in $(seq 1 3); do echo no | pecl install -o --nobuild memcached && s=0 && break || s=$? && sleep 1; done; (exit $s) \
&& cd "$(pecl config-get temp_dir)/memcached" \
&& phpize \
&& ./configure --enable-memcached-igbinary \
&& make \
&& make install \
&& docker-php-ext-enable memcached \
&& cd - \
\
# Delete source & builds deps so it does not hang around in layers taking up space
&& pecl clear-cache \
&& rm -Rf "$(pecl config-get temp_dir)/*" \
&& docker-php-source delete \
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false $buildDeps

# Set timezone
RUN echo "UTC" > /etc/timezone && dpkg-reconfigure --frontend noninteractive tzdata

# Set pid file to be able to restart php-fpm
RUN sed -i "s@^\[global\]@\[global\]\n\npid = /run/php-fpm.pid@" ${PHP_INI_DIR}-fpm.conf

COPY conf.d/blackfire.ini ${PHP_INI_DIR}/conf.d/blackfire.ini
COPY conf.d/xdebug.ini ${PHP_INI_DIR}/conf.d/xdebug.ini.disabled

# Create Composer directory (cache and auth files) & Get Composer
RUN mkdir -p $COMPOSER_HOME \
&& curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

# As application is put in as volume we do all needed operation on run
COPY scripts /scripts

# Add some custom config
COPY conf.d/php.ini ${PHP_INI_DIR}/conf.d/php.ini

RUN chmod 755 /scripts/*.sh

# Needed for docker-machine
RUN usermod -u 1000 www-data

WORKDIR /var/www

ENTRYPOINT ["/scripts/docker-entrypoint.sh"]

CMD php-fpm

EXPOSE 9000

0 comments on commit db8cc10

Please sign in to comment.