From cd9802f2835370cac785e65961066d8c8d188b2c Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers <359867+desrosj@users.noreply.github.com> Date: Fri, 26 Jul 2024 13:22:58 -0400 Subject: [PATCH] Add PHP 8.4 containers (#148) * Add PHP 8.4 containers. * Add PHP 8.4 containers. --------- Co-authored-by: desrosj --- .github/workflows/docker-hub.yml | 6 +- .../workflows/github-container-registry.yml | 6 +- images/8.4/cli/Dockerfile | 40 ++++++++++++ images/8.4/cli/entrypoint.sh | 17 +++++ images/8.4/php/Dockerfile | 63 +++++++++++++++++++ images/8.4/php/common.sh | 30 +++++++++ images/8.4/php/entrypoint.sh | 7 +++ images/8.4/php/php-fpm.conf | 3 + images/8.4/phpunit/Dockerfile | 22 +++++++ images/8.4/phpunit/entrypoint.sh | 9 +++ update.php | 14 +++++ 11 files changed, 211 insertions(+), 6 deletions(-) create mode 100644 images/8.4/cli/Dockerfile create mode 100644 images/8.4/cli/entrypoint.sh create mode 100644 images/8.4/php/Dockerfile create mode 100644 images/8.4/php/common.sh create mode 100644 images/8.4/php/entrypoint.sh create mode 100644 images/8.4/php/php-fpm.conf create mode 100644 images/8.4/phpunit/Dockerfile create mode 100644 images/8.4/phpunit/entrypoint.sh diff --git a/.github/workflows/docker-hub.yml b/.github/workflows/docker-hub.yml index 60791c5..03b886d 100644 --- a/.github/workflows/docker-hub.yml +++ b/.github/workflows/docker-hub.yml @@ -44,7 +44,7 @@ jobs: strategy: matrix: - php: [ '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3' ] + php: [ '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4' ] env: PHP_VERSION: ${{ matrix.php }} PHP_LATEST: '8.2' @@ -79,7 +79,7 @@ jobs: needs: build-php-images strategy: matrix: - php: [ '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3' ] + php: [ '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4' ] env: PHP_VERSION: ${{ matrix.php }} @@ -142,7 +142,7 @@ jobs: needs: build-php-images strategy: matrix: - php: [ '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3' ] + php: [ '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4' ] env: PHP_VERSION: ${{ matrix.php }} diff --git a/.github/workflows/github-container-registry.yml b/.github/workflows/github-container-registry.yml index 0de28c9..e443adc 100644 --- a/.github/workflows/github-container-registry.yml +++ b/.github/workflows/github-container-registry.yml @@ -53,7 +53,7 @@ jobs: needs: [ check-for-changes ] strategy: matrix: - php: [ '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3' ] + php: [ '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4' ] env: PHP_VERSION: ${{ matrix.php }} PHP_LATEST: '8.2' @@ -88,7 +88,7 @@ jobs: needs: build-php-images strategy: matrix: - php: [ '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3' ] + php: [ '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4' ] env: PHP_VERSION: ${{ matrix.php }} @@ -151,7 +151,7 @@ jobs: needs: build-php-images strategy: matrix: - php: [ '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3' ] + php: [ '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4' ] env: PHP_VERSION: ${{ matrix.php }} diff --git a/images/8.4/cli/Dockerfile b/images/8.4/cli/Dockerfile new file mode 100644 index 0000000..f21132c --- /dev/null +++ b/images/8.4/cli/Dockerfile @@ -0,0 +1,40 @@ +ARG PACKAGE_REGISTRY +ARG PR_TAG +FROM $PACKAGE_REGISTRY/php:8.4-fpm$PR_TAG + +########################################################################## +# +# WARNING: This file was generated by update.php. +# +# You can find the relevant template in the `/templates` folder. +# + + +# install wp-cli dependences +RUN set -ex; \ + \ + apt-get update; \ + \ + apt-get install -y --no-install-recommends \ + less \ + virtual-mysql-client \ + ; + +RUN set -ex; \ + \ + curl -L -o /usr/local/bin/wp https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar; \ + \ + chmod +x /usr/local/bin/wp; \ + \ + wp --allow-root --version; + +COPY entrypoint.sh /entrypoint.sh + +RUN chmod +x /entrypoint.sh + +ENTRYPOINT [ "/entrypoint.sh" ] + + +WORKDIR /var/www + +CMD [ "wp", "shell" ] diff --git a/images/8.4/cli/entrypoint.sh b/images/8.4/cli/entrypoint.sh new file mode 100644 index 0000000..a975386 --- /dev/null +++ b/images/8.4/cli/entrypoint.sh @@ -0,0 +1,17 @@ +#!/bin/bash +set -e + +source /common.sh + +# first arg is `-f` or `--some-option` +if [ "${1#-}" != "$1" ]; then + set -- wp "$@" +fi + +# if our command is a valid wp-cli subcommand, let's invoke it through wp-cli instead +if sudo -u wp_php wp --path=/dev/null help "$1" > /dev/null 2>&1; then + set -- wp "$@" +fi + +# Execute CMD +sudo -E -u wp_php "$@" diff --git a/images/8.4/php/Dockerfile b/images/8.4/php/Dockerfile new file mode 100644 index 0000000..27c6387 --- /dev/null +++ b/images/8.4/php/Dockerfile @@ -0,0 +1,63 @@ +FROM php:8.4-rc-fpm + +WORKDIR /var/www + +########################################################################## +# +# WARNING: This file was generated by update.php. +# +# You can find the relevant template in the `/templates` folder. +# + +ENV COMPOSER_ALLOW_SUPERUSER 1 +ENV COMPOSER_HOME /tmp + +# install the PHP extensions we need +RUN set -ex; \ + \ + apt-get update; \ + \ + apt-get install -y --no-install-recommends libjpeg-dev libpng-dev libwebp-dev libzip-dev libmemcached-dev unzip libmagickwand-dev ghostscript libonig-dev locales sudo rsync libxslt-dev git; \ + apt-get upgrade openssl -y; \ + update-ca-certificates --fresh; \ + sed -i 's/^# *\(\(ru_RU\|fr_FR\|de_DE\|es_ES\|ja_JP\).UTF-8\)/\1/' /etc/locale.gen; \ + locale-gen; \ + \ + docker-php-ext-configure gd --enable-gd --with-jpeg=/usr --with-webp=/usr; \ + \ + docker-php-ext-install gd opcache mysqli zip exif intl mbstring xml xsl; \ + \ + curl --silent --fail --location --retry 3 --output /tmp/installer.php --url https://getcomposer.org/installer; \ + curl --silent --fail --location --retry 3 --output /tmp/installer.sig --url https://composer.github.io/installer.sig; \ + php -r " \ + \$signature = file_get_contents( '/tmp/installer.sig' ); \ + \$hash = hash( 'sha384', file_get_contents('/tmp/installer.php') ); \ + if ( \$signature !== \$hash ) { \ + unlink( '/tmp/installer.php' ); \ + unlink( '/tmp/installer.sig' ); \ + echo 'Integrity check failed, installer is either corrupt or worse.' . PHP_EOL; \ + exit( 1 ); \ + }"; \ + php /tmp/installer.php --no-ansi --install-dir=/usr/bin --filename=composer; \ + composer --ansi --version --no-interaction; \ + rm -f /tmp/installer.php /tmp/installer.sig; + +COPY entrypoint.sh /entrypoint.sh +COPY common.sh /common.sh +COPY php-fpm.conf /usr/local/etc/php-fpm.d/zz-wordpress.conf + +ARG imagemagic_config=/etc/ImageMagick-6/policy.xml +RUN if [ -f $imagemagic_config ] ; then \ + sed -i 's///g' $imagemagic_config; \ + else \ + echo did not see file $imagemagic_config; \ + fi + +RUN chmod +x /entrypoint.sh && \ + chmod +x /common.sh && \ + groupadd -g 1000 -r wp_php && \ + useradd -u 1000 -s /bin/bash -g wp_php wp_php + +ENTRYPOINT [ "/entrypoint.sh" ] + +CMD [ "php-fpm" ] diff --git a/images/8.4/php/common.sh b/images/8.4/php/common.sh new file mode 100644 index 0000000..b0df597 --- /dev/null +++ b/images/8.4/php/common.sh @@ -0,0 +1,30 @@ +#!/bin/bash +set -e + +# If LOCAL_PHP_XDEBUG=true xdebug extension will be enabled +if [ "$LOCAL_PHP_XDEBUG" = true ]; then + docker-php-ext-enable xdebug + rm -f /usr/local/etc/php/conf.d/docker-php-ext-opcache.ini +else + docker-php-ext-enable opcache + rm -f /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini +fi + +# If LOCAL_PHP_MEMCACHED=true memcached extension will be enabled +if [ "$LOCAL_PHP_MEMCACHED" = true ]; then + docker-php-ext-enable memcached +else + rm -f /usr/local/etc/php/conf.d/docker-php-ext-memcached.ini +fi + +### Change UID/GID +WP_PHP_UID="${PHP_FPM_UID-1000}" +WP_PHP_GID="${PHP_FPM_GID-1000}" + +if [ "$WP_PHP_UID" != "`id -u wp_php`" ]; then + usermod -o -u "${WP_PHP_UID}" "wp_php" +fi + +if [ "$WP_PHP_GID" != "`id -g wp_php`" ]; then + groupmod -o -g "${WP_PHP_GID}" "wp_php" +fi diff --git a/images/8.4/php/entrypoint.sh b/images/8.4/php/entrypoint.sh new file mode 100644 index 0000000..c3c3b23 --- /dev/null +++ b/images/8.4/php/entrypoint.sh @@ -0,0 +1,7 @@ +#!/bin/bash +set -e + +source /common.sh + +# Execute CMD +exec "$@" diff --git a/images/8.4/php/php-fpm.conf b/images/8.4/php/php-fpm.conf new file mode 100644 index 0000000..fe69bda --- /dev/null +++ b/images/8.4/php/php-fpm.conf @@ -0,0 +1,3 @@ +[www] +user = wp_php +group = wp_php \ No newline at end of file diff --git a/images/8.4/phpunit/Dockerfile b/images/8.4/phpunit/Dockerfile new file mode 100644 index 0000000..6c3a6f6 --- /dev/null +++ b/images/8.4/phpunit/Dockerfile @@ -0,0 +1,22 @@ +ARG PACKAGE_REGISTRY +ARG PR_TAG +FROM $PACKAGE_REGISTRY/php:8.4-fpm$PR_TAG + +########################################################################## +# +# WARNING: This file was generated by update.php. +# +# You can find the relevant template in the `/templates` folder. +# + +RUN curl -sL https://phar.phpunit.de/phpunit-9.phar > /usr/local/bin/phpunit && chmod +x /usr/local/bin/phpunit + +WORKDIR /var/www + +COPY entrypoint.sh /entrypoint.sh + +RUN chmod +x /entrypoint.sh + +ENTRYPOINT [ "/entrypoint.sh" ] + +CMD /usr/local/bin/phpunit diff --git a/images/8.4/phpunit/entrypoint.sh b/images/8.4/phpunit/entrypoint.sh new file mode 100644 index 0000000..ef08bb8 --- /dev/null +++ b/images/8.4/phpunit/entrypoint.sh @@ -0,0 +1,9 @@ +#!/bin/bash +set -e + +source /common.sh + +chown -R wp_php:wp_php /var/www/${LOCAL_DIR-src}/wp-content/uploads + +# Execute CMD +sudo -E -u wp_php "$@" diff --git a/update.php b/update.php index fd52d91..748c477 100644 --- a/update.php +++ b/update.php @@ -153,6 +153,20 @@ 'download_url' => 'https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar', ), ), + '8.4' => array( + 'php' => array( + 'base_name' => 'php:8.4-rc-fpm', + 'apt' => array( 'libjpeg-dev', 'libpng-dev', 'libwebp-dev', 'libzip-dev', 'libmemcached-dev', 'unzip', 'libmagickwand-dev', 'ghostscript', 'libonig-dev', 'locales', 'sudo', 'rsync', 'libxslt-dev' ), + 'extensions' => array( 'gd', 'opcache', 'mysqli', 'zip', 'exif', 'intl', 'mbstring', 'xml', 'xsl' ), + 'pecl_extensions' => array(), + 'composer' => true, + ), + 'phpunit' => 9, + 'cli' => array( + 'mysql_client' => 'virtual-mysql-client', + 'download_url' => 'https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar', + ), + ), ); /**