diff --git a/.github/workflows/build-and-push.yml b/.github/workflows/build-and-push.yml index 341640c..145c6a0 100644 --- a/.github/workflows/build-and-push.yml +++ b/.github/workflows/build-and-push.yml @@ -20,6 +20,9 @@ jobs: - '8.5' - '8.5-frankenphp' - '8.5-www' + - '8.6' + - '8.6-frankenphp' + - '8.6-www' runs-on: blacksmith-4vcpu-ubuntu-2404 steps: - name: Checkout @@ -63,6 +66,9 @@ jobs: - '8.5' - '8.5-frankenphp' - '8.5-www' + - '8.6' + - '8.6-frankenphp' + - '8.6-www' runs-on: blacksmith-4vcpu-ubuntu-2404-arm steps: - name: Checkout @@ -108,6 +114,9 @@ jobs: - '8.5' - '8.5-frankenphp' - '8.5-www' + - '8.6' + - '8.6-frankenphp' + - '8.6-www' runs-on: blacksmith-2vcpu-ubuntu-2404 steps: - name: Checkout diff --git a/8.6-frankenphp/Dockerfile b/8.6-frankenphp/Dockerfile new file mode 100644 index 0000000..dba29d1 --- /dev/null +++ b/8.6-frankenphp/Dockerfile @@ -0,0 +1,163 @@ +ARG PHP_VERSION=8.6.0RC7 +ARG FRANKENPHP_VERSION=1.13.5 +ARG GO_VERSION=1.27 +ARG WATCHER_VERSION=0.14.5 + +# FrankenPHP does not publish PHP 8.6 images yet, so it is compiled here following +# its upstream Dockerfile. Since PHP 8.6 every official php image is built as ZTS +# with the embed SAPI (the separate "-zts" variant was dropped), so the "cli" +# variant is the FrankenPHP base. +FROM golang:${GO_VERSION}-trixie AS golang-base + +# ----------------------------------------------------- +# FrankenPHP Build +# ----------------------------------------------------- +FROM php:${PHP_VERSION}-cli-trixie AS builder + +ARG FRANKENPHP_VERSION +ARG WATCHER_VERSION +SHELL ["/bin/bash", "-o", "pipefail", "-c"] + +COPY --from=golang-base /usr/local/go /usr/local/go + +ENV PATH=/usr/local/go/bin:$PATH +ENV GOTOOLCHAIN=local + +RUN apt-get update && apt-get -y --no-install-recommends install \ + cmake \ + git \ + libargon2-dev \ + libbrotli-dev \ + libcap2-bin \ + libcurl4-openssl-dev \ + libonig-dev \ + libreadline-dev \ + libsodium-dev \ + libsqlite3-dev \ + libssl-dev \ + libxml2-dev \ + zlib1g-dev \ + && rm -rf /var/lib/apt/lists/* + +# e-dant/watcher (FrankenPHP file watching) +WORKDIR /usr/local/src/watcher +RUN curl -fsSL "https://github.com/e-dant/watcher/archive/refs/tags/release/${WATCHER_VERSION}.tar.gz" | tar xz --strip-components 1 \ + && cmake -S . -B build -DCMAKE_BUILD_TYPE=Release \ + && cmake --build build \ + && cmake --install build \ + && ldconfig + +WORKDIR /go/src/app +RUN git clone --depth 1 --branch "v${FRANKENPHP_VERSION}" https://github.com/php/frankenphp.git . \ + && go mod download \ + && cd caddy && go mod download + +# See https://github.com/docker-library/php/blob/master/8.6-rc/trixie/cli/Dockerfile for PHP values +ENV CGO_CFLAGS="-DFRANKENPHP_VERSION=$FRANKENPHP_VERSION $PHP_CFLAGS" +ENV CGO_CPPFLAGS=$PHP_CPPFLAGS +ENV CGO_LDFLAGS="-L/usr/local/lib -lssl -lcrypto -lreadline -largon2 -lcurl -lonig -lz $PHP_LDFLAGS" + +WORKDIR /go/src/app/caddy/frankenphp +RUN GOBIN=/usr/local/bin \ + ../../go.sh install -ldflags "-w -s -X 'github.com/caddyserver/caddy/v2.CustomVersion=FrankenPHP v$FRANKENPHP_VERSION PHP $PHP_VERSION Caddy' -X 'github.com/caddyserver/caddy/v2.CustomBinaryName=frankenphp' -X 'github.com/caddyserver/caddy/v2/modules/caddyhttp.ServerHeader=FrankenPHP Caddy'" -buildvcs=false \ + && setcap cap_net_bind_service=+ep /usr/local/bin/frankenphp \ + && frankenphp version \ + && frankenphp build-info + +# ----------------------------------------------------- +# FrankenPHP +#------------------------------------------------------ +FROM php:${PHP_VERSION}-cli-trixie + +ARG PORT=9001 + +ENV PORT=$PORT SERVER_NAME=":80, :$PORT" +ENV COMPOSER_ALLOW_SUPERUSER=1 COMPOSER_NO_INTERACTION=1 COMPOSER_CACHE_DIR="/tmp" +ENV PHP_INI_SCAN_DIR=":$PHP_INI_DIR/app.conf.d" +# See https://caddyserver.com/docs/conventions#file-locations for details +ENV XDG_CONFIG_HOME=/config XDG_DATA_HOME=/data +ENV GODEBUG=cgocheck=0 + +# PHP 8.6 removed internal C APIs (XtOffsetOf, zval_dtor, INI_STR/INT/FLT, ...). Until PECL releases +# support 8.6: apcu (5.1.29 release commit, not on PECL), igbinary and imagick are built from pinned +# upstream commits, amqp from the sctr/php-amqp fork (php-8.6-support branch, pending upstream), +# redis by scripts/install-phpredis.sh, and protobuf and grpc are left out because no upstream code +# compiles on 8.6 yet. +ENV EXTENSIONS="sctr/php-amqp@7a4318b41915d8957ab207de43783d94db25aa25 krakjoe/apcu@66300e28647c16fef7672a5add532f4262b23a75 ast bcmath exif ffi gd gettext gmp igbinary/igbinary@2b1f5d62e3037b07c2a46499ac32091cdb41fb40 Imagick/imagick@55ed2e9fda264395636a2e27e51f31673f5566ab intl maxminddb mongodb opcache pcntl pdo_mysql pdo_pgsql sockets sysvmsg sysvsem sysvshm uuid xsl zip opentelemetry zstd symfony/php-ext-deepclone@v0.8.11" + +WORKDIR /app + +# php extensions installer: https://github.com/mlocati/docker-php-extension-installer +ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/ +RUN chmod +x /usr/local/bin/install-php-extensions + +RUN apt-get update && apt-get install -y --no-install-recommends \ + git \ + acl \ + file \ + gettext \ + procps \ + supervisor \ + unzip \ + zip \ + imagemagick \ + gifsicle \ + jpegoptim \ + optipng \ + pngquant \ + libnss3-tools \ + mailcap \ + libcap2-bin \ + # Runtime libraries of the webp tools unpacked below + libgif7 libjpeg62-turbo libpng16-16t64 libsharpyuv0 libtiff6 libwebp7 libwebpdemux2 libwebpmux3 \ + # The webp package depends on OpenGL (~200 MB of Mesa and LLVM) only for its vwebp viewer: + # unpack its command-line tools instead of installing it. + && cd /tmp && apt-get download webp \ + && dpkg-deb --fsys-tarfile webp_*.deb | tar -x -C / \ + ./usr/bin/cwebp ./usr/bin/dwebp ./usr/bin/gif2webp ./usr/bin/img2webp ./usr/bin/webpinfo ./usr/bin/webpmux \ + && rm webp_*.deb \ + && rm -rf /var/lib/apt/lists/* + +# Same layout as the upstream FrankenPHP image +RUN set -eux; \ + mkdir -p /app/public /config/caddy /data/caddy /etc/caddy /etc/frankenphp; \ + sed -i 's/php/frankenphp run/g' /usr/local/bin/docker-php-entrypoint + +EXPOSE 80 +EXPOSE 443 +EXPOSE 443/udp +EXPOSE 2019 + +# Install latest libvips +# @see https://github.com/dooman87/imagemagick-docker/blob/main/Dockerfile.bookworm +ARG VIPS_VERSION=8.18.7 +ENV LD_LIBRARY_PATH="/usr/local/lib" +ENV PKG_CONFIG_PATH="/usr/local/lib/pkgconfig" + +COPY --chmod=755 scripts/install-libvips.sh /tmp/install-libvips.sh +RUN /tmp/install-libvips.sh ${VIPS_VERSION} && rm /tmp/install-libvips.sh + +# Install PHP extensions +RUN set -eux; install-php-extensions $EXTENSIONS + +ARG PHPREDIS_REF=623e8db5a39657ba7218ceea81ab8338d248b036 +COPY --chmod=755 scripts/install-phpredis.sh /tmp/install-phpredis.sh +RUN /tmp/install-phpredis.sh ${PHPREDIS_REF} && rm /tmp/install-phpredis.sh + +# Keep frequently changing binaries and startup code after dependency installation. +COPY --from=builder /usr/local/lib/libwatcher* /usr/local/lib/ +COPY --from=builder /usr/local/bin/frankenphp /usr/local/bin/frankenphp +# The builder stage sets cap_net_bind_service, which COPY keeps: running setcap here would +# rewrite the binary into another layer and store it twice. +RUN ldconfig \ + && frankenphp version +COPY --from=composer/composer:2-bin /composer /usr/bin/composer +COPY --link --chmod=755 ./8.6-frankenphp/docker-entrypoint.sh /usr/local/bin/docker-entrypoint + +ENTRYPOINT ["docker-entrypoint"] + +# Copying manifest files to host +COPY ./8.6-frankenphp/manifest / + +# Copy Imagemagick policy +RUN mv /etc/ImageMagick-7/IM7-policy.xml /etc/ImageMagick-7/policy.xml diff --git a/8.6-frankenphp/docker-entrypoint.sh b/8.6-frankenphp/docker-entrypoint.sh new file mode 100644 index 0000000..1e8c9af --- /dev/null +++ b/8.6-frankenphp/docker-entrypoint.sh @@ -0,0 +1,8 @@ +#!/bin/sh +set -e + +if [ "${INSTALL_COMPOSER_DEPS:-0}" = "1" ] && [ -z "$(ls -A 'vendor/' 2>/dev/null)" ]; then + composer install --prefer-dist --no-progress --no-interaction +fi + +exec docker-php-entrypoint "$@" diff --git a/8.6-frankenphp/manifest/etc/ImageMagick-7/IM7-policy.xml b/8.6-frankenphp/manifest/etc/ImageMagick-7/IM7-policy.xml new file mode 100644 index 0000000..94afb84 --- /dev/null +++ b/8.6-frankenphp/manifest/etc/ImageMagick-7/IM7-policy.xml @@ -0,0 +1,156 @@ + + + + + + + + + + + + ]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/8.6-frankenphp/manifest/etc/frankenphp/Caddyfile b/8.6-frankenphp/manifest/etc/frankenphp/Caddyfile new file mode 100644 index 0000000..bdaf309 --- /dev/null +++ b/8.6-frankenphp/manifest/etc/frankenphp/Caddyfile @@ -0,0 +1,26 @@ +{ + {$CADDY_GLOBAL_OPTIONS} + + frankenphp { + {$FRANKENPHP_CONFIG} + } +} + +{$CADDY_EXTRA_CONFIG} + +{$SERVER_NAME:localhost} { + log { + output stdout + format console + } + + root * /app/public + encode zstd br gzip + + {$CADDY_SERVER_EXTRA_DIRECTIVES} + + # Disable Topics tracking if not enabled explicitly: https://github.com/jkarlin/topics + header ?Permissions-Policy "browsing-topics=()" + + php_server +} \ No newline at end of file diff --git a/8.6-frankenphp/manifest/etc/frankenphp/worker.Caddyfile b/8.6-frankenphp/manifest/etc/frankenphp/worker.Caddyfile new file mode 100644 index 0000000..8095c40 --- /dev/null +++ b/8.6-frankenphp/manifest/etc/frankenphp/worker.Caddyfile @@ -0,0 +1,4 @@ +worker { + file /app/public/index.php + env APP_RUNTIME Runtime\FrankenPhpSymfony\Runtime +} diff --git a/8.6-frankenphp/manifest/etc/supervisor/conf.d/frankenphp.conf b/8.6-frankenphp/manifest/etc/supervisor/conf.d/frankenphp.conf new file mode 100644 index 0000000..b4df022 --- /dev/null +++ b/8.6-frankenphp/manifest/etc/supervisor/conf.d/frankenphp.conf @@ -0,0 +1,7 @@ +[program:frankenphp] +command=/usr/local/bin/frankenphp run --config /etc/frankenphp/Caddyfile --adapter caddyfile +autostart=true +autorestart=true +priority=10 +stdout_events_enabled=true +stderr_events_enabled=true diff --git a/8.6-frankenphp/manifest/etc/supervisord.conf b/8.6-frankenphp/manifest/etc/supervisord.conf new file mode 100644 index 0000000..68dc04e --- /dev/null +++ b/8.6-frankenphp/manifest/etc/supervisord.conf @@ -0,0 +1,28 @@ +[unix_http_server] +file=/var/run/supervisor.sock ; (the path to the socket file) + +[supervisord] +loglevel=info ; (log level;default info; others: debug,warn,trace) +pidfile=/var/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid) +nodaemon=false ; (start in foreground if true;default false) +minfds=1024 ; (min. avail startup file descriptors;default 1024) +minprocs=200 ; (min. avail process descriptors;default 200) +user=root ; + +; the below section must remain in the config file for RPC +; (supervisorctl/web interface) to work, additional interfaces may be +; added by defining them in separate rpcinterface: sections +[rpcinterface:supervisor] +supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface + +[supervisorctl] +serverurl=unix:///var/run/supervisor.sock ; use a unix:// URL for a unix socket + +; [eventlistener:stdout] +; command = supervisor_stdout +; buffer_size = 100 +; events = PROCESS_LOG +; result_handler = supervisor_stdout:event_handler + +[include] +files = /etc/supervisor/conf.d/*.conf diff --git a/8.6-frankenphp/manifest/usr/local/etc/php/app.conf.d/10-apc.ini b/8.6-frankenphp/manifest/usr/local/etc/php/app.conf.d/10-apc.ini new file mode 100644 index 0000000..d061fd0 --- /dev/null +++ b/8.6-frankenphp/manifest/usr/local/etc/php/app.conf.d/10-apc.ini @@ -0,0 +1,12 @@ +[apcu] +apc.shm_size=128M +apc.enable_cli=1 +apc.rfc1867=1 +; PHP file cache 1 hour +apc.ttl=3600 +; User cache 2 hour +apc.user_ttl=7200 +; Garbage collection 1 hour +apc.gc_ttl=3600 +; check files +apc.stat=1 diff --git a/8.6-frankenphp/manifest/usr/local/etc/php/app.conf.d/10-ffi.ini b/8.6-frankenphp/manifest/usr/local/etc/php/app.conf.d/10-ffi.ini new file mode 100644 index 0000000..f5cbee2 --- /dev/null +++ b/8.6-frankenphp/manifest/usr/local/etc/php/app.conf.d/10-ffi.ini @@ -0,0 +1,2 @@ +zend.max_allowed_stack_size=-1 +ffi.enable=true \ No newline at end of file diff --git a/8.6-frankenphp/manifest/usr/local/etc/php/app.conf.d/10-opcache.ini b/8.6-frankenphp/manifest/usr/local/etc/php/app.conf.d/10-opcache.ini new file mode 100644 index 0000000..7d0bcdb --- /dev/null +++ b/8.6-frankenphp/manifest/usr/local/etc/php/app.conf.d/10-opcache.ini @@ -0,0 +1,7 @@ +[opcache] +opcache.enable=1 +opcache.memory_consumption=256M +; Must be a prime number +opcache.max_accelerated_files=80051 +opcache.interned_strings_buffer=16 +opcache.enable_file_override=1 diff --git a/8.6-frankenphp/manifest/usr/local/etc/php/app.conf.d/10-php.ini b/8.6-frankenphp/manifest/usr/local/etc/php/app.conf.d/10-php.ini new file mode 100644 index 0000000..6c63805 --- /dev/null +++ b/8.6-frankenphp/manifest/usr/local/etc/php/app.conf.d/10-php.ini @@ -0,0 +1,17 @@ +[PHP] +error_reporting = E_ALL +display_errors = Off +log_errors = On +memory_limit = -1 +max_execution_time = 30 +max_input_time = 30 +expose_php = 0 +date.timezone = UTC +session_use_strict_mode = 1 +session.auto_start = Off +short_open_tag = Off +zend.detect_unicode = 0 +; CVE-2026-109619: upload progress writes a session from any multipart request, before the app runs +session.upload_progress.enabled = 0 +; CVE-2026-109619: removes the stale-state producer used by the confirmed RCE (PHP 8.5+) +fatal_error_backtraces = 0 diff --git a/8.6-frankenphp/manifest/usr/local/etc/php/app.conf.d/10-realpath.ini b/8.6-frankenphp/manifest/usr/local/etc/php/app.conf.d/10-realpath.ini new file mode 100644 index 0000000..134c0cf --- /dev/null +++ b/8.6-frankenphp/manifest/usr/local/etc/php/app.conf.d/10-realpath.ini @@ -0,0 +1,5 @@ +; maximum memory allocated to store the results +realpath_cache_size=8192K + +; save the results for 10 minutes (600 seconds) +realpath_cache_ttl=600 diff --git a/8.6-www/Dockerfile b/8.6-www/Dockerfile new file mode 100644 index 0000000..5417e03 --- /dev/null +++ b/8.6-www/Dockerfile @@ -0,0 +1,163 @@ +ARG CADDY_VERSION=2.11 +ARG FRANKENPHP_VERSION=1.13.5 +ARG PHP_VERSION=8.6.0RC7 +ARG GO_VERSION=1.27 +ARG WATCHER_VERSION=0.14.5 + +FROM caddy:${CADDY_VERSION}-builder AS caddy-builder + +# FrankenPHP does not publish PHP 8.6 images yet, so it is compiled here following +# its upstream Dockerfile. Since PHP 8.6 every official php image is built as ZTS +# with the embed SAPI (the separate "-zts" variant was dropped), so the "cli" +# variant is the FrankenPHP base. +FROM golang:${GO_VERSION}-trixie AS golang-base + +# ----------------------------------------------------- +# FrankenPHP Build +# ----------------------------------------------------- +FROM php:${PHP_VERSION}-cli-trixie AS builder + +ARG FRANKENPHP_VERSION +ARG WATCHER_VERSION +SHELL ["/bin/bash", "-o", "pipefail", "-c"] + +COPY --from=golang-base /usr/local/go /usr/local/go +# Copy xcaddy from caddy builder +COPY --from=caddy-builder /usr/bin/xcaddy /usr/bin/xcaddy + +ENV PATH=/usr/local/go/bin:$PATH +ENV GOTOOLCHAIN=local + +RUN apt-get update && apt-get -y --no-install-recommends install \ + cmake \ + git \ + libargon2-dev \ + libbrotli-dev \ + libcap2-bin \ + libcurl4-openssl-dev \ + libonig-dev \ + libreadline-dev \ + libsodium-dev \ + libsqlite3-dev \ + libssl-dev \ + libxml2-dev \ + zlib1g-dev \ + && rm -rf /var/lib/apt/lists/* + +# e-dant/watcher (FrankenPHP file watching) +WORKDIR /usr/local/src/watcher +RUN curl -fsSL "https://github.com/e-dant/watcher/archive/refs/tags/release/${WATCHER_VERSION}.tar.gz" | tar xz --strip-components 1 \ + && cmake -S . -B build -DCMAKE_BUILD_TYPE=Release \ + && cmake --build build \ + && cmake --install build \ + && ldconfig + +WORKDIR /go/src/app +RUN git clone --depth 1 --branch "v${FRANKENPHP_VERSION}" https://github.com/php/frankenphp.git . + +# Build FrankenPHP with custom Caddy modules +RUN CGO_ENABLED=1 \ + XCADDY_GO_BUILD_FLAGS="-ldflags='-w -s' -tags=nobadger,nomysql,nopgx" \ + CGO_CFLAGS="-DFRANKENPHP_VERSION=$FRANKENPHP_VERSION $PHP_CFLAGS $(php-config --includes)" \ + CGO_CPPFLAGS="$PHP_CPPFLAGS" \ + CGO_LDFLAGS="-L/usr/local/lib -lssl -lcrypto -lreadline -largon2 -lcurl -lonig -lz $PHP_LDFLAGS $(php-config --ldflags) $(php-config --libs)" \ + xcaddy build \ + --output /usr/local/bin/frankenphp \ + --with github.com/dunglas/frankenphp@v${FRANKENPHP_VERSION}=./ \ + --with github.com/dunglas/frankenphp/caddy@v${FRANKENPHP_VERSION}=./caddy/ \ + --with github.com/dunglas/caddy-cbrotli@v1.0.1 \ + #caddy-jwt 1.2.0 + --with github.com/ggicci/caddy-jwt@28e0de3db362a787564352ec22e97aa743a371f3 \ + --with github.com/mholt/caddy-ratelimit@v0.1.0 \ + --with github.com/pberkel/caddy-storage-redis@v1.7.0 \ + && setcap cap_net_bind_service=+ep /usr/local/bin/frankenphp \ + && frankenphp version + +# ----------------------------------------------------- +# FrankenPHP +#------------------------------------------------------ +FROM php:${PHP_VERSION}-cli-trixie + +ARG PORT=9001 + +ENV PORT=$PORT SERVER_NAME=":80, :$PORT" +ENV COMPOSER_ALLOW_SUPERUSER=1 COMPOSER_NO_INTERACTION=1 COMPOSER_CACHE_DIR="/tmp" +ENV PHP_INI_SCAN_DIR=":$PHP_INI_DIR/app.conf.d" +# See https://caddyserver.com/docs/conventions#file-locations for details +ENV XDG_CONFIG_HOME=/config XDG_DATA_HOME=/data +ENV GODEBUG=cgocheck=0 + +# PHP 8.6 removed internal C APIs (XtOffsetOf, zval_dtor, INI_STR/INT/FLT, ...). Until PECL releases +# support 8.6: apcu (5.1.29 release commit, not on PECL), igbinary and imagick are built from pinned +# upstream commits, amqp from the sctr/php-amqp fork (php-8.6-support branch, pending upstream), +# redis by scripts/install-phpredis.sh, and protobuf and grpc are left out because no upstream code +# compiles on 8.6 yet. +ENV EXTENSIONS="sctr/php-amqp@7a4318b41915d8957ab207de43783d94db25aa25 krakjoe/apcu@66300e28647c16fef7672a5add532f4262b23a75 ast bcmath exif gd gettext gmp igbinary/igbinary@2b1f5d62e3037b07c2a46499ac32091cdb41fb40 Imagick/imagick@55ed2e9fda264395636a2e27e51f31673f5566ab intl opcache pcntl mongodb sockets sysvmsg sysvsem sysvshm uuid xsl zip opentelemetry zstd symfony/php-ext-deepclone@v0.8.11" + +WORKDIR /app + +# php extensions installer: https://github.com/mlocati/docker-php-extension-installer +ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/ +RUN chmod +x /usr/local/bin/install-php-extensions + +RUN apt-get update && apt-get install -y --no-install-recommends \ + git \ + acl \ + file \ + gettext \ + procps \ + supervisor \ + unzip \ + zip \ + imagemagick \ + gifsicle \ + jpegoptim \ + optipng \ + pngquant \ + libnss3-tools \ + mailcap \ + libcap2-bin \ + # Runtime libraries of the webp tools unpacked below + libgif7 libjpeg62-turbo libpng16-16t64 libsharpyuv0 libtiff6 libwebp7 libwebpdemux2 libwebpmux3 \ + # The webp package depends on OpenGL (~200 MB of Mesa and LLVM) only for its vwebp viewer: + # unpack its command-line tools instead of installing it. + && cd /tmp && apt-get download webp \ + && dpkg-deb --fsys-tarfile webp_*.deb | tar -x -C / \ + ./usr/bin/cwebp ./usr/bin/dwebp ./usr/bin/gif2webp ./usr/bin/img2webp ./usr/bin/webpinfo ./usr/bin/webpmux \ + && rm webp_*.deb \ + && rm -rf /var/lib/apt/lists/* + +# Same layout as the upstream FrankenPHP image +RUN set -eux; \ + mkdir -p /app/public /config/caddy /data/caddy /etc/caddy /etc/frankenphp; \ + sed -i 's/php/frankenphp run/g' /usr/local/bin/docker-php-entrypoint + +EXPOSE 80 +EXPOSE 443 +EXPOSE 443/udp +EXPOSE 2019 + +# Install PHP extensions +RUN set -eux; install-php-extensions $EXTENSIONS + +ARG PHPREDIS_REF=623e8db5a39657ba7218ceea81ab8338d248b036 +COPY --chmod=755 scripts/install-phpredis.sh /tmp/install-phpredis.sh +RUN /tmp/install-phpredis.sh ${PHPREDIS_REF} && rm /tmp/install-phpredis.sh + +# Keep frequently changing binaries and startup code after dependency installation. +COPY --from=builder /usr/local/lib/libwatcher* /usr/local/lib/ +COPY --from=builder /usr/local/bin/frankenphp /usr/local/bin/frankenphp +# The builder stage sets cap_net_bind_service, which COPY keeps: running setcap here would +# rewrite the binary into another layer and store it twice. +RUN ldconfig \ + && frankenphp version +COPY --from=composer/composer:2-bin /composer /usr/bin/composer +COPY --link --chmod=755 ./8.6-www/docker-entrypoint.sh /usr/local/bin/docker-entrypoint + +ENTRYPOINT ["docker-entrypoint"] + +# Copying manifest files to host +COPY ./8.6-www/manifest / + +# Copy Imagemagick policy +RUN mv /etc/ImageMagick-7/IM7-policy.xml /etc/ImageMagick-7/policy.xml diff --git a/8.6-www/docker-entrypoint.sh b/8.6-www/docker-entrypoint.sh new file mode 100644 index 0000000..1e8c9af --- /dev/null +++ b/8.6-www/docker-entrypoint.sh @@ -0,0 +1,8 @@ +#!/bin/sh +set -e + +if [ "${INSTALL_COMPOSER_DEPS:-0}" = "1" ] && [ -z "$(ls -A 'vendor/' 2>/dev/null)" ]; then + composer install --prefer-dist --no-progress --no-interaction +fi + +exec docker-php-entrypoint "$@" diff --git a/8.6-www/manifest/etc/ImageMagick-7/IM7-policy.xml b/8.6-www/manifest/etc/ImageMagick-7/IM7-policy.xml new file mode 100644 index 0000000..94afb84 --- /dev/null +++ b/8.6-www/manifest/etc/ImageMagick-7/IM7-policy.xml @@ -0,0 +1,156 @@ + + + + + + + + + + + + ]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/8.6-www/manifest/etc/frankenphp/Caddyfile b/8.6-www/manifest/etc/frankenphp/Caddyfile new file mode 100644 index 0000000..bdaf309 --- /dev/null +++ b/8.6-www/manifest/etc/frankenphp/Caddyfile @@ -0,0 +1,26 @@ +{ + {$CADDY_GLOBAL_OPTIONS} + + frankenphp { + {$FRANKENPHP_CONFIG} + } +} + +{$CADDY_EXTRA_CONFIG} + +{$SERVER_NAME:localhost} { + log { + output stdout + format console + } + + root * /app/public + encode zstd br gzip + + {$CADDY_SERVER_EXTRA_DIRECTIVES} + + # Disable Topics tracking if not enabled explicitly: https://github.com/jkarlin/topics + header ?Permissions-Policy "browsing-topics=()" + + php_server +} \ No newline at end of file diff --git a/8.6-www/manifest/etc/frankenphp/worker.Caddyfile b/8.6-www/manifest/etc/frankenphp/worker.Caddyfile new file mode 100644 index 0000000..8095c40 --- /dev/null +++ b/8.6-www/manifest/etc/frankenphp/worker.Caddyfile @@ -0,0 +1,4 @@ +worker { + file /app/public/index.php + env APP_RUNTIME Runtime\FrankenPhpSymfony\Runtime +} diff --git a/8.6-www/manifest/etc/supervisor/conf.d/frankenphp.conf b/8.6-www/manifest/etc/supervisor/conf.d/frankenphp.conf new file mode 100644 index 0000000..b4df022 --- /dev/null +++ b/8.6-www/manifest/etc/supervisor/conf.d/frankenphp.conf @@ -0,0 +1,7 @@ +[program:frankenphp] +command=/usr/local/bin/frankenphp run --config /etc/frankenphp/Caddyfile --adapter caddyfile +autostart=true +autorestart=true +priority=10 +stdout_events_enabled=true +stderr_events_enabled=true diff --git a/8.6-www/manifest/etc/supervisord.conf b/8.6-www/manifest/etc/supervisord.conf new file mode 100644 index 0000000..68dc04e --- /dev/null +++ b/8.6-www/manifest/etc/supervisord.conf @@ -0,0 +1,28 @@ +[unix_http_server] +file=/var/run/supervisor.sock ; (the path to the socket file) + +[supervisord] +loglevel=info ; (log level;default info; others: debug,warn,trace) +pidfile=/var/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid) +nodaemon=false ; (start in foreground if true;default false) +minfds=1024 ; (min. avail startup file descriptors;default 1024) +minprocs=200 ; (min. avail process descriptors;default 200) +user=root ; + +; the below section must remain in the config file for RPC +; (supervisorctl/web interface) to work, additional interfaces may be +; added by defining them in separate rpcinterface: sections +[rpcinterface:supervisor] +supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface + +[supervisorctl] +serverurl=unix:///var/run/supervisor.sock ; use a unix:// URL for a unix socket + +; [eventlistener:stdout] +; command = supervisor_stdout +; buffer_size = 100 +; events = PROCESS_LOG +; result_handler = supervisor_stdout:event_handler + +[include] +files = /etc/supervisor/conf.d/*.conf diff --git a/8.6-www/manifest/usr/local/etc/php/app.conf.d/10-apc.ini b/8.6-www/manifest/usr/local/etc/php/app.conf.d/10-apc.ini new file mode 100644 index 0000000..d061fd0 --- /dev/null +++ b/8.6-www/manifest/usr/local/etc/php/app.conf.d/10-apc.ini @@ -0,0 +1,12 @@ +[apcu] +apc.shm_size=128M +apc.enable_cli=1 +apc.rfc1867=1 +; PHP file cache 1 hour +apc.ttl=3600 +; User cache 2 hour +apc.user_ttl=7200 +; Garbage collection 1 hour +apc.gc_ttl=3600 +; check files +apc.stat=1 diff --git a/8.6-www/manifest/usr/local/etc/php/app.conf.d/10-opcache.ini b/8.6-www/manifest/usr/local/etc/php/app.conf.d/10-opcache.ini new file mode 100644 index 0000000..7d0bcdb --- /dev/null +++ b/8.6-www/manifest/usr/local/etc/php/app.conf.d/10-opcache.ini @@ -0,0 +1,7 @@ +[opcache] +opcache.enable=1 +opcache.memory_consumption=256M +; Must be a prime number +opcache.max_accelerated_files=80051 +opcache.interned_strings_buffer=16 +opcache.enable_file_override=1 diff --git a/8.6-www/manifest/usr/local/etc/php/app.conf.d/10-php.ini b/8.6-www/manifest/usr/local/etc/php/app.conf.d/10-php.ini new file mode 100644 index 0000000..3730f98 --- /dev/null +++ b/8.6-www/manifest/usr/local/etc/php/app.conf.d/10-php.ini @@ -0,0 +1,15 @@ +[PHP] +error_reporting = E_ALL +display_errors = Off +log_errors = On +memory_limit = -1 +max_execution_time = 30 +max_input_time = 30 +expose_php = 0 +date.timezone = UTC +session_use_strict_mode = 1 +session.auto_start = Off +short_open_tag = Off +zend.detect_unicode = 0 +; CVE-2026-109619: keep off after patching too (advisory GHSA-6wmf-4rv5-p3rp); unused, rarely tested +session.upload_progress.enabled = 0 diff --git a/8.6-www/manifest/usr/local/etc/php/app.conf.d/10-realpath.ini b/8.6-www/manifest/usr/local/etc/php/app.conf.d/10-realpath.ini new file mode 100644 index 0000000..134c0cf --- /dev/null +++ b/8.6-www/manifest/usr/local/etc/php/app.conf.d/10-realpath.ini @@ -0,0 +1,5 @@ +; maximum memory allocated to store the results +realpath_cache_size=8192K + +; save the results for 10 minutes (600 seconds) +realpath_cache_ttl=600 diff --git a/8.6/Dockerfile b/8.6/Dockerfile new file mode 100644 index 0000000..6ffbdfc --- /dev/null +++ b/8.6/Dockerfile @@ -0,0 +1,94 @@ +ARG PHP_VERSION=8.6.0RC7 +ARG CADDY_VERSION=2 + +# ----------------------------------------------------- +# Caddy Install +# ----------------------------------------------------- +FROM caddy:$CADDY_VERSION-builder AS builder +ARG TARGETPLATFORM +ARG BUILDPLATFORM +ARG TARGETOS +ARG TARGETARCH + +RUN CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH xcaddy build \ + --with github.com/ueffel/caddy-brotli \ + --with github.com/ggicci/caddy-jwt@28e0de3db362a787564352ec22e97aa743a371f3 #1.2.0 + +# ----------------------------------------------------- +# App Itself +# ----------------------------------------------------- +FROM php:$PHP_VERSION-fpm-trixie + +ARG PORT=9001 +ARG PUBLIC_DIR=public + +ENV PORT=$PORT +ENV PUBLIC_DIR=$PUBLIC_DIR +ENV COMPOSER_ALLOW_SUPERUSER=1 COMPOSER_NO_INTERACTION=1 COMPOSER_CACHE_DIR="/tmp" +ENV PHP_INI_SCAN_DIR=":$PHP_INI_DIR/app.conf.d" + +# PHP 8.6 removed internal C APIs (XtOffsetOf, zval_dtor, INI_STR/INT/FLT, ...). Until PECL releases +# support 8.6: apcu (5.1.29 release commit, not on PECL), igbinary and imagick are built from pinned +# upstream commits, amqp from the sctr/php-amqp fork (php-8.6-support branch, pending upstream), +# redis by scripts/install-phpredis.sh, and protobuf and grpc are left out because no upstream code +# compiles on 8.6 yet. +ENV EXTENSIONS="sctr/php-amqp@7a4318b41915d8957ab207de43783d94db25aa25 krakjoe/apcu@66300e28647c16fef7672a5add532f4262b23a75 ast bcmath exif ffi gd gettext gmp igbinary/igbinary@2b1f5d62e3037b07c2a46499ac32091cdb41fb40 Imagick/imagick@55ed2e9fda264395636a2e27e51f31673f5566ab intl maxminddb mongodb opcache pcntl pdo_mysql pdo_pgsql sockets sysvmsg sysvsem sysvshm uuid xsl zip opentelemetry zstd symfony/php-ext-deepclone@v0.8.11" + +WORKDIR /app + +# php extensions installer: https://github.com/mlocati/docker-php-extension-installer +ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/ +RUN chmod +x /usr/local/bin/install-php-extensions + +# Install required packages +RUN apt-get update && apt-get install -y --no-install-recommends \ + git \ + acl \ + ca-certificates \ + curl \ + file \ + gettext \ + procps \ + supervisor \ + unzip \ + zip \ + imagemagick \ + gifsicle \ + jpegoptim \ + optipng \ + pngquant \ + # Runtime libraries of the webp tools unpacked below + libgif7 libjpeg62-turbo libpng16-16t64 libsharpyuv0 libtiff6 libwebp7 libwebpdemux2 libwebpmux3 \ + # The webp package depends on OpenGL (~200 MB of Mesa and LLVM) only for its vwebp viewer: + # unpack its command-line tools instead of installing it. + && cd /tmp && apt-get download webp \ + && dpkg-deb --fsys-tarfile webp_*.deb | tar -x -C / \ + ./usr/bin/cwebp ./usr/bin/dwebp ./usr/bin/gif2webp ./usr/bin/img2webp ./usr/bin/webpinfo ./usr/bin/webpmux \ + && rm webp_*.deb \ + && rm -rf /var/lib/apt/lists/* + +# Install latest libvips +# @see https://github.com/dooman87/imagemagick-docker/blob/main/Dockerfile.bookworm +ARG VIPS_VERSION=8.18.7 +ENV LD_LIBRARY_PATH="/usr/local/lib" +ENV PKG_CONFIG_PATH="/usr/local/lib/pkgconfig" + +COPY --chmod=755 scripts/install-libvips.sh /tmp/install-libvips.sh +RUN /tmp/install-libvips.sh ${VIPS_VERSION} && rm /tmp/install-libvips.sh + +# Install PHP extensions +RUN set -eux; install-php-extensions $EXTENSIONS + +ARG PHPREDIS_REF=623e8db5a39657ba7218ceea81ab8338d248b036 +COPY --chmod=755 scripts/install-phpredis.sh /tmp/install-phpredis.sh +RUN /tmp/install-phpredis.sh ${PHPREDIS_REF} && rm /tmp/install-phpredis.sh + +# Keep frequently changing binaries after dependency installation. +COPY --from=builder /usr/bin/caddy /usr/local/bin/caddy +COPY --from=composer/composer:2-bin /composer /usr/bin/composer + +# Copying manifest files to host +COPY ./8.6/manifest / + +# Copy Imagemagick policy +RUN mv /etc/ImageMagick-7/IM7-policy.xml /etc/ImageMagick-7/policy.xml diff --git a/8.6/manifest/etc/ImageMagick-7/IM7-policy.xml b/8.6/manifest/etc/ImageMagick-7/IM7-policy.xml new file mode 100644 index 0000000..94afb84 --- /dev/null +++ b/8.6/manifest/etc/ImageMagick-7/IM7-policy.xml @@ -0,0 +1,156 @@ + + + + + + + + + + + + ]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/8.6/manifest/etc/caddy/Caddyfile b/8.6/manifest/etc/caddy/Caddyfile new file mode 100644 index 0000000..183bf4e --- /dev/null +++ b/8.6/manifest/etc/caddy/Caddyfile @@ -0,0 +1,45 @@ +:80, :{$PORT} { + root * /app/{$PUBLIC_DIR} + + reverse_proxy /php-fpm-status 127.0.0.1:9000 { + transport fastcgi { + split .php + } + } + + encode zstd br gzip + + redir /index.php* / + + php_fastcgi 127.0.0.1:9000 { + trusted_proxies private_ranges + } + + file_server + + header / { + # Enable cross-site filter (XSS) and tell browser to block detected attacks + X-XSS-Protection "1; mode=block" + # Prevent some browsers from MIME-sniffing a response away from the declared Content-Type + X-Content-Type-Options "nosniff" + # Disallow the site to be rendered within a frame (clickjacking protection) + X-Frame-Options "DENY" + } + + log { + output stderr + level warn + format json { + message_key log + level_key level + time_key dt + name_key logger + caller_key function + stacktrace_key stack + time_format "2006-01-02 15:04:05 MST" # RFC3339-like format + time_local # Use local timezone + duration_format "ms" + level_format "upper" + } + } +} diff --git a/8.6/manifest/etc/supervisor/conf.d/caddy.conf b/8.6/manifest/etc/supervisor/conf.d/caddy.conf new file mode 100644 index 0000000..5fe188d --- /dev/null +++ b/8.6/manifest/etc/supervisor/conf.d/caddy.conf @@ -0,0 +1,10 @@ +[program:caddy] +command=/usr/local/bin/caddy run --config /etc/caddy/Caddyfile --adapter caddyfile +autostart=true +autorestart=true +priority=10 +redirect_stderr=true +stdout_logfile=/dev/stdout +stderr_logfile=/dev/stderr +stdout_logfile_maxbytes=0 +stderr_logfile_maxbytes=0 diff --git a/8.6/manifest/etc/supervisor/conf.d/php-fpm.conf b/8.6/manifest/etc/supervisor/conf.d/php-fpm.conf new file mode 100644 index 0000000..07542e1 --- /dev/null +++ b/8.6/manifest/etc/supervisor/conf.d/php-fpm.conf @@ -0,0 +1,13 @@ +[program:php-fpm] +command=/usr/local/sbin/php-fpm -c /usr/local/etc +process_name=%(program_name)s_%(process_num)02d +priority=5 +numprocs=1 +autostart=true +autorestart=false +startsecs=0 +redirect_stderr=true +stdout_logfile=/dev/stdout +stderr_logfile=/dev/stderr +stdout_logfile_maxbytes=0 +stderr_logfile_maxbytes=0 diff --git a/8.6/manifest/etc/supervisord.conf b/8.6/manifest/etc/supervisord.conf new file mode 100644 index 0000000..68dc04e --- /dev/null +++ b/8.6/manifest/etc/supervisord.conf @@ -0,0 +1,28 @@ +[unix_http_server] +file=/var/run/supervisor.sock ; (the path to the socket file) + +[supervisord] +loglevel=info ; (log level;default info; others: debug,warn,trace) +pidfile=/var/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid) +nodaemon=false ; (start in foreground if true;default false) +minfds=1024 ; (min. avail startup file descriptors;default 1024) +minprocs=200 ; (min. avail process descriptors;default 200) +user=root ; + +; the below section must remain in the config file for RPC +; (supervisorctl/web interface) to work, additional interfaces may be +; added by defining them in separate rpcinterface: sections +[rpcinterface:supervisor] +supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface + +[supervisorctl] +serverurl=unix:///var/run/supervisor.sock ; use a unix:// URL for a unix socket + +; [eventlistener:stdout] +; command = supervisor_stdout +; buffer_size = 100 +; events = PROCESS_LOG +; result_handler = supervisor_stdout:event_handler + +[include] +files = /etc/supervisor/conf.d/*.conf diff --git a/8.6/manifest/usr/local/etc/php-fpm.d/zz-docker.conf b/8.6/manifest/usr/local/etc/php-fpm.d/zz-docker.conf new file mode 100644 index 0000000..06a014f --- /dev/null +++ b/8.6/manifest/usr/local/etc/php-fpm.d/zz-docker.conf @@ -0,0 +1,22 @@ +[global] +error_log = /proc/self/fd/2 +log_limit = 524288 +log_buffering = no + +[www] +; access.log = /proc/self/fd/2 +access.log = /dev/null + +clear_env = no + +catch_workers_output = yes +decorate_workers_output = no + +pm = dynamic +pm.start_servers = 2 +pm.min_spare_servers = 2 +pm.max_spare_servers = 5 +chdir = / + +listen = 9000 +pm.status_path = /php-fpm-status diff --git a/8.6/manifest/usr/local/etc/php/app.conf.d/10-apc.ini b/8.6/manifest/usr/local/etc/php/app.conf.d/10-apc.ini new file mode 100644 index 0000000..d061fd0 --- /dev/null +++ b/8.6/manifest/usr/local/etc/php/app.conf.d/10-apc.ini @@ -0,0 +1,12 @@ +[apcu] +apc.shm_size=128M +apc.enable_cli=1 +apc.rfc1867=1 +; PHP file cache 1 hour +apc.ttl=3600 +; User cache 2 hour +apc.user_ttl=7200 +; Garbage collection 1 hour +apc.gc_ttl=3600 +; check files +apc.stat=1 diff --git a/8.6/manifest/usr/local/etc/php/app.conf.d/10-ffi.ini b/8.6/manifest/usr/local/etc/php/app.conf.d/10-ffi.ini new file mode 100644 index 0000000..f5cbee2 --- /dev/null +++ b/8.6/manifest/usr/local/etc/php/app.conf.d/10-ffi.ini @@ -0,0 +1,2 @@ +zend.max_allowed_stack_size=-1 +ffi.enable=true \ No newline at end of file diff --git a/8.6/manifest/usr/local/etc/php/app.conf.d/10-opcache.ini b/8.6/manifest/usr/local/etc/php/app.conf.d/10-opcache.ini new file mode 100644 index 0000000..7d0bcdb --- /dev/null +++ b/8.6/manifest/usr/local/etc/php/app.conf.d/10-opcache.ini @@ -0,0 +1,7 @@ +[opcache] +opcache.enable=1 +opcache.memory_consumption=256M +; Must be a prime number +opcache.max_accelerated_files=80051 +opcache.interned_strings_buffer=16 +opcache.enable_file_override=1 diff --git a/8.6/manifest/usr/local/etc/php/app.conf.d/10-php.ini b/8.6/manifest/usr/local/etc/php/app.conf.d/10-php.ini new file mode 100644 index 0000000..ec4ccf6 --- /dev/null +++ b/8.6/manifest/usr/local/etc/php/app.conf.d/10-php.ini @@ -0,0 +1,16 @@ +[PHP] +error_reporting = E_ALL +display_errors = Off +log_errors = On +error_log = /proc/self/fd/2 +memory_limit = -1 +max_execution_time = 30 +max_input_time = 30 +expose_php = Off +date.timezone = UTC +session_use_strict_mode = 1 +session.auto_start = Off +short_open_tag = Off +zend_detect_unicode = Off +; CVE-2026-109619: keep off after patching too (advisory GHSA-6wmf-4rv5-p3rp); unused, rarely tested +session.upload_progress.enabled = 0 diff --git a/8.6/manifest/usr/local/etc/php/app.conf.d/10-realpath.ini b/8.6/manifest/usr/local/etc/php/app.conf.d/10-realpath.ini new file mode 100644 index 0000000..c70bb14 --- /dev/null +++ b/8.6/manifest/usr/local/etc/php/app.conf.d/10-realpath.ini @@ -0,0 +1,5 @@ +; maximum memory allocated to store the results +realpath_cache_size=8192K + +; save the results for 10 minutes (600 seconds) +realpath_cache_ttl=600 \ No newline at end of file diff --git a/CLAUDE.md b/CLAUDE.md index 8513997..3a9fab0 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -26,14 +26,16 @@ docker build --cache-from ghcr.io/sctr/docker-symfony:8.4-amd64 -f 8.4/Dockerfil Two types of images: -1. **PHP-FPM + Caddy** (directories: `8.4/`, `8.5/`) +1. **PHP-FPM + Caddy** (directories: `8.4/`, `8.5/`, `8.6/`) - Multi-stage build: first stage builds Caddy with custom modules, second stage sets up PHP-FPM - Process management via Supervisor (runs both PHP-FPM and Caddy) - Caddy modules: `caddy-ratelimit`, `caddy-storage-redis`, `caddy-jwt` -2. **FrankenPHP** (directories: `8.4-frankenphp/`, `8.5-frankenphp/`) +2. **FrankenPHP** (directories: `8.4-frankenphp/`, `8.5-frankenphp/`, `8.5-www/`, `8.6-frankenphp/`, `8.6-www/`) - Single binary combining PHP and HTTP server - - Uses `dunglas/frankenphp` base image + - Up to 8.5: uses the `dunglas/frankenphp` base image (`*-www` rebuilds the binary with extra Caddy modules) + - 8.6: no `dunglas/frankenphp` PHP 8.6 images exist, so FrankenPHP is compiled from source on + `php:8.6.*-cli-trixie` (all PHP 8.6 official images are ZTS; the `-zts` tag was dropped) - Custom `docker-entrypoint.sh` for initialization ### Directory Structure Pattern @@ -57,15 +59,20 @@ PHP_INI_SCAN_DIR=":$PHP_INI_DIR/app.conf.d" # PHP config scan directory ### PHP Extensions (common across versions) -`amqp apcu ast bcmath exif ffi gd gettext gmp igbinary imagick intl maxminddb mongodb opcache pcntl pdo_mysql pdo_pgsql redis sockets sysvmsg sysvsem sysvshm uuid xsl zip grpc protobuf` +`amqp apcu ast bcmath exif ffi gd gettext gmp igbinary imagick intl maxminddb mongodb opcache pcntl pdo_mysql pdo_pgsql redis sockets sysvmsg sysvsem sysvshm uuid xsl zip protobuf` -Note: `grpc` is excluded from PHP 8.5 FrankenPHP due to compatibility issues. +Note: `grpc` is no longer included in the 8.5 and 8.6 images. + +PHP 8.6 images: `protobuf` is excluded (no upstream code compiles on 8.6 yet); `apcu`, +`igbinary` and `imagick` are built from pinned upstream commits, `amqp` from the `sctr/php-amqp` fork +(`php-8.6-support`, same fix as upstream PR php-amqp/php-amqp#638) and `redis` via `scripts/install-phpredis.sh`. +See the README's "PHP 8.6 images" section. ## CI/CD GitHub Actions workflow (`.github/workflows/build-and-push.yml`) builds multi-arch images: -- **Active versions:** 8.4, 8.4-frankenphp, 8.5, 8.5-frankenphp +- **Active versions:** 8.5, 8.5-frankenphp, 8.5-www, 8.6, 8.6-frankenphp, 8.6-www - **Architectures:** AMD64 + ARM64 - **Output tags:** `ghcr.io/sctr/docker-symfony:{version}[-{arch}]` diff --git a/README.md b/README.md index ee34bd1..bd50a60 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,9 @@ docker pull ghcr.io/sctr/docker-symfony:{tag} | Tag | Base | Description | |-----|------|-------------| +| `8.6` | Debian + PHP-FPM + Caddy | PHP 8.6 (RC) with Caddy reverse proxy, without protobuf (see below) | +| `8.6-frankenphp` | FrankenPHP (built from source) | PHP 8.6 (RC) with FrankenPHP (single binary) (see below) | +| `8.6-www` | FrankenPHP (built from source) + Custom Caddy | PHP 8.6 (RC) FrankenPHP with Caddy modules (ratelimit, redis, jwt), without protobuf (see below) | | `8.5` | Debian + PHP-FPM + Caddy | PHP 8.5 with Caddy reverse proxy | | `8.5-frankenphp` | FrankenPHP | PHP 8.5 with FrankenPHP (single binary) | | `8.5-www` | FrankenPHP + Custom Caddy | PHP 8.5 FrankenPHP with Caddy modules (ratelimit, redis, jwt) | @@ -36,7 +39,7 @@ Architecture-specific tags are also available: `8.4-amd64`, `8.4-arm64`, etc. - **Web Servers:** Caddy with custom modules (rate limiting, Redis storage, JWT auth) or FrankenPHP - **Process Management:** Supervisor for multi-process orchestration - **Image Processing:** ImageMagick 7, libvips 8.18, jpegoptim, optipng, pngquant, gifsicle, webp -- **PHP Extensions:** amqp, apcu, bcmath, gd, grpc, imagick, intl, mongodb, opcache, pdo_mysql, pdo_pgsql, redis, uuid, and more +- **PHP Extensions:** amqp, apcu, bcmath, gd, imagick, intl, mongodb, opcache, pdo_mysql, pdo_pgsql, redis, uuid, and more ## Usage @@ -81,6 +84,49 @@ sh scripts/test-image.sh docker-symfony:8.5-www 8.5-www sh scripts/test-image.sh docker-symfony:8.5-frankenphp 8.5-frankenphp ``` +### PHP 8.6 images + +The 8.6 images track the PHP 8.6 release candidates (currently `8.6.0RC7`) until 8.6.0 is +released; bump `PHP_VERSION` in the three 8.6 Dockerfiles to follow new releases. + +They mirror the 8.5 images (same ini files, entrypoints and Caddy modules), except: + +- **Extensions:** PHP 8.6 removed internal C APIs (`XtOffsetOf()`, `zval_dtor()`, `INI_STR/INT/FLT`, + `zval_is_true()`, the `php_verror()` `param` argument), and several PECL extensions have no + 8.6-compatible release yet. Until they do: + - `apcu` (5.1.29 release commit, not yet on PECL), `igbinary` and `imagick` are built from pinned + upstream commits listed in `EXTENSIONS`; + - `redis` is built from a pinned phpredis commit by `scripts/install-phpredis.sh` (`PHPREDIS_REF`), + because its GitHub source lacks the `liblzf` submodule that `install-php-extensions` needs; + - `amqp` is built from the [`sctr/php-amqp`](https://github.com/sctr/php-amqp) fork + (`php-8.6-support` branch), which adds PHP 8.6 support with the same fix as the open upstream + PR [php-amqp/php-amqp#638](https://github.com/php-amqp/php-amqp/pull/638); + - **`protobuf` is not included**: no upstream code compiles on PHP 8.6 yet. (`grpc` is not + included either; it was also removed from the 8.5 images.) + + Switch back to the PECL releases, and restore `protobuf`, once + releases support 8.6. + +- Since PHP 8.6 the official `php` images are all built as ZTS with the embed SAPI, and the + separate `-zts` tag no longer exists, so `8.6-frankenphp` and `8.6-www` are based on + `php:8.6.*-cli-trixie`. +- FrankenPHP does not publish PHP 8.6 images yet, so both FrankenPHP variants compile + FrankenPHP (`FRANKENPHP_VERSION`) and e-dant/watcher (`WATCHER_VERSION`) in a builder stage, + following the upstream FrankenPHP Dockerfile. `8.6-frankenphp` includes the same Caddy modules + as the upstream binary (Mercure, Vulcain, brotli). `8.6-www` adds the jwt, ratelimit and + redis storage modules through xcaddy, as `8.5-www` does. The builder stage sets the + `cap_net_bind_service` capability, which `COPY` keeps, so the binary is stored only once. +- The webp command-line tools (`cwebp`, `dwebp`, `gif2webp`, `img2webp`, `webpinfo`, `webpmux`) are + unpacked from Debian's `webp` package without installing it: the package depends on OpenGL + only for its `vwebp` viewer, which pulls in about 200 MB of Mesa and LLVM libraries. `vwebp` is + not included. + +```bash +sh scripts/test-image.sh docker-symfony:8.6 8.6 +sh scripts/test-image.sh docker-symfony:8.6-www 8.6-www +sh scripts/test-image.sh docker-symfony:8.6-frankenphp 8.6-frankenphp +``` + ## Useful Links - https://github.com/mvorisek/image-php/tree/master diff --git a/scripts/install-phpredis.sh b/scripts/install-phpredis.sh new file mode 100644 index 0000000..70f62ae --- /dev/null +++ b/scripts/install-phpredis.sh @@ -0,0 +1,51 @@ +#!/bin/bash +# Build phpredis from a pinned upstream commit. +# +# No phpredis release supports PHP 8.6 yet, and install-php-extensions cannot install the +# GitHub source tarball because it lacks the liblzf git submodule. This uses the same +# configure options install-php-extensions uses for redis. Run it after igbinary is installed. +# +# Usage: install-phpredis.sh +set -euxo pipefail + +PHPREDIS_REF="$1" + +mapfile -t savedAptMark < <(apt-mark showmanual) + +apt-get -y update +apt-get install -y --no-install-recommends liblz4-dev libzstd-dev + +git clone --filter=blob:none https://github.com/phpredis/phpredis.git /usr/src/phpredis +cd /usr/src/phpredis +git checkout "$PHPREDIS_REF" +git submodule update --init --depth 1 + +phpize +./configure \ + --enable-redis-igbinary \ + --enable-redis-lzf \ + --enable-redis-zstd \ + --enable-redis-msgpack=no \ + --enable-redis-lz4 \ + --with-liblz4 +make -j"$(nproc)" +make install +strip --strip-unneeded "$(php-config --extension-dir)/redis.so" +docker-php-ext-enable redis + +# Remove build dependencies, keeping the runtime libraries the extension links against. +cd / +apt-mark auto '.*' > /dev/null +apt-mark manual "${savedAptMark[@]}" > /dev/null +find "$(php-config --extension-dir)" -name '*.so' -exec ldd '{}' ';' 2>/dev/null \ + | awk '/=> \/(usr\/)?lib\// { print $(NF-1) }' \ + | xargs -r readlink -f \ + | sort -u \ + | xargs -r dpkg-query --search \ + | cut -d: -f1 \ + | sort -u \ + | xargs -r apt-mark manual +apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false +rm -rf /var/lib/apt/lists/* /usr/src/phpredis + +php --ri redis diff --git a/scripts/test-image.sh b/scripts/test-image.sh index e8f4a54..ac36928 100644 --- a/scripts/test-image.sh +++ b/scripts/test-image.sh @@ -1,14 +1,15 @@ #!/bin/sh -# Usage: sh scripts/test-image.sh IMAGE 8.5|8.5-www|8.5-frankenphp +# Usage: sh scripts/test-image.sh IMAGE 8.5|8.5-www|8.5-frankenphp|8.6|8.6-www|8.6-frankenphp set -eu docker run --rm --network none --read-only "$1" php -v docker run --rm --network none --read-only --tmpfs /tmp:exec --entrypoint sh "$1" -eu -c ' php -r '\'' - foreach (explode(" ", getenv("EXTENSIONS")) as $extension) { - // GitHub sources: "vendor/php-ext-name@ref" loads as "name". - $extension = preg_replace("~^.*/(php-ext-)?|@.*$~", "", $extension); + // redis is built separately on PHP 8.6 (scripts/install-phpredis.sh). + foreach ([...explode(" ", getenv("EXTENSIONS")), "redis"] as $extension) { + // GitHub sources: "vendor/php-ext-name@ref" or "vendor/php-name@ref" loads as "name". + $extension = preg_replace("~^.*/(php-ext-|php-)?|@.*$~", "", $extension); if (!extension_loaded($extension === "opcache" ? "Zend OPcache" : $extension)) { throw new RuntimeException("Missing extension: " . $extension); } @@ -22,7 +23,18 @@ docker run --rm --network none --read-only --tmpfs /tmp:exec --entrypoint sh "$1 $image->writeImage("/tmp/imagick.png"); '\'' composer --version - if [ "$1" != "8.5-www" ]; then + # Image optimization tools (webp tools are unpacked without the webp package on 8.6). + for tool in jpegoptim optipng pngquant gifsicle cwebp dwebp gif2webp img2webp webpinfo webpmux; do + command -v "$tool" > /dev/null + done + cwebp -quiet /tmp/imagick.png -o /tmp/cwebp.webp + dwebp -quiet /tmp/cwebp.webp -o /tmp/dwebp.png + case "$1" in + *-www) variant=www ;; + *-frankenphp) variant=frankenphp ;; + *) variant=fpm ;; + esac + if [ "$variant" != www ]; then test "$(dpkg-query -W -f '\''${db:Status-Status}'\'' libvips-dev 2>/dev/null || true)" != installed vips --version vips black /tmp/test.v 8 8 @@ -31,18 +43,19 @@ docker run --rm --network none --read-only --tmpfs /tmp:exec --entrypoint sh "$1 vipsheader "/tmp/test.$format" done fi - if [ "$1" = "8.5" ]; then + if [ "$variant" = fpm ]; then php-fpm -t caddy list-modules | grep -q http.encoders.br else frankenphp list-modules > /tmp/modules modules="frankenphp http.encoders.br" - if [ "$1" = "8.5-www" ]; then + if [ "$variant" = www ]; then modules="$modules http.authentication.providers.jwt http.handlers.rate_limit caddy.storage.redis" fi for module in $modules; do grep -qx "$module" /tmp/modules done + getcap /usr/local/bin/frankenphp | grep -q cap_net_bind_service # Exercise startup with no network and stub only the external commands. mkdir -p /tmp/bin /tmp/app