From 3cd00cd30127653897cd2ae3868e8e0cbe888aae Mon Sep 17 00:00:00 2001 From: Michael Aguiar Date: Wed, 21 Oct 2026 14:27:15 -0700 Subject: [PATCH 1/4] Build the 8.3-8.5 cli images on the official php images The cli images used Alpine's PHP packages, which on stable branches sit on one patch release for months: 8.3-cli was on 8.3.19 and 8.4-cli on 8.4.16, both still exposed to CVE-2026-109618/109619, and 8.5-cli needed alpine:edge. The official php:X-cli-alpine images track php.net and are the same PHP build the frankenphp images use. Each image keeps its extension set, user, ini settings, timezone and the /usr/bin/php and /usr/bin/phpXY paths. Extensions now come from install-php-extensions, as in the frankenphp images, so the 8.4 wordpress cli image installs the same list as frankenphp/Dockerfile.wordpress. The unused php-cgi and phpdbg binaries are removed. --- .github/workflows/build-and-push.yml | 9 ++-- README.md | 2 +- php/8.3/cli/Dockerfile | 67 +++++++++++++++------------- php/8.4/cli/Dockerfile | 61 +++++++++++-------------- php/8.4/cli/Dockerfile.wordpress | 16 +++---- php/8.5/cli/Dockerfile | 66 ++++++++++++++------------- 6 files changed, 113 insertions(+), 108 deletions(-) diff --git a/.github/workflows/build-and-push.yml b/.github/workflows/build-and-push.yml index f4e5c8d..48c0d74 100644 --- a/.github/workflows/build-and-push.yml +++ b/.github/workflows/build-and-push.yml @@ -101,10 +101,11 @@ jobs: php/8.5/frankenphp/docker-configure # Images with no in-repo FROM dependency - safe to build fully in parallel. - # The frankenphp images live in their own build-frankenphp-base job below: - # every one of these still finishes in well under a minute (confirmed from - # actual run logs), so there's nothing to gain from the digest-split/native - # -arm64 treatment frankenphp needs - it would only add job overhead here. + # The frankenphp images live in their own build-frankenphp-base job below. + # The 8.3-8.5 cli images compile their extensions (install-php-extensions on + # the official php images), which is slower under QEMU for arm64; if these + # legs become the bottleneck, give them the digest-split/native-arm64 + # treatment frankenphp has. build-base: needs: detect-changes runs-on: ubuntu-latest diff --git a/README.md b/README.md index 6098288..2c80a38 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ docker pull ghcr.io/aliasproject/php:8.4-frankenphp ## Variants -- **cli** — Alpine + the PHP CLI SAPI and a minimal extension set (`pdo_mysql`, `bcmath`, `pcntl`, `posix`, etc.), unlimited execution time, runs as an unprivileged `appuser` in group `0`. +- **cli** — the PHP CLI with unlimited execution time. 8.3–8.5 are built on the official `php:-cli-alpine` images, so they get php.net patch releases as soon as those images do (7.4–8.1 still use Alpine's EOL packages). 8.4 has a minimal extension set (`pdo_mysql`, `bcmath`, `intl`, `pcntl`, `zip`, etc.) and runs as an unprivileged `appuser` in group `0`; 8.3 and 8.5 also include `gd`, `exif`, `imagick`, `mysqli`, `redis` and `igbinary`, and run as root. - **frankenphp** — FrankenPHP serves PHP directly through Caddy; no separate web server. Minimal extension set, non-root by default, mail sent through `msmtp`, Composer baked in, `HEALTHCHECK` against Caddy's admin API. - **frankenphp (dev)** — the FrankenPHP base with extra extensions (`mysqli`, `gd`, `exif`, `imagick`, `redis`, `igbinary`, `soap`) for local development. - **frankenphp (wordpress)** — the FrankenPHP base with the same extensions as `dev`, plus a hardening policy suited to running WordPress (see below). diff --git a/php/8.3/cli/Dockerfile b/php/8.3/cli/Dockerfile index 48b07c3..784e87e 100644 --- a/php/8.3/cli/Dockerfile +++ b/php/8.3/cli/Dockerfile @@ -1,37 +1,42 @@ -FROM alpine:3.21 +# Official image: it tracks php.net patch releases, where Alpine's stable +# branches can sit on one PHP patch release for months, and it is the same +# PHP build the frankenphp images use (php:*-zts-alpine under +# dunglas/frankenphp), so CLI and web containers run the same PHP. +FROM php:8.3-cli-alpine LABEL maintainer="Michael Aguiar " -RUN apk add --no-cache \ - curl \ - php83 \ - php83-bcmath \ - php83-common \ - php83-ctype \ - php83-curl \ - php83-dom \ - php83-exif \ - php83-fileinfo \ - php83-gd \ - php83-iconv \ - php83-mbstring \ - php83-mysqli \ - php83-opcache \ - php83-openssl \ - php83-pcntl \ - php83-pdo_mysql \ - php83-pecl-imagick \ - php83-pecl-redis \ - php83-phar \ - php83-posix \ - php83-session \ - php83-simplexml \ - php83-sodium \ - php83-tokenizer \ - php83-xml \ - php83-xmlreader \ - php83-xmlwriter \ - php83-zip +# Same installer the frankenphp images ship. +COPY --from=mlocati/php-extension-installer:2 /usr/bin/install-php-extensions /usr/local/bin/ + +# Same extensions as the Alpine-package image this replaced. igbinary and +# msgpack are installed alongside redis so it's built with both serializers. +RUN apk add --no-cache tzdata && \ + install-php-extensions \ + bcmath \ + exif \ + gd \ + igbinary \ + imagick \ + msgpack \ + mysqli \ + pcntl \ + pdo_mysql \ + redis \ + sockets \ + zip && \ + \ + cp "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" && \ + printf 'max_execution_time = 0\ndate.timezone = UTC\n' \ + > "$PHP_INI_DIR/conf.d/99-cli.ini" && \ + \ + # The Alpine-package image this replaced had PHP at /usr/bin/php and + # /usr/bin/php83; keep both working for scripts that call them. + ln -s /usr/local/bin/php /usr/bin/php && \ + ln -s /usr/local/bin/php /usr/bin/php83 && \ + \ + # The CGI and debugger SAPIs are ~20MB each and unused in a CLI image. + rm /usr/local/bin/php-cgi /usr/local/bin/phpdbg WORKDIR /app diff --git a/php/8.4/cli/Dockerfile b/php/8.4/cli/Dockerfile index c14d76b..e46a790 100644 --- a/php/8.4/cli/Dockerfile +++ b/php/8.4/cli/Dockerfile @@ -1,51 +1,44 @@ -# Alpine 3.22 matches the OS of the frankenphp base image (3.22.2), keeping the -# CLI and web PHP builds on the same release line. -FROM alpine:3.22 +# Official image: it tracks php.net patch releases, where Alpine's stable +# branches can sit on one PHP patch release for months, and it is the same +# PHP build the frankenphp images use (php:*-zts-alpine under +# dunglas/frankenphp), so CLI and web containers run the same PHP. +FROM php:8.4-cli-alpine LABEL maintainer="Michael Aguiar " ARG APP_UID=1000 +# Same installer the frankenphp images ship, so derived images +# (Dockerfile.wordpress) install extensions with the same names and builds. +COPY --from=mlocati/php-extension-installer:2 /usr/bin/install-php-extensions /usr/local/bin/ + # Tier 1 only: the PHP runtime itself, plus pdo_mysql as the generic modern # driver (mysqlnd is compiled in, so the shim is effectively free). # # Deliberately NOT here -- each picks a backend or wraps an external library, # and belongs in a derived image: mysqli, redis, igbinary, gd, exif, imagick, # soap, pgsql. -RUN apk add --no-cache \ - ca-certificates \ - curl \ - tzdata \ - php84 \ - php84-bcmath \ - php84-common \ - php84-ctype \ - php84-curl \ - php84-dom \ - php84-fileinfo \ - php84-iconv \ - php84-intl \ - php84-mbstring \ - php84-opcache \ - php84-openssl \ - php84-pcntl \ - php84-pdo_mysql \ - php84-phar \ - php84-posix \ - php84-session \ - php84-simplexml \ - php84-sodium \ - php84-tokenizer \ - php84-xml \ - php84-xmlreader \ - php84-xmlwriter \ - php84-zip && \ - ln -s /usr/bin/php84 /usr/bin/php && \ +RUN apk add --no-cache tzdata && \ + install-php-extensions \ + bcmath \ + intl \ + pcntl \ + pdo_mysql \ + zip && \ \ + cp "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" && \ # CLI tasks (search-replace, imports, exports) blow past the 128M default. # max_execution_time 0 = unlimited, which is the CLI SAPI norm. - printf 'memory_limit = 512M\nmax_execution_time = 0\n' \ - > /etc/php84/conf.d/99-cli.ini && \ + printf 'memory_limit = 512M\nmax_execution_time = 0\ndate.timezone = UTC\n' \ + > "$PHP_INI_DIR/conf.d/99-cli.ini" && \ + \ + # The Alpine-package images this replaced had PHP at /usr/bin/php and + # /usr/bin/php84; keep both working for scripts that call them. + ln -s /usr/local/bin/php /usr/bin/php && \ + ln -s /usr/local/bin/php /usr/bin/php84 && \ + \ + # The CGI and debugger SAPIs are ~20MB each and unused in a CLI image. + rm /usr/local/bin/php-cgi /usr/local/bin/phpdbg && \ \ # Match the frankenphp images: unprivileged UID in group 0 adduser -u ${APP_UID} -G root -s /sbin/nologin -D appuser && \ diff --git a/php/8.4/cli/Dockerfile.wordpress b/php/8.4/cli/Dockerfile.wordpress index a3efc0a..2287bf7 100644 --- a/php/8.4/cli/Dockerfile.wordpress +++ b/php/8.4/cli/Dockerfile.wordpress @@ -25,13 +25,13 @@ RUN if [ "${APP_UID}" != "$(id -u appuser)" ]; then \ # igbinary in particular is a correctness requirement, not parity for its own # sake -- the redis-cache plugin can serialize with it, and a CLI without # igbinary silently fails to deserialize the object cache. -RUN apk add --no-cache \ - php84-exif \ - php84-gd \ - php84-mysqli \ - php84-pecl-igbinary \ - php84-pecl-imagick \ - php84-pecl-redis \ - php84-soap +RUN install-php-extensions \ + mysqli \ + gd \ + exif \ + redis \ + igbinary \ + imagick \ + soap USER appuser diff --git a/php/8.5/cli/Dockerfile b/php/8.5/cli/Dockerfile index 74ee39c..b021497 100644 --- a/php/8.5/cli/Dockerfile +++ b/php/8.5/cli/Dockerfile @@ -1,36 +1,42 @@ -FROM alpine:edge +# Official image: it tracks php.net patch releases, where Alpine's stable +# branches can sit on one PHP patch release for months, and it is the same +# PHP build the frankenphp images use (php:*-zts-alpine under +# dunglas/frankenphp), so CLI and web containers run the same PHP. +FROM php:8.5-cli-alpine LABEL maintainer="Michael Aguiar " -RUN apk add --no-cache \ - curl \ - php85 \ - php85-bcmath \ - php85-common \ - php85-ctype \ - php85-curl \ - php85-dom \ - php85-exif \ - php85-fileinfo \ - php85-gd \ - php85-iconv \ - php85-mbstring \ - php85-mysqli \ - php85-openssl \ - php85-pcntl \ - php85-pdo_mysql \ - php85-pecl-imagick \ - php85-pecl-redis \ - php85-phar \ - php85-posix \ - php85-session \ - php85-simplexml \ - php85-sodium \ - php85-tokenizer \ - php85-xml \ - php85-xmlreader \ - php85-xmlwriter \ - php85-zip +# Same installer the frankenphp images ship. +COPY --from=mlocati/php-extension-installer:2 /usr/bin/install-php-extensions /usr/local/bin/ + +# Same extensions as the Alpine-package image this replaced. igbinary and +# msgpack are installed alongside redis so it's built with both serializers. +RUN apk add --no-cache tzdata && \ + install-php-extensions \ + bcmath \ + exif \ + gd \ + igbinary \ + imagick \ + msgpack \ + mysqli \ + pcntl \ + pdo_mysql \ + redis \ + sockets \ + zip && \ + \ + cp "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" && \ + printf 'max_execution_time = 0\ndate.timezone = UTC\n' \ + > "$PHP_INI_DIR/conf.d/99-cli.ini" && \ + \ + # The Alpine-package image this replaced had PHP at /usr/bin/php and + # /usr/bin/php85; keep both working for scripts that call them. + ln -s /usr/local/bin/php /usr/bin/php && \ + ln -s /usr/local/bin/php /usr/bin/php85 && \ + \ + # The CGI and debugger SAPIs are ~20MB each and unused in a CLI image. + rm /usr/local/bin/php-cgi /usr/local/bin/phpdbg WORKDIR /app From 416141cbabc6107fbb75ad1e9ab40b52e4b7b07c Mon Sep 17 00:00:00 2001 From: Michael Aguiar Date: Wed, 21 Oct 2026 14:33:46 -0700 Subject: [PATCH 2/4] Keep the cli images' MySQL socket default and fix doc claims The Alpine-package images defaulted mysqli and pdo_mysql to /run/mysqld/mysqld.sock; the official images leave both empty, so a "localhost" connection fell back to /tmp/mysql.sock and failed where the MariaDB socket is mounted at /run/mysqld. Set both in 99-cli.ini. Removing php-cgi/phpdbg deleted files from the base image's layer, which saves nothing in image or pull size, so drop it. Correct the header comment (the frankenphp images use the ZTS variant of the same images, not the same build) and the README (images rebuild only on a Dockerfile change or a manual run; 8.3/8.5 don't have intl; ini path). --- README.md | 2 +- php/8.3/cli/Dockerfile | 15 +++++++-------- php/8.4/cli/Dockerfile | 13 ++++++------- php/8.5/cli/Dockerfile | 15 +++++++-------- 4 files changed, 21 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 2c80a38..c0f3774 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ docker pull ghcr.io/aliasproject/php:8.4-frankenphp ## Variants -- **cli** — the PHP CLI with unlimited execution time. 8.3–8.5 are built on the official `php:-cli-alpine` images, so they get php.net patch releases as soon as those images do (7.4–8.1 still use Alpine's EOL packages). 8.4 has a minimal extension set (`pdo_mysql`, `bcmath`, `intl`, `pcntl`, `zip`, etc.) and runs as an unprivileged `appuser` in group `0`; 8.3 and 8.5 also include `gd`, `exif`, `imagick`, `mysqli`, `redis` and `igbinary`, and run as root. +- **cli** — the PHP CLI with unlimited execution time. 8.3–8.5 are built on the official `php:-cli-alpine` images, so a rebuild picks up the latest php.net patch release (7.4–8.1 still use Alpine's EOL packages). Images are only rebuilt when their Dockerfile changes or the workflow is run by hand. PHP's ini files are in `/usr/local/etc/php` (`conf.d/` for overrides). 8.4 has a minimal extension set (`pdo_mysql`, `bcmath`, `intl`, `pcntl`, `zip`, etc.) and runs as an unprivileged `appuser` in group `0`. 8.3 and 8.5 have a different set (`bcmath`, `pcntl`, `pdo_mysql`, `zip` plus `gd`, `exif`, `imagick`, `mysqli`, `redis`, `igbinary`, `msgpack` and `sockets`, but not `intl`) and run as root. - **frankenphp** — FrankenPHP serves PHP directly through Caddy; no separate web server. Minimal extension set, non-root by default, mail sent through `msmtp`, Composer baked in, `HEALTHCHECK` against Caddy's admin API. - **frankenphp (dev)** — the FrankenPHP base with extra extensions (`mysqli`, `gd`, `exif`, `imagick`, `redis`, `igbinary`, `soap`) for local development. - **frankenphp (wordpress)** — the FrankenPHP base with the same extensions as `dev`, plus a hardening policy suited to running WordPress (see below). diff --git a/php/8.3/cli/Dockerfile b/php/8.3/cli/Dockerfile index 784e87e..43c7c34 100644 --- a/php/8.3/cli/Dockerfile +++ b/php/8.3/cli/Dockerfile @@ -1,7 +1,7 @@ # Official image: it tracks php.net patch releases, where Alpine's stable -# branches can sit on one PHP patch release for months, and it is the same -# PHP build the frankenphp images use (php:*-zts-alpine under -# dunglas/frankenphp), so CLI and web containers run the same PHP. +# branches can sit on one PHP patch release for months. The frankenphp images +# are built on the same images (the ZTS variant, php:*-zts-alpine), so CLI and +# web containers get PHP from the same source and build recipe. FROM php:8.3-cli-alpine LABEL maintainer="Michael Aguiar " @@ -26,17 +26,16 @@ RUN apk add --no-cache tzdata && \ sockets \ zip && \ \ + # The socket paths are the ones the Alpine-package image this replaced + # used; without them mysqlnd falls back to /tmp/mysql.sock. cp "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" && \ - printf 'max_execution_time = 0\ndate.timezone = UTC\n' \ + printf 'max_execution_time = 0\ndate.timezone = UTC\nmysqli.default_socket = /run/mysqld/mysqld.sock\npdo_mysql.default_socket = /run/mysqld/mysqld.sock\n' \ > "$PHP_INI_DIR/conf.d/99-cli.ini" && \ \ # The Alpine-package image this replaced had PHP at /usr/bin/php and # /usr/bin/php83; keep both working for scripts that call them. ln -s /usr/local/bin/php /usr/bin/php && \ - ln -s /usr/local/bin/php /usr/bin/php83 && \ - \ - # The CGI and debugger SAPIs are ~20MB each and unused in a CLI image. - rm /usr/local/bin/php-cgi /usr/local/bin/phpdbg + ln -s /usr/local/bin/php /usr/bin/php83 WORKDIR /app diff --git a/php/8.4/cli/Dockerfile b/php/8.4/cli/Dockerfile index e46a790..1dc145c 100644 --- a/php/8.4/cli/Dockerfile +++ b/php/8.4/cli/Dockerfile @@ -1,7 +1,7 @@ # Official image: it tracks php.net patch releases, where Alpine's stable -# branches can sit on one PHP patch release for months, and it is the same -# PHP build the frankenphp images use (php:*-zts-alpine under -# dunglas/frankenphp), so CLI and web containers run the same PHP. +# branches can sit on one PHP patch release for months. The frankenphp images +# are built on the same images (the ZTS variant, php:*-zts-alpine), so CLI and +# web containers get PHP from the same source and build recipe. FROM php:8.4-cli-alpine LABEL maintainer="Michael Aguiar " @@ -29,7 +29,9 @@ RUN apk add --no-cache tzdata && \ cp "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" && \ # CLI tasks (search-replace, imports, exports) blow past the 128M default. # max_execution_time 0 = unlimited, which is the CLI SAPI norm. - printf 'memory_limit = 512M\nmax_execution_time = 0\ndate.timezone = UTC\n' \ + # The socket paths are the ones the Alpine-package image this replaced + # used; without them mysqlnd falls back to /tmp/mysql.sock. + printf 'memory_limit = 512M\nmax_execution_time = 0\ndate.timezone = UTC\nmysqli.default_socket = /run/mysqld/mysqld.sock\npdo_mysql.default_socket = /run/mysqld/mysqld.sock\n' \ > "$PHP_INI_DIR/conf.d/99-cli.ini" && \ \ # The Alpine-package images this replaced had PHP at /usr/bin/php and @@ -37,9 +39,6 @@ RUN apk add --no-cache tzdata && \ ln -s /usr/local/bin/php /usr/bin/php && \ ln -s /usr/local/bin/php /usr/bin/php84 && \ \ - # The CGI and debugger SAPIs are ~20MB each and unused in a CLI image. - rm /usr/local/bin/php-cgi /usr/local/bin/phpdbg && \ - \ # Match the frankenphp images: unprivileged UID in group 0 adduser -u ${APP_UID} -G root -s /sbin/nologin -D appuser && \ mkdir -p /app && \ diff --git a/php/8.5/cli/Dockerfile b/php/8.5/cli/Dockerfile index b021497..17c08ad 100644 --- a/php/8.5/cli/Dockerfile +++ b/php/8.5/cli/Dockerfile @@ -1,7 +1,7 @@ # Official image: it tracks php.net patch releases, where Alpine's stable -# branches can sit on one PHP patch release for months, and it is the same -# PHP build the frankenphp images use (php:*-zts-alpine under -# dunglas/frankenphp), so CLI and web containers run the same PHP. +# branches can sit on one PHP patch release for months. The frankenphp images +# are built on the same images (the ZTS variant, php:*-zts-alpine), so CLI and +# web containers get PHP from the same source and build recipe. FROM php:8.5-cli-alpine LABEL maintainer="Michael Aguiar " @@ -26,17 +26,16 @@ RUN apk add --no-cache tzdata && \ sockets \ zip && \ \ + # The socket paths are the ones the Alpine-package image this replaced + # used; without them mysqlnd falls back to /tmp/mysql.sock. cp "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" && \ - printf 'max_execution_time = 0\ndate.timezone = UTC\n' \ + printf 'max_execution_time = 0\ndate.timezone = UTC\nmysqli.default_socket = /run/mysqld/mysqld.sock\npdo_mysql.default_socket = /run/mysqld/mysqld.sock\n' \ > "$PHP_INI_DIR/conf.d/99-cli.ini" && \ \ # The Alpine-package image this replaced had PHP at /usr/bin/php and # /usr/bin/php85; keep both working for scripts that call them. ln -s /usr/local/bin/php /usr/bin/php && \ - ln -s /usr/local/bin/php /usr/bin/php85 && \ - \ - # The CGI and debugger SAPIs are ~20MB each and unused in a CLI image. - rm /usr/local/bin/php-cgi /usr/local/bin/phpdbg + ln -s /usr/local/bin/php /usr/bin/php85 WORKDIR /app From 6132bc6288c9773da11dbb7667337f16d5ead144 Mon Sep 17 00:00:00 2001 From: Michael Aguiar Date: Wed, 21 Oct 2026 14:55:30 -0700 Subject: [PATCH 3/4] Make the 8.3 and 8.5 cli images match 8.4 8.4-cli was reworked into the tiered design (minimal extensions, unprivileged appuser, 512M memory limit) but 8.3 and 8.5 kept the older root, all-extensions layout. The three are now identical apart from the PHP version. 8.3/8.5 drop gd, exif, imagick, mysqli, redis, igbinary, msgpack and sockets (they belong in a derived image, as in 8.4/cli/Dockerfile.wordpress), gain intl, and run as uid 1000. --- README.md | 2 +- php/8.3/cli/Dockerfile | 41 ++++++++++++++++++++++++++--------------- php/8.5/cli/Dockerfile | 41 ++++++++++++++++++++++++++--------------- 3 files changed, 53 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index c0f3774..ff2fb41 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ docker pull ghcr.io/aliasproject/php:8.4-frankenphp ## Variants -- **cli** — the PHP CLI with unlimited execution time. 8.3–8.5 are built on the official `php:-cli-alpine` images, so a rebuild picks up the latest php.net patch release (7.4–8.1 still use Alpine's EOL packages). Images are only rebuilt when their Dockerfile changes or the workflow is run by hand. PHP's ini files are in `/usr/local/etc/php` (`conf.d/` for overrides). 8.4 has a minimal extension set (`pdo_mysql`, `bcmath`, `intl`, `pcntl`, `zip`, etc.) and runs as an unprivileged `appuser` in group `0`. 8.3 and 8.5 have a different set (`bcmath`, `pcntl`, `pdo_mysql`, `zip` plus `gd`, `exif`, `imagick`, `mysqli`, `redis`, `igbinary`, `msgpack` and `sockets`, but not `intl`) and run as root. +- **cli** — the PHP CLI with unlimited execution time. 8.3–8.5 are built on the official `php:-cli-alpine` images, so a rebuild picks up the latest php.net patch release (7.4–8.1 still use Alpine's EOL packages). Images are only rebuilt when their Dockerfile changes or the workflow is run by hand. PHP's ini files are in `/usr/local/etc/php` (`conf.d/` for overrides). 8.3–8.5 are identical apart from the PHP version: a minimal extension set (`pdo_mysql`, `bcmath`, `intl`, `pcntl`, `zip`, etc.), a 512M memory limit, and an unprivileged `appuser` in group `0`. Backend and library extensions (`mysqli`, `gd`, `imagick`, `redis`, `igbinary`, …) belong in a derived image such as `php/8.4/cli/Dockerfile.wordpress`. - **frankenphp** — FrankenPHP serves PHP directly through Caddy; no separate web server. Minimal extension set, non-root by default, mail sent through `msmtp`, Composer baked in, `HEALTHCHECK` against Caddy's admin API. - **frankenphp (dev)** — the FrankenPHP base with extra extensions (`mysqli`, `gd`, `exif`, `imagick`, `redis`, `igbinary`, `soap`) for local development. - **frankenphp (wordpress)** — the FrankenPHP base with the same extensions as `dev`, plus a hardening policy suited to running WordPress (see below). diff --git a/php/8.3/cli/Dockerfile b/php/8.3/cli/Dockerfile index 43c7c34..3f34827 100644 --- a/php/8.3/cli/Dockerfile +++ b/php/8.3/cli/Dockerfile @@ -6,37 +6,48 @@ FROM php:8.3-cli-alpine LABEL maintainer="Michael Aguiar " -# Same installer the frankenphp images ship. +ARG APP_UID=1000 + +# Same installer the frankenphp images ship, so derived images +# (Dockerfile.wordpress) install extensions with the same names and builds. COPY --from=mlocati/php-extension-installer:2 /usr/bin/install-php-extensions /usr/local/bin/ -# Same extensions as the Alpine-package image this replaced. igbinary and -# msgpack are installed alongside redis so it's built with both serializers. +# Tier 1 only: the PHP runtime itself, plus pdo_mysql as the generic modern +# driver (mysqlnd is compiled in, so the shim is effectively free). +# +# Deliberately NOT here -- each picks a backend or wraps an external library, +# and belongs in a derived image: mysqli, redis, igbinary, gd, exif, imagick, +# soap, pgsql. RUN apk add --no-cache tzdata && \ install-php-extensions \ bcmath \ - exif \ - gd \ - igbinary \ - imagick \ - msgpack \ - mysqli \ + intl \ pcntl \ pdo_mysql \ - redis \ - sockets \ zip && \ \ + cp "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" && \ + # CLI tasks (search-replace, imports, exports) blow past the 128M default. + # max_execution_time 0 = unlimited, which is the CLI SAPI norm. # The socket paths are the ones the Alpine-package image this replaced # used; without them mysqlnd falls back to /tmp/mysql.sock. - cp "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" && \ - printf 'max_execution_time = 0\ndate.timezone = UTC\nmysqli.default_socket = /run/mysqld/mysqld.sock\npdo_mysql.default_socket = /run/mysqld/mysqld.sock\n' \ + printf 'memory_limit = 512M\nmax_execution_time = 0\ndate.timezone = UTC\nmysqli.default_socket = /run/mysqld/mysqld.sock\npdo_mysql.default_socket = /run/mysqld/mysqld.sock\n' \ > "$PHP_INI_DIR/conf.d/99-cli.ini" && \ \ - # The Alpine-package image this replaced had PHP at /usr/bin/php and + # The Alpine-package images this replaced had PHP at /usr/bin/php and # /usr/bin/php83; keep both working for scripts that call them. ln -s /usr/local/bin/php /usr/bin/php && \ - ln -s /usr/local/bin/php /usr/bin/php83 + ln -s /usr/local/bin/php /usr/bin/php83 && \ + \ + # Match the frankenphp images: unprivileged UID in group 0 + adduser -u ${APP_UID} -G root -s /sbin/nologin -D appuser && \ + mkdir -p /app && \ + chgrp -R 0 /app && \ + chmod -R g=u /app WORKDIR /app +# Running unprivileged keeps file ownership consistent with the web containers. +USER ${APP_UID}:0 + CMD ["php", "-a"] diff --git a/php/8.5/cli/Dockerfile b/php/8.5/cli/Dockerfile index 17c08ad..0105167 100644 --- a/php/8.5/cli/Dockerfile +++ b/php/8.5/cli/Dockerfile @@ -6,37 +6,48 @@ FROM php:8.5-cli-alpine LABEL maintainer="Michael Aguiar " -# Same installer the frankenphp images ship. +ARG APP_UID=1000 + +# Same installer the frankenphp images ship, so derived images +# (Dockerfile.wordpress) install extensions with the same names and builds. COPY --from=mlocati/php-extension-installer:2 /usr/bin/install-php-extensions /usr/local/bin/ -# Same extensions as the Alpine-package image this replaced. igbinary and -# msgpack are installed alongside redis so it's built with both serializers. +# Tier 1 only: the PHP runtime itself, plus pdo_mysql as the generic modern +# driver (mysqlnd is compiled in, so the shim is effectively free). +# +# Deliberately NOT here -- each picks a backend or wraps an external library, +# and belongs in a derived image: mysqli, redis, igbinary, gd, exif, imagick, +# soap, pgsql. RUN apk add --no-cache tzdata && \ install-php-extensions \ bcmath \ - exif \ - gd \ - igbinary \ - imagick \ - msgpack \ - mysqli \ + intl \ pcntl \ pdo_mysql \ - redis \ - sockets \ zip && \ \ + cp "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" && \ + # CLI tasks (search-replace, imports, exports) blow past the 128M default. + # max_execution_time 0 = unlimited, which is the CLI SAPI norm. # The socket paths are the ones the Alpine-package image this replaced # used; without them mysqlnd falls back to /tmp/mysql.sock. - cp "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" && \ - printf 'max_execution_time = 0\ndate.timezone = UTC\nmysqli.default_socket = /run/mysqld/mysqld.sock\npdo_mysql.default_socket = /run/mysqld/mysqld.sock\n' \ + printf 'memory_limit = 512M\nmax_execution_time = 0\ndate.timezone = UTC\nmysqli.default_socket = /run/mysqld/mysqld.sock\npdo_mysql.default_socket = /run/mysqld/mysqld.sock\n' \ > "$PHP_INI_DIR/conf.d/99-cli.ini" && \ \ - # The Alpine-package image this replaced had PHP at /usr/bin/php and + # The Alpine-package images this replaced had PHP at /usr/bin/php and # /usr/bin/php85; keep both working for scripts that call them. ln -s /usr/local/bin/php /usr/bin/php && \ - ln -s /usr/local/bin/php /usr/bin/php85 + ln -s /usr/local/bin/php /usr/bin/php85 && \ + \ + # Match the frankenphp images: unprivileged UID in group 0 + adduser -u ${APP_UID} -G root -s /sbin/nologin -D appuser && \ + mkdir -p /app && \ + chgrp -R 0 /app && \ + chmod -R g=u /app WORKDIR /app +# Running unprivileged keeps file ownership consistent with the web containers. +USER ${APP_UID}:0 + CMD ["php", "-a"] From ef1cb7eb0dbd659daa17aa49296d4b570efefcd9 Mon Sep 17 00:00:00 2001 From: Michael Aguiar Date: Wed, 21 Oct 2026 14:58:31 -0700 Subject: [PATCH 4/4] README: env-var configuration applies to the frankenphp images only The cli images have no ENV block; say how to override their settings. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ff2fb41..188eba4 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ docker pull ghcr.io/aliasproject/php:8.4-frankenphp - **frankenphp (dev)** — the FrankenPHP base with extra extensions (`mysqli`, `gd`, `exif`, `imagick`, `redis`, `igbinary`, `soap`) for local development. - **frankenphp (wordpress)** — the FrankenPHP base with the same extensions as `dev`, plus a hardening policy suited to running WordPress (see below). -Every image is configurable via environment variables — `PHP_MEMORY_LIMIT`, `PHP_OPCACHE_*`, `PHP_UPLOAD_MAX_FILESIZE`, etc. — see each Dockerfile's `ENV` block for the defaults. +Every frankenphp image is configurable via environment variables — `PHP_MEMORY_LIMIT`, `PHP_OPCACHE_*`, `PHP_UPLOAD_MAX_FILESIZE`, etc. — see each Dockerfile's `ENV` block for the defaults. The cli images have no such variables; override PHP settings with an ini file in `/usr/local/etc/php/conf.d/` or `php -d`. ## Static asset caching