Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IBX-8154: Added PHP 8.3 Dockerfile #32

Merged
merged 5 commits into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ jobs:
php:
- "7.4"
- "8.0"
- "8.1"
- "8.2"
- "8.3"
node:
- "18"
product-version:
Expand All @@ -31,12 +30,15 @@ jobs:
- php: "7.3"
product-version: "~3.3.x-dev"
node: "14"
- php: "7.3"
- php: "7.4"
product-version: "~3.3.x-dev"
node: "16"
- php: "7.3"
- php: "8.3"
product-version: "~3.3.x-dev"
node: "18"
- php: "8.3"
product-version: "~5.0.x-dev"
node: "18"

steps:
- uses: actions/checkout@v4
Expand Down
7 changes: 6 additions & 1 deletion bin/ci/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ docker run -i --rm ibexa_php:latest-node bash -c "php -v; php -m"
printf "\nVersion and module information about php build with enabled xdebug\n"
docker run -i --rm -e ENABLE_XDEBUG="1" ibexa_php:latest-node bash -c "php -v; php -m"

printf "\Integration: Behat testing on ibexa_php:latest and ibexa_php:latest-node with eZ Platform\n"
printf "\nIntegration: Behat testing on ibexa_php:latest and ibexa_php:latest-node with eZ Platform\n"
cd volumes/ezplatform

export COMPOSE_FILE="doc/docker/base-dev.yml:doc/docker/redis.yml:doc/docker/selenium.yml"
Expand All @@ -74,6 +74,11 @@ export PHP_IMAGE="ibexa_php:latest-node" PHP_IMAGE_DEV="ibexa_php:latest-node"
docker compose --env-file .env up -d --build --force-recreate
echo '> Workaround for test issues: Change ownership of files inside docker container'
docker compose --env-file=.env exec -T app sh -c 'chown -R www-data:www-data /var/www'
if docker run -i --rm ibexa_php:latest-node bash -c "php -v" | grep -q '8.3'; then
echo '> Set PHP 8.2+ Ibexa error handler to avoid deprecations'
docker compose --env-file=.env exec -T --user www-data app sh -c "composer config extra.runtime.error_handler \"\\Ibexa\\Contracts\\Core\\MVC\\Symfony\\ErrorHandler\\Php82HideDeprecationsErrorHandler\""
docker compose --env-file=.env exec -T --user www-data app sh -c "composer dump-autoload"
fi
# Rebuild Symfony container
docker compose --env-file=.env exec -T --user www-data app sh -c "rm -rf var/cache/*"
docker compose --env-file=.env exec -T --user www-data app php bin/console cache:clear
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