Repository navigation
Build the 8.3–8.5 CLI images on the official PHP images - #11
Conversation
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.
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).
Review round 1 (single round)I had a reviewer with fresh context check this PR with Confirmed holds
Findings
|
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.
The cli images have no ENV block; say how to override their settings.
Review round 2 (narrow: 6132bc6, 8.3/8.5 matched to 8.4)Mike decided that the 8.3 and 8.5 CLI images should be identical to 8.4 apart from the PHP version. In 6132bc6 they now run as uid 1000 with 512M and 8.4's minimal extensions. They gain A reviewer with fresh context found no defects in that commit. Confirmed holds
Fixed: the reviewer noted an inaccuracy from before this PR. The README said every image takes |
Summary
The 8.3, 8.4 and 8.5 CLI images used Alpine's PHP packages. Alpine's stable releases rarely move to a new PHP patch release, so the published images were well behind:
php:X-cli-alpine)8.3-cli8.4-cli8.5-clialpine:edge)All three were still exposed to CVE-2026-109618/109619. The official images follow php.net releases, and the FrankenPHP images are built on the thread-safe (ZTS) variant of the same images. CLI and web containers now get PHP from the same source and build recipe, currently at the same patch versions.
Kept the same as before:
max_execution_time = 0,php.ini-productiondefaults anddate.timezone=UTC;/run/mysqld/mysqld.sock, formysqliandpdo_mysql. The official images leave it empty, which falls back to/tmp/mysql.sock;/usr/bin/phpand/usr/bin/phpXY, which are symlinks now, so existing scripts keep working;8.3 and 8.5 now match 8.4 apart from the PHP version. They used to run as root with a large extension set; now they have:
appuser, group0);intland dropsgd,exif,imagick,mysqli,redis,igbinary,msgpackandsockets. Those belong in a derived image, as in8.4/cli/Dockerfile.wordpress.Anything that relied on those extensions in
8.3-clior8.5-cli, or on running as root, needs a derived image.What changed:
install-php-extensions, like the FrankenPHP images.8.4/cli/Dockerfile.wordpressnow installs the same list asfrankenphp/Dockerfile.wordpress./etc/php8X/to/usr/local/etc/php/. A volume mounting a custom ini into/etc/php84/conf.d/would silently stop applying, so mount into/usr/local/etc/php/conf.d/instead. A derived image that runsapk add php84-…must switch toinstall-php-extensions ….7.4, 8.0 and 8.1 are unchanged. They're end-of-life, and the official images for them don't get fixes either.
Trade-offs
Image size.
intl.Build time and pecl. Extensions are compiled during the build rather than installed as Alpine packages (pecl ones only in derived images such as the wordpress CLI image). arm64 builds run under QEMU, so they'll be slower, and a pecl outage can fail a build. FrankenPHP wordpress builds already work this way.
Benchmark
All runs were on the same host (amd64), pinned to one CPU core, with medians of 5 runs (
bench.php) or 3 runs (others). Each pair was run twice, interleaved.bench.phpandmicro_bench.phpcome from php-src. Startup is onephp -vcall.bench.phpmicro_bench.phpbench.php33%,micro_bench.php40–41%), and slightly less on 8.5. The old Alpine 3.21/3.22 builds were much slower than both thealpine:edgeand official builds. Alpine doesn't show its compiler flags, so I couldn't confirm why.Test plan
8.4-cli-wordpressbuilt against the new8.4-cli.pdo_sqlite/sqlite3, which the official image builds in), uid, ini values, timezone, MySQL socket defaults and/usr/bin/php*paths./appwritable, and the same modules apart from 8.5's built-inlexboranduri.8.4-frankenphp-wordpressis read correctly by the new8.4-cli-wordpress.8.4-cli-wordpress:/appis writable as uid 1000;wp --inforuns on PHP 8.4.27.8.4-cli-wordpressisn't built by CI today, so the change to its Dockerfile is only tested locally.