Skip to content

feat(php-base)!: install extensions with PIE, remove vips (#23) - #51

Merged
sylvesterdamgaard merged 5 commits into
mainfrom
feat/pie-migration
Oct 21, 2026
Merged

sylvesterdamgaard merged 5 commits into
mainfrom
feat/pie-migration

Conversation

@sylvesterdamgaard

@sylvesterdamgaard sylvesterdamgaard commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Breaking: the vips extension is removed from the standard tier and above. See the bottom of this description before merging.

The pecl binary does not exist in php:8.6 images (--with-pear dropped, 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 install in php-base/Dockerfile is now pie install. Package names are not mechanical, and each was verified against Packagist:

extension PIE package
redis phpredis/phpredis
apcu apcu/apcu
msgpack msgpack/msgpack-php
imagick imagick/imagick
mongodb mongodb/mongodb-extension
opentelemetry open-telemetry/ext-opentelemetry
xdebug xdebug/xdebug
pcov pecl/pcov

PIE 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 both php/pie tags 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:

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 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>.ini that docker-php-ext-enable did:

  • the standard tier still moves docker-php-ext-opentelemetry.ini out of the scan dir (installed, not loaded — confirmed in the built image)
  • the dev tier's own xdebug/spx/pcov ini files still overwrite what PIE wrote (xdebug.ini → zend_extension=xdebug, confirmed)

git and unzip still present in the dev tier, both of which this change nearly broke (below).

Five defects found on the way, all fixed here

  1. ARG defaults had drifted from 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.
  2. PIE is stricter than pecl — Packagist carries only what a maintainer tagged, and msgpack 3.0.0 does not exist there at all. Where pecl served the stale default happily, PIE fails the build. That is an improvement, but it means every pin must exist on Packagist.
  3. A COPY of the phar ships 8.6 MB in every image — a layer cannot be shrunk by deleting its contents later. Hence the bind mount.
  4. The bind mount under /tmp broke the cleanup's rm -rf /tmp/* with Device or resource busy.
  5. 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 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/image runs on GD or ImageMagick.
  • ImageMagick covers the formats the comparison table credited to libvips (HEIC/HEIF, SVG, colour profiles).
  • What is genuinely lost is libvips' memory profile on very large images. If that is load-bearing, run libvips as its own service rather than in the PHP container.

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-fpm still installed libvips42/libvips-tools as runtime dead weight, and scripts/update-versions.sh would have tried to update a versions.json key that no longer exists.

On the deprecation policy: versions.json sets warning_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's deprecated list is empty and never named vips — it is written for PHP/OS/Node versions — so nothing in versions.json changes 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

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.
@sylvesterdamgaard
sylvesterdamgaard merged commit e45e42a into main Oct 21, 2026
121 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant