From eec2a8baa28b4f0036e323e292346d4347fd1cb4 Mon Sep 17 00:00:00 2001 From: Luis Pabon Date: Wed, 21 Oct 2026 19:03:49 +0100 Subject: [PATCH 1/2] DRY: single parameterised Dockerfile, shared overrides.conf, matrix CI Opcache package is only installed for PHP < 8.5 (built into core from 8.5). --- .dockerignore | 5 ++ .github/workflows/docker-build.yaml | 36 ++++++------ Dockerfile | 74 ++++++++++++++++++++++++ php/8.2/overrides.conf => overrides.conf | 0 php/8.1/Dockerfile | 60 ------------------- php/8.1/README.md | 11 ---- php/8.1/overrides.conf | 27 --------- php/8.2/Dockerfile | 59 ------------------- php/8.2/README.md | 11 ---- php/8.3/Dockerfile | 59 ------------------- php/8.3/README.md | 7 --- php/8.3/overrides.conf | 27 --------- php/8.4/Dockerfile | 59 ------------------- php/8.4/README.md | 7 --- php/8.4/overrides.conf | 27 --------- php/8.5/Dockerfile | 58 ------------------- php/8.5/README.md | 7 --- php/8.5/overrides.conf | 27 --------- 18 files changed, 96 insertions(+), 465 deletions(-) create mode 100644 .dockerignore create mode 100644 Dockerfile rename php/8.2/overrides.conf => overrides.conf (100%) delete mode 100644 php/8.1/Dockerfile delete mode 100644 php/8.1/README.md delete mode 100644 php/8.1/overrides.conf delete mode 100644 php/8.2/Dockerfile delete mode 100644 php/8.2/README.md delete mode 100644 php/8.3/Dockerfile delete mode 100644 php/8.3/README.md delete mode 100644 php/8.3/overrides.conf delete mode 100644 php/8.4/Dockerfile delete mode 100644 php/8.4/README.md delete mode 100644 php/8.4/overrides.conf delete mode 100644 php/8.5/Dockerfile delete mode 100644 php/8.5/README.md delete mode 100644 php/8.5/overrides.conf diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..1d2503e --- /dev/null +++ b/.dockerignore @@ -0,0 +1,5 @@ +.git +.github +.idea +.steiner +*.md diff --git a/.github/workflows/docker-build.yaml b/.github/workflows/docker-build.yaml index 7a6a5b4..668620b 100644 --- a/.github/workflows/docker-build.yaml +++ b/.github/workflows/docker-build.yaml @@ -18,6 +18,14 @@ jobs: strategy: matrix: php: [ '8.1', '8.2', '8.3', '8.4', '8.5' ] + target: [ 'cli', 'fpm' ] + include: + # Ubuntu base image per PHP version + - { php: '8.1', ubuntu: 'jammy' } + - { php: '8.2', ubuntu: 'jammy' } + - { php: '8.3', ubuntu: 'jammy' } + - { php: '8.4', ubuntu: 'noble' } + - { php: '8.5', ubuntu: 'noble' } steps: - name: Checkout @@ -41,28 +49,18 @@ jobs: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: PHP CLI container + - name: PHP ${{ matrix.php }} ${{ matrix.target }} container uses: docker/build-push-action@v6 with: - context: php/${{ matrix.php }} + context: . + build-args: | + PHP_VERSION=${{ matrix.php }} + UBUNTU=${{ matrix.ubuntu }} platforms: linux/amd64,linux/arm64,linux/arm/v7 push: ${{ github.ref == 'refs/heads/master' }} pull: true # Enable BuildKit cache restore/save across workflow runs - cache-from: type=gha,scope=php-${{ matrix.php }} - cache-to: type=gha,mode=max,scope=php-${{ matrix.php }} - tags: phpdockerio/php:${{ matrix.php }}-cli - target: cli - - - name: PHP FPM container - uses: docker/build-push-action@v6 - with: - context: php/${{ matrix.php }} - platforms: linux/amd64,linux/arm64,linux/arm/v7 - push: ${{ github.ref == 'refs/heads/master' }} - pull: true - # Enable BuildKit cache restore/save across workflow runs - cache-from: type=gha,scope=php-${{ matrix.php }} - cache-to: type=gha,mode=max,scope=php-${{ matrix.php }} - tags: phpdockerio/php:${{ matrix.php }}-fpm - target: fpm + cache-from: type=gha,scope=php-${{ matrix.php }}-${{ matrix.target }} + cache-to: type=gha,mode=max,scope=php-${{ matrix.php }}-${{ matrix.target }} + tags: phpdockerio/php:${{ matrix.php }}-${{ matrix.target }} + target: ${{ matrix.target }} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..b4fd78a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,74 @@ +########################################## +# PHPDocker.io PHP CLI and FPM image # +# Build with --build-arg PHP_VERSION=8.x # +########################################## + +# Ubuntu release the image is based on, also used to pick the Ondrej PPA suite +ARG UBUNTU=noble + +### CLI ### + +FROM ubuntu:${UBUNTU} AS cli + +ARG UBUNTU +ARG PHP_VERSION + +# Fixes some weird terminal issues such as broken clear / CTRL+L +ENV TERM=linux + +# Ensure apt doesn't ask questions when installing stuff +ENV DEBIAN_FRONTEND=noninteractive + +# Install Ondrej repos for Ubuntu, PHP, composer and selected extensions - better selection than +# the distro's packages +# +# From PHP 8.5 opcache is built into the PHP runtime and there is no separate package for it. +RUN test -n "${PHP_VERSION}" || { echo "PHP_VERSION build arg is required" >&2; exit 1; } \ + && OPCACHE="" \ + && if dpkg --compare-versions "${PHP_VERSION}" lt 8.5; then OPCACHE="php${PHP_VERSION}-opcache"; fi \ + && apt-get update \ + && apt-get install -y --no-install-recommends gnupg \ + && echo "deb http://ppa.launchpad.net/ondrej/php/ubuntu ${UBUNTU} main" > /etc/apt/sources.list.d/ondrej-php.list \ + && apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 4F4EA0AAE5267A6C \ + && apt-get update \ + && apt-get -y --no-install-recommends install \ + ca-certificates \ + curl \ + unzip \ + php${PHP_VERSION}-apcu \ + php${PHP_VERSION}-cli \ + php${PHP_VERSION}-curl \ + php${PHP_VERSION}-mbstring \ + ${OPCACHE} \ + php${PHP_VERSION}-readline \ + php${PHP_VERSION}-xml \ + php${PHP_VERSION}-zip \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/* ~/.composer + +COPY --from=composer:2 /usr/bin/composer /usr/bin/composer + +CMD ["php", "-a"] + +### FPM ### + +FROM cli AS fpm + +ARG PHP_VERSION + +# Install FPM. The version-independent symlink lets CMD (exec form, no ARG expansion) avoid the version. +RUN apt-get update \ + && apt-get -y --no-install-recommends install php${PHP_VERSION}-fpm \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/* \ + && ln -s /usr/sbin/php-fpm${PHP_VERSION} /usr/sbin/php-fpm + +STOPSIGNAL SIGQUIT + +# PHP-FPM packages need a nudge to make them docker-friendly +COPY overrides.conf /etc/php/${PHP_VERSION}/fpm/pool.d/z-overrides.conf + +CMD ["/usr/sbin/php-fpm", "-O" ] + +# Open up fcgi port +EXPOSE 9000 diff --git a/php/8.2/overrides.conf b/overrides.conf similarity index 100% rename from php/8.2/overrides.conf rename to overrides.conf diff --git a/php/8.1/Dockerfile b/php/8.1/Dockerfile deleted file mode 100644 index 63bd0d0..0000000 --- a/php/8.1/Dockerfile +++ /dev/null @@ -1,60 +0,0 @@ -############################################ -# PHPDocker.io PHP 8.1 / CLI and FPM image # -############################################ - -FROM ubuntu:jammy AS cli - -# Fixes some weird terminal issues such as broken clear / CTRL+L -ENV TERM=linux - -# Ensure apt doesn't ask questions when installing stuff -ENV DEBIAN_FRONTEND=noninteractive - -# Install Ondrej repos for Ubuntu jammy, PHP, composer and selected extensions - better selection than -# the distro's packages -RUN apt-get update \ - && apt-get install -y --no-install-recommends gnupg \ - && echo "deb http://ppa.launchpad.net/ondrej/php/ubuntu jammy main" > /etc/apt/sources.list.d/ondrej-php.list \ - && apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 4F4EA0AAE5267A6C \ - && apt-get update \ - && apt-get -y --no-install-recommends install \ - ca-certificates \ - curl \ - unzip \ - php8.1-apcu \ - php8.1-cli \ - php8.1-curl \ - php8.1-mbstring \ - php8.1-opcache \ - php8.1-readline \ - php8.1-xml \ - php8.1-zip \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/* ~/.composer - -COPY --from=composer:2 /usr/bin/composer /usr/bin/composer - -CMD ["php", "-a"] - -# If you'd like to be able to use this container on a docker-compose environment as a quiescent PHP CLI container -# you can /bin/bash into, override CMD with the following - bear in mind that this will make docker-compose stop -# slow on such a container, docker-compose kill might do if you're in a hurry -# CMD ["tail", "-f", "/dev/null"] - -FROM cli AS fpm - -# Install FPM -RUN apt-get update \ - && apt-get -y --no-install-recommends install php8.1-fpm \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/* - -STOPSIGNAL SIGQUIT - -# PHP-FPM packages need a nudge to make them docker-friendly -COPY overrides.conf /etc/php/8.1/fpm/pool.d/z-overrides.conf - -CMD ["/usr/sbin/php-fpm8.1", "-O" ] - -# Open up fcgi port -EXPOSE 9000 diff --git a/php/8.1/README.md b/php/8.1/README.md deleted file mode 100644 index 714cad0..0000000 --- a/php/8.1/README.md +++ /dev/null @@ -1,11 +0,0 @@ -# PHPDocker.io - PHP 8.1 / CLI, FPM and Swoole container images - -Ubuntu 22.04 PHP 8.1 CLI and FPM container images for [PHPDocker.io](http://phpdocker.io) projects. Packages are provided by [Ondřej Surý](https://deb.sury.org/). - -Far smaller in size than PHP's official container. No need to compile any extensions: simply run `apt-get install php8.1-EXTENSION_NAME` as part of your Dockerfile - -*Note on logging:* configure your application to stream logs into `php://stdout`. That's it. - -## About swoole - -Swoole version is not configurable. We always provide the latest available via Ondrej's PPA to this version of PHP. diff --git a/php/8.1/overrides.conf b/php/8.1/overrides.conf deleted file mode 100644 index e1c0646..0000000 --- a/php/8.1/overrides.conf +++ /dev/null @@ -1,27 +0,0 @@ -[global] -; Override default pid file -pid = /run/php-fpm.pid - -; Avoid logs being sent to syslog -error_log = /proc/self/fd/2 - -; Set this to php default's max_execution_time to allow children to stop gracefully when fpm is commanded to stop -; This helps avoiding 502's -process_control_timeout = 30 - -; Do not daemonize (eg send process to the background) -daemonize = no - -[www] -; Access from webserver container is via network, not socket file -listen = [::]:9000 - -; Redirect logs to stdout - FPM closes /dev/std* on startup -access.log = /proc/self/fd/2 -catch_workers_output = yes - -; Remove "pool www" decoration from log output (older phpdocker.io containers for php use sed for this) -decorate_workers_output = no - -; Required to allow config-by-environment -clear_env = no diff --git a/php/8.2/Dockerfile b/php/8.2/Dockerfile deleted file mode 100644 index a0c76fb..0000000 --- a/php/8.2/Dockerfile +++ /dev/null @@ -1,59 +0,0 @@ -############################################ -# PHPDocker.io PHP 8.2 / CLI and FPM image # -############################################ - -### CLI ### - -FROM ubuntu:jammy AS cli - -# Fixes some weird terminal issues such as broken clear / CTRL+L -ENV TERM=linux - -# Ensure apt doesn't ask questions when installing stuff -ENV DEBIAN_FRONTEND=noninteractive - -# Install Ondrej repos for Ubuntu jammy, PHP, composer and selected extensions - better selection than -# the distro's packages -RUN apt-get update \ - && apt-get install -y --no-install-recommends gnupg \ - && echo "deb http://ppa.launchpad.net/ondrej/php/ubuntu jammy main" > /etc/apt/sources.list.d/ondrej-php.list \ - && apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 4F4EA0AAE5267A6C \ - && apt-get update \ - && apt-get -y --no-install-recommends install \ - ca-certificates \ - curl \ - unzip \ - php8.2-apcu \ - php8.2-cli \ - php8.2-curl \ - php8.2-mbstring \ - php8.2-opcache \ - php8.2-readline \ - php8.2-xml \ - php8.2-zip \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/* ~/.composer - -COPY --from=composer:2 /usr/bin/composer /usr/bin/composer - -CMD ["php", "-a"] - -### FPM ### - -FROM cli AS fpm - -# Install FPM -RUN apt-get update \ - && apt-get -y --no-install-recommends install php8.2-fpm \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/* - -STOPSIGNAL SIGQUIT - -# PHP-FPM packages need a nudge to make them docker-friendly -COPY overrides.conf /etc/php/8.2/fpm/pool.d/z-overrides.conf - -CMD ["/usr/sbin/php-fpm8.2", "-O" ] - -# Open up fcgi port -EXPOSE 9000 diff --git a/php/8.2/README.md b/php/8.2/README.md deleted file mode 100644 index 05a18d1..0000000 --- a/php/8.2/README.md +++ /dev/null @@ -1,11 +0,0 @@ -# PHPDocker.io - PHP 8.2 / CLI, FPM and Swoole container images - -Ubuntu 22.04 PHP 8.2 CLI and FPM container images for [PHPDocker.io](http://phpdocker.io) projects. Packages are provided by [Ondřej Surý](https://deb.sury.org/). - -Far smaller in size than PHP's official container. No need to compile any extensions: simply run `apt-get install php8.2-EXTENSION_NAME` as part of your Dockerfile - -*Note on logging:* configure your application to stream logs into `php://stdout`. That's it. - -## About swoole - -Swoole version is not configurable. We always provide the latest available via Ondrej's PPA to this version of PHP. diff --git a/php/8.3/Dockerfile b/php/8.3/Dockerfile deleted file mode 100644 index dc16e0f..0000000 --- a/php/8.3/Dockerfile +++ /dev/null @@ -1,59 +0,0 @@ -############################################ -# PHPDocker.io PHP 8.3 / CLI and FPM image # -############################################ - -### CLI ### - -FROM ubuntu:jammy AS cli - -# Fixes some weird terminal issues such as broken clear / CTRL+L -ENV TERM=linux - -# Ensure apt doesn't ask questions when installing stuff -ENV DEBIAN_FRONTEND=noninteractive - -# Install Ondrej repos for Ubuntu jammy, PHP, composer and selected extensions - better selection than -# the distro's packages -RUN apt-get update \ - && apt-get install -y --no-install-recommends gnupg \ - && echo "deb http://ppa.launchpad.net/ondrej/php/ubuntu jammy main" > /etc/apt/sources.list.d/ondrej-php.list \ - && apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 4F4EA0AAE5267A6C \ - && apt-get update \ - && apt-get -y --no-install-recommends install \ - ca-certificates \ - curl \ - unzip \ - php8.3-apcu \ - php8.3-cli \ - php8.3-curl \ - php8.3-mbstring \ - php8.3-opcache \ - php8.3-readline \ - php8.3-xml \ - php8.3-zip \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/* ~/.composer - -COPY --from=composer:2 /usr/bin/composer /usr/bin/composer - -CMD ["php", "-a"] - -### FPM ### - -FROM cli AS fpm - -# Install FPM -RUN apt-get update \ - && apt-get -y --no-install-recommends install php8.3-fpm \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/* - -STOPSIGNAL SIGQUIT - -# PHP-FPM packages need a nudge to make them docker-friendly -COPY overrides.conf /etc/php/8.3/fpm/pool.d/z-overrides.conf - -CMD ["/usr/sbin/php-fpm8.3", "-O" ] - -# Open up fcgi port -EXPOSE 9000 diff --git a/php/8.3/README.md b/php/8.3/README.md deleted file mode 100644 index 0d1eec3..0000000 --- a/php/8.3/README.md +++ /dev/null @@ -1,7 +0,0 @@ -# PHPDocker.io - PHP 8.3 / CLI, FPM and Swoole container images - -Ubuntu 22.04 PHP 8.3 CLI and FPM container images for [PHPDocker.io](http://phpdocker.io) projects. Packages are provided by [Ondřej Surý](https://deb.sury.org/). - -Far smaller in size than PHP's official container. No need to compile any extensions: simply run `apt-get install php8.3-EXTENSION_NAME` as part of your Dockerfile - -*Note on logging:* configure your application to stream logs into `php://stdout`. That's it. diff --git a/php/8.3/overrides.conf b/php/8.3/overrides.conf deleted file mode 100644 index abd9340..0000000 --- a/php/8.3/overrides.conf +++ /dev/null @@ -1,27 +0,0 @@ -[global] -; Override default pid file -pid = /run/php-fpm.pid - -; Avoid logs being sent to syslog -error_log = /proc/self/fd/2 - -; Set this to php default's max_execution_time to allow children to stop gracefully when fpm is commanded to stop -; This helps avoiding 502's -process_control_timeout = 30 - -; Do not daemonize (eg send process to the background) -daemonize = no - -[www] -; Access from webserver container is via network, not socket file -listen = [::]:9000 - -; Redirect logs to stdout - FPM closes /dev/std* on startup -access.log = /proc/self/fd/2 -catch_workers_output = yes - -; Remove "pool www" decoration from log output -decorate_workers_output = no - -; Required to allow config-by-environment -clear_env = no diff --git a/php/8.4/Dockerfile b/php/8.4/Dockerfile deleted file mode 100644 index 055ca64..0000000 --- a/php/8.4/Dockerfile +++ /dev/null @@ -1,59 +0,0 @@ -############################################ -# PHPDocker.io PHP 8.4 / CLI and FPM image # -############################################ - -### CLI ### - -FROM ubuntu:noble AS cli - -# Fixes some weird terminal issues such as broken clear / CTRL+L -ENV TERM=linux - -# Ensure apt doesn't ask questions when installing stuff -ENV DEBIAN_FRONTEND=noninteractive - -# Install Ondrej repos for Ubuntu, PHP, composer and selected extensions - better selection than -# the distro's packages -RUN apt-get update \ - && apt-get install -y --no-install-recommends gnupg \ - && echo "deb http://ppa.launchpad.net/ondrej/php/ubuntu noble main" > /etc/apt/sources.list.d/ondrej-php.list \ - && apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 4F4EA0AAE5267A6C \ - && apt-get update \ - && apt-get -y --no-install-recommends install \ - ca-certificates \ - curl \ - unzip \ - php8.4-apcu \ - php8.4-cli \ - php8.4-curl \ - php8.4-mbstring \ - php8.4-opcache \ - php8.4-readline \ - php8.4-xml \ - php8.4-zip \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/* ~/.composer - -COPY --from=composer:2 /usr/bin/composer /usr/bin/composer - -CMD ["php", "-a"] - -### FPM ### - -FROM cli AS fpm - -# Install FPM -RUN apt-get update \ - && apt-get -y --no-install-recommends install php8.4-fpm \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/* - -STOPSIGNAL SIGQUIT - -# PHP-FPM packages need a nudge to make them docker-friendly -COPY overrides.conf /etc/php/8.4/fpm/pool.d/z-overrides.conf - -CMD ["/usr/sbin/php-fpm8.4", "-O" ] - -# Open up fcgi port -EXPOSE 9000 diff --git a/php/8.4/README.md b/php/8.4/README.md deleted file mode 100644 index 689a968..0000000 --- a/php/8.4/README.md +++ /dev/null @@ -1,7 +0,0 @@ -# PHPDocker.io - PHP 8.4 / CLI, FPM and Swoole container images - -Ubuntu 22.04 PHP 8.4 CLI and FPM container images for [PHPDocker.io](http://phpdocker.io) projects. Packages are provided by [Ondřej Surý](https://deb.sury.org/). - -Far smaller in size than PHP's official container. No need to compile any extensions: simply run `apt-get install php8.4-EXTENSION_NAME` as part of your Dockerfile - -*Note on logging:* configure your application to stream logs into `php://stdout`. That's it. diff --git a/php/8.4/overrides.conf b/php/8.4/overrides.conf deleted file mode 100644 index abd9340..0000000 --- a/php/8.4/overrides.conf +++ /dev/null @@ -1,27 +0,0 @@ -[global] -; Override default pid file -pid = /run/php-fpm.pid - -; Avoid logs being sent to syslog -error_log = /proc/self/fd/2 - -; Set this to php default's max_execution_time to allow children to stop gracefully when fpm is commanded to stop -; This helps avoiding 502's -process_control_timeout = 30 - -; Do not daemonize (eg send process to the background) -daemonize = no - -[www] -; Access from webserver container is via network, not socket file -listen = [::]:9000 - -; Redirect logs to stdout - FPM closes /dev/std* on startup -access.log = /proc/self/fd/2 -catch_workers_output = yes - -; Remove "pool www" decoration from log output -decorate_workers_output = no - -; Required to allow config-by-environment -clear_env = no diff --git a/php/8.5/Dockerfile b/php/8.5/Dockerfile deleted file mode 100644 index 774ec63..0000000 --- a/php/8.5/Dockerfile +++ /dev/null @@ -1,58 +0,0 @@ -############################################ -# PHPDocker.io PHP 8.5 / CLI and FPM image # -############################################ - -### CLI ### - -FROM ubuntu:noble AS cli - -# Fixes some weird terminal issues such as broken clear / CTRL+L -ENV TERM=linux - -# Ensure apt doesn't ask questions when installing stuff -ENV DEBIAN_FRONTEND=noninteractive - -# Install Ondrej repos for Ubuntu, PHP, composer and selected extensions - better selection than -# the distro's packages -RUN apt-get update \ - && apt-get install -y --no-install-recommends gnupg \ - && echo "deb http://ppa.launchpad.net/ondrej/php/ubuntu noble main" > /etc/apt/sources.list.d/ondrej-php.list \ - && apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 4F4EA0AAE5267A6C \ - && apt-get update \ - && apt-get -y --no-install-recommends install \ - ca-certificates \ - curl \ - unzip \ - php8.5-apcu \ - php8.5-cli \ - php8.5-curl \ - php8.5-mbstring \ - php8.5-readline \ - php8.5-xml \ - php8.5-zip \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/* ~/.composer - -COPY --from=composer:2 /usr/bin/composer /usr/bin/composer - -CMD ["php", "-a"] - -### FPM ### - -FROM cli AS fpm - -# Install FPM -RUN apt-get update \ - && apt-get -y --no-install-recommends install php8.5-fpm \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/* - -STOPSIGNAL SIGQUIT - -# PHP-FPM packages need a nudge to make them docker-friendly -COPY overrides.conf /etc/php/8.5/fpm/pool.d/z-overrides.conf - -CMD ["/usr/sbin/php-fpm8.5", "-O" ] - -# Open up fcgi port -EXPOSE 9000 diff --git a/php/8.5/README.md b/php/8.5/README.md deleted file mode 100644 index 304f041..0000000 --- a/php/8.5/README.md +++ /dev/null @@ -1,7 +0,0 @@ -# PHPDocker.io - PHP 8.5 / CLI, FPM and Swoole container images - -Ubuntu 22.04 PHP 8.5 CLI and FPM container images for [PHPDocker.io](http://phpdocker.io) projects. Packages are provided by [Ondřej Surý](https://deb.sury.org/). - -Far smaller in size than PHP's official container. No need to compile any extensions: simply run `apt-get install php8.5-EXTENSION_NAME` as part of your Dockerfile - -*Note on logging:* configure your application to stream logs into `php://stdout`. That's it. diff --git a/php/8.5/overrides.conf b/php/8.5/overrides.conf deleted file mode 100644 index abd9340..0000000 --- a/php/8.5/overrides.conf +++ /dev/null @@ -1,27 +0,0 @@ -[global] -; Override default pid file -pid = /run/php-fpm.pid - -; Avoid logs being sent to syslog -error_log = /proc/self/fd/2 - -; Set this to php default's max_execution_time to allow children to stop gracefully when fpm is commanded to stop -; This helps avoiding 502's -process_control_timeout = 30 - -; Do not daemonize (eg send process to the background) -daemonize = no - -[www] -; Access from webserver container is via network, not socket file -listen = [::]:9000 - -; Redirect logs to stdout - FPM closes /dev/std* on startup -access.log = /proc/self/fd/2 -catch_workers_output = yes - -; Remove "pool www" decoration from log output -decorate_workers_output = no - -; Required to allow config-by-environment -clear_env = no From b2e7a748e4648da664dbaba8e31c063703a97a8a Mon Sep 17 00:00:00 2001 From: Luis Pabon Date: Wed, 21 Oct 2026 19:42:39 +0100 Subject: [PATCH 2/2] CI: build cli and fpm in one job per PHP version, sharing cache scope --- .github/workflows/docker-build.yaml | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/.github/workflows/docker-build.yaml b/.github/workflows/docker-build.yaml index 668620b..b2cfdbd 100644 --- a/.github/workflows/docker-build.yaml +++ b/.github/workflows/docker-build.yaml @@ -18,7 +18,6 @@ jobs: strategy: matrix: php: [ '8.1', '8.2', '8.3', '8.4', '8.5' ] - target: [ 'cli', 'fpm' ] include: # Ubuntu base image per PHP version - { php: '8.1', ubuntu: 'jammy' } @@ -49,7 +48,7 @@ jobs: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: PHP ${{ matrix.php }} ${{ matrix.target }} container + - name: PHP CLI container uses: docker/build-push-action@v6 with: context: . @@ -60,7 +59,23 @@ jobs: push: ${{ github.ref == 'refs/heads/master' }} pull: true # Enable BuildKit cache restore/save across workflow runs - cache-from: type=gha,scope=php-${{ matrix.php }}-${{ matrix.target }} - cache-to: type=gha,mode=max,scope=php-${{ matrix.php }}-${{ matrix.target }} - tags: phpdockerio/php:${{ matrix.php }}-${{ matrix.target }} - target: ${{ matrix.target }} + cache-from: type=gha,scope=php-${{ matrix.php }} + cache-to: type=gha,mode=max,scope=php-${{ matrix.php }} + tags: phpdockerio/php:${{ matrix.php }}-cli + target: cli + + # FPM is built on top of the CLI stage, so it reuses its layers from the cache above + - name: PHP FPM container + uses: docker/build-push-action@v6 + with: + context: . + build-args: | + PHP_VERSION=${{ matrix.php }} + UBUNTU=${{ matrix.ubuntu }} + platforms: linux/amd64,linux/arm64,linux/arm/v7 + push: ${{ github.ref == 'refs/heads/master' }} + pull: true + cache-from: type=gha,scope=php-${{ matrix.php }} + cache-to: type=gha,mode=max,scope=php-${{ matrix.php }} + tags: phpdockerio/php:${{ matrix.php }}-fpm + target: fpm