Repository navigation
feat(php-base)!: install extensions with PIE, remove vips (#23) - #51
Merged
Merged
Conversation
Work in progress on #23. Slim tier verified by build; standard tier written but its build was interrupted and has NOT been verified; dev tier not started; the 27 files that still mention vips not swept. The pecl binary does not exist in php:8.6 images and the PECL network service has a stated shelf life, so this path had to go regardless of when 8.6 is added. Mappings verified against Packagist (they are not mechanical - pecl `redis` is PIE `phpredis/phpredis`): redis phpredis/phpredis apcu apcu/apcu msgpack msgpack/msgpack-php imagick imagick/imagick mongodb mongodb/mongodb-extension opentelemetry open-telemetry/ext-opentelemetry vips is dropped: it has no PIE package under any name, is PECL-only, and its upstream repo has been untouched since 2024-10 with its newest git tag three releases behind what PECL serves. It could not survive the pecl retirement by waiting, migrating, or building from a tag. GD and ImageMagick remain, which the e2e scenario already called the primary image libraries. PIE is delivered as a pinned, sha256-verified phar via scripts/download-pie.sh, the same pattern as cbox-init and fpm-exporter, rather than bind-mounted from a floating registry tag as upstream's examples do: a floating tag is neither reproducible nor available on demand (ghcr's blob CDN 502'd for twenty minutes while this was written). It is bind-mounted from the build context so the 8.6 MB phar leaves no layer behind. Five real defects surfaced while doing this, each fixed here: - The Dockerfile's ARG defaults had drifted from versions.json (apcu, mongodb, msgpack, xdebug). CI passes the right values, so only local builds silently got a different extension set. - PIE is stricter than pecl: Packagist carries only what the maintainer tagged, so msgpack 3.0.0 does not exist there and the stale default failed hard instead of installing something else. - A COPY of the phar would have shipped 8.6 MB of build tooling in every image; a layer cannot be shrunk by deleting its contents later. - The bind mount under /tmp broke the cleanup's `rm -rf /tmp/*` with "Device or resource busy". - Purging unzip after the PIE step removed a RUNTIME tool shipped by slim-base, breaking the Node/bun install downstream. tests/test-runtime-deps.sh caught that one, which is why it exists.
BREAKING: the vips extension is gone from the standard tier and above. The pecl binary does not exist in php:8.6 images (--with-pear dropped, PECL formally deprecated) and the PECL network service has a stated shelf life, so this migration had to happen whether or not 8.6 is added (#23). All three tiers verified by build - slim, standard and dev carry the same extensions at the same pinned versions as before: redis 6.3.0 apcu 5.1.28 msgpack 3.0.1 imagick 3.8.1 mongodb 2.5.2 xdebug 3.5.3 pcov 1.0.12 spx 0.4.22 Two downstream behaviours that depend on ini filenames still hold, which is why PIE's naming was measured before anything was migrated: the standard tier still moves docker-php-ext-opentelemetry.ini out of the scan dir (it is installed, not loaded), and the dev tier's own xdebug/spx/pcov ini files still overwrite what PIE wrote. vips could not come along. It has no PIE package under any name, PECL-only, upstream untouched since 2024-10 with its newest git tag three releases behind what PECL serves - so it could not survive the pecl retirement by waiting, migrating, or building from a tag. GD and ImageMagick remain, which the e2e scenario already called the primary image libraries. Its dead runtime packages come out of php-fpm too. PIE is delivered as a pinned, sha256-verified phar via scripts/download-pie.sh - the cbox-init/fpm-exporter pattern - rather than bind-mounted from a floating registry tag as upstream's examples do. A floating tag is neither reproducible nor dependably available: ghcr's blob CDN 502'd for both php/pie tags for twenty minutes while this was written. It is bind-mounted from the build context, so none of its 8.6 MB lands in a layer. Also fixes ARG defaults that had drifted from versions.json (apcu, mongodb, msgpack, xdebug). CI passes build-args, so only local builds were affected - silently getting a different extension set than production. pecl served those older versions happily; PIE does not, because Packagist carries only what a maintainer tagged. New gate: tests/test-arg-defaults.sh. Refs #23
The first CI run of the migration failed on both architectures:
"/pie/binaries/pie.phar": not found
The phar is gitignored, exactly like the cbox-init and fpm-exporter
binaries, and every workflow that builds php-base downloads those in a
dedicated step. PIE was never added to them.
Local builds were green throughout because scripts/download-pie.sh had
already populated the directory, so the gap existed only where nobody
had run that script - which is every CI runner.
All seven download steps across _build-image.yml, e2e-tests.yml and
integration-tests.yml now fetch the phar and verify it against the
sha256 in versions.json, next to the other two binaries. The exact
command was run against a clean directory to confirm the URL and the
checksum before pushing.
… random
PIE resolves from Packagist but downloads extension source from GitHub, and
unauthenticated GitHub allows 60 requests/hour per IP. CI runners share IP
ranges, so a full matrix exhausts that in minutes and PIE fails with
Could not download mongodb/mongodb-extension using pre-packaged-source
method: Could not authenticate against github.com
which is Composer's HTTP layer raising 401/403 - what a rate-limited anonymous
request returns.
It is probabilistic, and that is the trap. The full-matrix proof run
(39584014996) lost exactly one cell of 95: dev-rootless 8.3 on amd64, while
8.3/arm64 and 8.4/amd64 installed the same mongodb package at the same pinned
version fine. One lost cell is not one lost build - its `merge` job skips and
that tier's tag is never promoted, so the published image quietly keeps its old
digest. Across the ~97 jobs of the real chain that is likelier to happen than
not, which makes it a publishing risk, not a nuisance.
All three PIE steps take GITHUB_TOKEN as a build SECRET, not a build-arg: a
secret is not recorded in the mode=max provenance attestation and does not land
in a layer. required=false keeps local builds working anonymously. The five
php-base builds across _build-image.yml, e2e-tests.yml and integration-tests.yml
pass secrets.GITHUB_TOKEN, raising the allowance to 1000/hour per repository.
The provenance comment that claimed "no secret build-args" was updated rather
than left to drift.
Verified three ways:
- build with no secret succeeds (PIE runs anonymous)
- with a secret, the value reaches the subprocess PIE runs in
- a command failing mid-chain still fails the build
The third mattered most: a wrong shell prologue would have made genuine build
failures exit 0.
Run 39588448211 lost the merge job for slim 8.5 at the SARIF scan:
failed to download vulnerability DB from mirror.gcr.io/aquasec/trivy-db:2:
unexpected status code 429 Too Many Requests
Where it died matters. The scanner failed; the gate step was skipped and never
judged anything, so this was not a CVE finding. But a failed merge job moves no
tags - the same mechanism that kept the 8-20 October publishing outage
invisible - so a scanner that cannot fetch its database is a publishing outage
in a different costume.
trivy-action does not set TRIVY_DB_REPOSITORY, so Trivy used its own default
list, [mirror.gcr.io/..., ghcr.io/...], and still aborted on the first entry's
429 instead of trying the second. The documented "order of priority" fallback
therefore does not cover a rate limit, so reordering is the fix rather than
adding a fallback that already existed.
All three invocations now name ghcr.io/aquasecurity/trivy-db:2 first. The merge
job has already run docker/login-action against ghcr.io, and Trivy's OCI client
reads those credentials out of the docker config, so that pull is authenticated
rather than sharing one anonymous per-IP allowance with the whole runner fleet.
mirror.gcr.io stays second.
Not fixed here: the DB is fetched once per merge job, ~20 times per chain,
because the action caches only the Trivy binary. Caching the DB across jobs is
the next improvement.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
peclbinary does not exist inphp:8.6images (--with-peardropped, PECL formally deprecated — docker-library/php#1682) and the PECL network service has a stated shelf life. This migration had to happen whether or not 8.6 is added, which is why it is landing on its own rather than as part of an 8.6 PR.What changed
Every
pecl installinphp-base/Dockerfileis nowpie install. Package names are not mechanical, and each was verified against Packagist:phpredis/phpredisapcu/apcumsgpack/msgpack-phpimagick/imagickmongodb/mongodb-extensionopen-telemetry/ext-opentelemetryxdebug/xdebugpecl/pcovPIE arrives as a pinned, sha256-verified phar via
scripts/download-pie.sh— the cbox-init/fpm-exporter pattern — rather than bind-mounted from a floating registry tag as upstream's own examples do. A floating tag is neither reproducible nor dependably available: ghcr's blob CDN returned 502 for bothphp/pietags for twenty minutes while this was being written. The phar is bind-mounted from the build context, so none of its 8.6 MB lands in a layer.Verification
All three tiers built locally. Same extensions, same pinned versions as before:
Two downstream behaviours depend on the ini filename the installer writes, so PIE's naming was measured before anything was migrated rather than assumed — it writes the same
docker-php-ext-<name>.inithatdocker-php-ext-enabledid:docker-php-ext-opentelemetry.iniout of the scan dir (installed, not loaded — confirmed in the built image)xdebug.ini→zend_extension=xdebug, confirmed)gitandunzipstill present in the dev tier, both of which this change nearly broke (below).Five defects found on the way, all fixed here
versions.json— apcu 5.1.27/5.1.28, mongodb 2.1.4/2.5.2, msgpack 3.0.0/3.0.1, xdebug 3.5.0/3.5.3. CI passes build-args, so only local builds were affected: anyone reproducing a bug got a different extension set than production, silently. New gate:tests/test-arg-defaults.sh, verified by reintroducing the old apcu default and watching it fail.COPYof the phar ships 8.6 MB in every image — a layer cannot be shrunk by deleting its contents later. Hence the bind mount./tmpbroke the cleanup'srm -rf /tmp/*withDevice or resource busy.unzipafter the PIE step removed a RUNTIME tool shipped by slim-base, breaking the Node/bun install downstream.tests/test-runtime-deps.shcaught it — which is exactly why that test exists ("a tier must not drop a tool the tiers below it ship").The breaking part: vips
It is the one extension that could not come along. No PIE package under any name, PECL-only, upstream repository untouched since 2024-10, and its newest git tag (
v1.0.10) is three releases behind what PECL serves — so it could not survive the pecl retirement by waiting for a tag, by migrating, or by building from one.intervention/imageruns on GD or ImageMagick.The e2e scenario already called libvips optional — "GD and ImageMagick are the primary image libraries" — and its section is removed with a note saying why.
Swept out of the whole repo, not just the Dockerfile. That turned up two functional leftovers:
php-fpmstill installedlibvips42/libvips-toolsas runtime dead weight, andscripts/update-versions.shwould have tried to update aversions.jsonkey that no longer exists.On the deprecation policy:
versions.jsonsetswarning_before_removal_days: 90, so I raised whether vips deserved a deprecation window rather than an outright removal. Decided: no window, the removal stands. The policy'sdeprecatedlist is empty and never named vips — it is written for PHP/OS/Node versions — so nothing inversions.jsonchanges on account of it.Not in here
PHP 8.6 itself. Six extensions still have no 8.6-compatible release (fixes merged upstream but untagged), and SPX fails on 8.6 even from master — the beta lane tracks all of it. This PR only removes the thing that was blocking the migration from being possible at all.
Refs #23