Skip to content

v4 runtime images on Ubuntu 26.04 - #351

Draft
mnapoli wants to merge 6 commits into
4.xfrom
v4-images
Draft

mnapoli wants to merge 6 commits into
4.xfrom
v4-images

Conversation

@mnapoli

@mnapoli mnapoli commented Nov 18, 2026 •

Copy link
Copy Markdown
Member

First step of the v4 runtime: the images, built and tested, without the Customer-Managed Runtime publishing yet (separate PR).

What changes compared to v3:

  • Ubuntu 26.04, PHP compiled by us, one Dockerfile for every PHP version (versions in docker-bake.hcl).
  • No layers: nothing in /opt (Lambda mounts layers there and they would hide it). PHP in /usr/local, config in /etc/php, bootstrap in /var/runtime. Extension layers still work: /opt/bref/etc/php/conf.d is still scanned.
  • Multi-architecture images: bref/php-85 serves both x86 and arm (no more arm- prefix), plus -dev and bref/build-php-85 for building extensions.
  • Default extensions compiled statically (faster PHP startup), same enabled set as v3. Optional ones unchanged for now (intl, soap, apcu, redis, disabled).
  • Ubuntu's OpenSSL 3.5, without Amazon Linux's SnapSafe patch for now (to simplify): environments restored from the same SnapStart snapshot share OpenSSL's random generator state.
  • zend.assertions=-1, certificates at /usr/lib/ssl/cert.pem (and still at v3's /etc/pki/tls/cert.pem).
  • The image contains /var/task and /etc/hosts, which Lambda requires (without them the environment silently never starts).

Validated: make test passes for 8.3, 8.4 and 8.5 (arm64), and the 8.5 image runs as a CMR runtime on Lambda (function, FPM, Laravel) with today's bref/bref 3.x thanks to a php-fpm wrapper (src/php-fpm-v3-compat.sh, to remove once bref/bref v4 reads /etc/php/php-fpm.conf).

Choices to validate:

  • PHP 8.3, 8.4, 8.5 (8.2 is end of life at the end of 2026).
  • Image names bref/php-XX, bref/php-XX-dev, bref/build-php-XX, Docker tag 4.

Not in this PR: CMR runtime publishing (versions, aliases, pre-warming), the extra extensions, the HTTP server mode (nginx/FrankenPHP), the single php/php-fpm binary, bref/bref v4.

The branch merges 4.x (#350: src/php-85.ini is gone, its fastcgi_finish_request change lands in src/php.ini), and the tests now run on pushes to 4.x instead of v4.

- One Dockerfile for PHP 8.3, 8.4 and 8.5 (versions in docker-bake.hcl), multi-architecture
  images (linux/amd64 + linux/arm64): bref/php-XX, bref/php-XX-dev, bref/build-php-XX.
- No more Lambda layers: nothing is installed in /opt (layers would hide it). PHP in /usr/local,
  configuration in /etc/php, Bref's bootstrap in /var/runtime.
- PHP compiled with -O2 instead of -Os, default extensions compiled statically, optional ones
  (intl, soap, apcu, redis) shared and disabled as before.
- OpenSSL 3.5 built with Amazon Linux's SnapSafe patch (SnapStart-safe randomness).
- zend.assertions=-1.
- php-fpm wrapper so that bref/bref 3.x (which starts FPM with /opt/bref/etc/php-fpm.conf) works.
@mnapoli

mnapoli commented Nov 18, 2026

Copy link
Copy Markdown
Member Author

Measured on Lambda (CMR runtime, arm64, 1024 MB, 20 cold starts each, interleaved): A = v3 layer, B = the research prototype (al2023-v4), C = this branch's PHP 8.5 image.

A v3 layer B prototype C this PR
hello FPM cold start 231 ms 168 ms (-63 [-81, -43]) 202 ms (-30 [-64, -8])
Laravel cold start 1174 ms 1078 ms (-95 [-155, 8]) 1135 ms (-39 [-122, 66])
FPM memory 72 MB 59 MB 73 MB

Warm requests: no difference (1.5 ms hello, ~16 ms Laravel). The gap between B and C is mostly the single php/php-fpm binary (php-src#23558 backport, -12 to -16 ms of FPM init and -8 MB), which the prototype has and this PR does not, plus Ubuntu's ~5 MB more memory than Amazon Linux. Adding the single binary is a follow-up PR (the backport only exists for 8.5 so far).

@mnapoli mnapoli self-assigned this Nov 18, 2026
@mnapoli
mnapoli added this pull request to stack #354 November 18, 2026 20:42
Simpler for now. Without it, environments restored from the same SnapStart snapshot share OpenSSL's random generator state.
Comment thread Makefile
PHP_VERSION=$* DOCKER_PLATFORM=linux/amd64,linux/arm64 ${BAKE_COMMAND} --push \
--set "build-php.tags=bref/build-php-$*:4" --set "build-php.tags=bref/build-php-$*:${DOCKER_TAG}" --set "build-php.tags=bref/build-php-$*:latest" \
--set "php.tags=bref/php-$*:4" --set "php.tags=bref/php-$*:${DOCKER_TAG}" --set "php.tags=bref/php-$*:latest" \
--set "php-dev.tags=bref/php-$*-dev:4" --set "php-dev.tags=bref/php-$*-dev:${DOCKER_TAG}" --set "php-dev.tags=bref/php-$*-dev:latest"

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't want to publish latest for now (as long as v3 is the stable version)

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