From 35bd811bdc0f9ba542cdf87540fab8b1997a93a7 Mon Sep 17 00:00:00 2001 From: Antoine Wattier Date: Thu, 7 Sep 2023 17:27:16 -0400 Subject: [PATCH] Add PHP 8.2 support --- .github/workflows/ci.yml | 1 + .github/workflows/publish.yml | 3 + Dockerfile-8.2 | 145 +++++++++++++++++++++ README.md | 6 +- container/root/tests/php-fpm/8.2.goss.yaml | 22 ++++ 5 files changed, 175 insertions(+), 2 deletions(-) create mode 100644 Dockerfile-8.2 create mode 100644 container/root/tests/php-fpm/8.2.goss.yaml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fb6fe13..6cdfc31 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,6 +14,7 @@ jobs: - "7.4-alpine" - "8.0" - "8.1" + - "8.2" platform: - linux/amd64 - linux/arm64 diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 9ff47d3..42b9ff6 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -27,6 +27,9 @@ jobs: - Dockerfile: Dockerfile-8.1 version: "8.1" platforms: linux/amd64,linux/arm64 + - Dockerfile: Dockerfile-8.2 + version: "8.2" + platforms: linux/amd64,linux/arm64 steps: - name: Checkout diff --git a/Dockerfile-8.2 b/Dockerfile-8.2 new file mode 100644 index 0000000..cfa3526 --- /dev/null +++ b/Dockerfile-8.2 @@ -0,0 +1,145 @@ +FROM behance/docker-nginx:10.2.0 as output +LABEL maintainers="Behance Team " + +# Set TERM to suppress warning messages. +ENV CONF_PHPFPM=/etc/php/8.2/fpm/php-fpm.conf \ + CONF_PHPMODS=/etc/php/8.2/mods-available \ + CONF_FPMPOOL=/etc/php/8.2/fpm/pool.d/www.conf \ + CONF_FPMOVERRIDES=/etc/php/8.2/fpm/conf.d/overrides.user.ini \ + APP_ROOT=/app \ + SERVER_WORKER_CONNECTIONS=3072 \ + SERVER_CLIENT_BODY_BUFFER_SIZE=128k \ + SERVER_CLIENT_HEADER_BUFFER_SIZE=1k \ + SERVER_CLIENT_BODY_BUFFER_SIZE=128k \ + SERVER_LARGE_CLIENT_HEADER_BUFFERS="4 256k" \ + PHP_FPM_MAX_CHILDREN=4096 \ + PHP_FPM_START_SERVERS=20 \ + PHP_FPM_MAX_REQUESTS=1024 \ + PHP_FPM_MIN_SPARE_SERVERS=5 \ + PHP_FPM_MAX_SPARE_SERVERS=128 \ + PHP_FPM_MEMORY_LIMIT=256M \ + PHP_FPM_MAX_EXECUTION_TIME=60 \ + PHP_FPM_UPLOAD_MAX_FILESIZE=1M \ + PHP_OPCACHE_MEMORY_CONSUMPTION=128 \ + PHP_OPCACHE_INTERNED_STRINGS_BUFFER=16 \ + PHP_OPCACHE_MAX_WASTED_PERCENTAGE=5 \ + PHP_OPCACHE_ENABLE_CLI=1 \ + PHP_ENGINE_VERSION=20210902 \ + CFG_APP_DEBUG=1 + +COPY ./scripts/ /scripts/ + +# - Update security packages +# - Add PHP and support packages +# - Install NewRelic +# - Compile extensions +# - Enable/disable default extensions +# - Cleanup +RUN /bin/bash -e /security_updates.sh && \ + apt-get install -yqq --no-install-recommends \ + gpg-agent \ + git \ + curl \ + wget \ + software-properties-common \ + locales \ + && \ + locale-gen en_US.UTF-8 && export LANG=en_US.UTF-8 && \ + add-apt-repository ppa:ondrej/php -y && \ + apt-get update -q && \ + # Ensure old versions of PHP don't accidentally get added by PPA maintainers + apt-mark hold \ + manpages \ + manpages-dev \ + apache2 \ + apache2-bin \ + libapache2-mod-php8.2 \ + && \ + apt-get -yqq install \ + php8.2 \ + php8.2-apcu \ + php8.2-bcmath \ + php8.2-bz2 \ + php8.2-curl \ + php8.2-fpm \ + php8.2-gd \ + php8.2-intl \ + php8.2-mbstring \ + php8.2-memcache \ + php8.2-memcached \ + php8.2-mysql \ + php8.2-pgsql \ + php8.2-redis \ + php8.2-xdebug \ + php8.2-xml \ + php8.2-yaml \ + php8.2-zip \ + # below required to compile non-packaged extensions + php8.2-dev \ + pkg-config \ + libmemcached-dev \ + zlib1g-dev \ + libssl-dev \ + libpcre3-dev \ + golang \ + && \ + /bin/bash -e /scripts/install-newrelic-ubuntu.sh && \ + /bin/bash -e /scripts/install-composer.sh && \ + phpenmod \ + memcached \ + igbinary \ + msgpack \ + && \ + phpdismod \ + pdo_pgsql \ + pgsql \ + redis \ + yaml \ + xdebug \ + && \ + apt-get remove --purge -yq \ + build-essential \ + cpp \ + cpp-7 \ + gcc \ + golang \ + libpcre3-dev \ + libssl-dev \ + locales \ + patch \ + php8.2-dev \ + pkg-config \ + software-properties-common \ + wget \ + && \ + /bin/bash /clean.sh \ + # Remove extra extensions installed via packages for other versions of PHP, leaving the active engine folder + cd /usr/lib/php && \ + ls -d */ | grep '[0-9]\{8\}' | grep -v ${PHP_ENGINE_VERSION} | xargs rm -rf && \ + cd / + +# Overlay the root filesystem from this repo +COPY ./container/root / + +# - Make additional hacks to migrate files/config from 7.0 --> 8.2 folder +RUN cp /etc/php/7.0/mods-available/* $CONF_PHPMODS && \ + cp /etc/php/7.0/fpm/conf.d/overrides.user.ini $CONF_FPMOVERRIDES && \ + # Hack: share startup scripts between variant versions by symlinking \ + ln -s /usr/sbin/php-fpm8.2 /usr/sbin/php-fpm && \ + # Override default ini values for both CLI + FPM \ + phpenmod overrides && \ + # Enable NewRelic via Ubuntu symlinks, but disable in file. Cross-variant startup script uncomments with env vars. + phpenmod newrelic && \ + # Run standard set of tweaks to ensure runs performant, reliably, and consistent between variants + /bin/bash -e /scripts/prep-php.sh + +# TESTING PHASE: using multi-stage to isolate any possible side effects +FROM output as testenvironment + +# HACK: workaround for https://github.com/aelsabbahy/goss/issues/392 +# Run the child and parent test configs separately instead of leveraging inheritance +RUN goss -g /tests/php-fpm/8.2.goss.yaml validate && \ + goss -g /tests/php-fpm/base.goss.yaml validate + +# Output the final image +FROM output diff --git a/README.md b/README.md index 1bbf6ac..3cef395 100644 --- a/README.md +++ b/README.md @@ -13,8 +13,10 @@ Available on [Docker Hub](https://hub.docker.com/r/behance/docker-php/). ### Quick-start - `docker run behance/docker-php:7.4-alpine "php" "-v"` -- `docker run behance/docker-php:7.4" "php" "-v"` -- `docker run behance/docker-php:8.0" "php" "-v"` +- `docker run behance/docker-php:7.4 "php" "-v"` +- `docker run behance/docker-php:8.0 "php" "-v"` +- `docker run behance/docker-php:8.1 "php" "-v"` +- `docker run behance/docker-php:8.2 "php" "-v"` Adding code to runtime, see [here](https://github.com/behance/docker-php#expectations). PHP tuning and configuration, see [here](https://github.com/behance/docker-php#downstream-configuration). diff --git a/container/root/tests/php-fpm/8.2.goss.yaml b/container/root/tests/php-fpm/8.2.goss.yaml new file mode 100644 index 0000000..140d804 --- /dev/null +++ b/container/root/tests/php-fpm/8.2.goss.yaml @@ -0,0 +1,22 @@ + +# Extended file tests will be overridden/ignored from parent +# Note: Other variants may not include extended file tests, are not susceptible +# @see https://github.com/aelsabbahy/goss/issues/392 + +# gossfile: +# base.goss.yaml: {} + +command: + # IMPORTANT: confirm the major/minor version of PHP itself + php -r 'echo PHP_MAJOR_VERSION;': + exit-status: 0 + stdout: [8] + php -r 'echo PHP_MINOR_VERSION;': + exit-status: 0 + stdout: [2] + php-fpm -v: + exit-status: 0 + stdout: [PHP 8.2] + # Not common to all variants, test in supported children + php -m | grep -i memcache: + exit-status: 0