From 92e1219dc8d4de64ab6d803858dc2cb34f734807 Mon Sep 17 00:00:00 2001 From: Thomas Date: Tue, 7 Jan 2025 05:27:05 -0600 Subject: [PATCH] 8.4 builds --- .github/workflows/build-and-push.yml | 3 + 8.4-frankenphp/Dockerfile | 68 +++++++++++++++++++ 8.4-frankenphp/docker-entrypoint.sh | 8 +++ 8.4-frankenphp/manifest/etc/caddy/Caddyfile | 26 +++++++ .../manifest/etc/caddy/worker.Caddyfile | 4 ++ .../etc/supervisor/conf.d/frankenphp.conf | 7 ++ 8.4-frankenphp/manifest/etc/supervisord.conf | 28 ++++++++ .../usr/local/etc/php/app.conf.d/10-apc.ini | 0 .../usr/local/etc/php/app.conf.d/10-ffi.ini | 2 + .../local/etc/php/app.conf.d/10-opcache.ini | 0 .../usr/local/etc/php/app.conf.d/10-php.ini | 14 ++++ .../local/etc/php/app.conf.d/10-realpath.ini | 5 ++ 8.4/Dockerfile | 41 +++++++---- .../realpath.ini => app.conf.d/10-.ini} | 0 .../usr/local/etc/php/app.conf.d/10-apc.ini | 12 ++++ .../local/etc/php/app.conf.d/10-opcache.ini | 5 ++ .../{conf.d/php.ini => app.conf.d/10-php.ini} | 0 17 files changed, 211 insertions(+), 12 deletions(-) create mode 100644 8.4-frankenphp/Dockerfile create mode 100644 8.4-frankenphp/docker-entrypoint.sh create mode 100644 8.4-frankenphp/manifest/etc/caddy/Caddyfile create mode 100644 8.4-frankenphp/manifest/etc/caddy/worker.Caddyfile create mode 100644 8.4-frankenphp/manifest/etc/supervisor/conf.d/frankenphp.conf create mode 100644 8.4-frankenphp/manifest/etc/supervisord.conf rename 8.4/manifest/usr/local/etc/php/conf.d/apc.ini => 8.4-frankenphp/manifest/usr/local/etc/php/app.conf.d/10-apc.ini (100%) create mode 100644 8.4-frankenphp/manifest/usr/local/etc/php/app.conf.d/10-ffi.ini rename 8.4/manifest/usr/local/etc/php/conf.d/opcache.ini => 8.4-frankenphp/manifest/usr/local/etc/php/app.conf.d/10-opcache.ini (100%) create mode 100644 8.4-frankenphp/manifest/usr/local/etc/php/app.conf.d/10-php.ini create mode 100644 8.4-frankenphp/manifest/usr/local/etc/php/app.conf.d/10-realpath.ini rename 8.4/manifest/usr/local/etc/php/{conf.d/realpath.ini => app.conf.d/10-.ini} (100%) create mode 100644 8.4/manifest/usr/local/etc/php/app.conf.d/10-apc.ini create mode 100644 8.4/manifest/usr/local/etc/php/app.conf.d/10-opcache.ini rename 8.4/manifest/usr/local/etc/php/{conf.d/php.ini => app.conf.d/10-php.ini} (100%) diff --git a/.github/workflows/build-and-push.yml b/.github/workflows/build-and-push.yml index e9f798f..7078f16 100644 --- a/.github/workflows/build-and-push.yml +++ b/.github/workflows/build-and-push.yml @@ -15,6 +15,7 @@ jobs: phpversion: - 8.3 - 8.4 + - 8.4-frankenphp runs-on: ubuntu-latest steps: - name: Checkout @@ -43,6 +44,7 @@ jobs: phpversion: - 8.3 - 8.4 + - 8.4-frankenphp runs-on: ubuntu-latest-arm64 steps: - name: Checkout @@ -72,6 +74,7 @@ jobs: phpversion: - 8.3 - 8.4 + - 8.4-frankenphp runs-on: ubuntu-latest steps: - name: Checkout diff --git a/8.4-frankenphp/Dockerfile b/8.4-frankenphp/Dockerfile new file mode 100644 index 0000000..73747d3 --- /dev/null +++ b/8.4-frankenphp/Dockerfile @@ -0,0 +1,68 @@ +# ----------------------------------------------------- +# FrankenPHP +#------------------------------------------------------ +FROM dunglas/frankenphp:1-php8.4 + +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" + +COPY --link --chmod=755 ./8.4-frankenphp/docker-entrypoint.sh /usr/local/bin/docker-entrypoint + +ENTRYPOINT ["docker-entrypoint"] + +WORKDIR /app + +RUN apt-get update && apt-get install -y --no-install-recommends \ + acl \ + file \ + gettext \ + gifsicle \ + git \ + imagemagick \ + jpegoptim \ + libexif-dev \ + libheif-dev \ + libvips42 \ + optipng \ + pngquant \ + procps \ + supervisor \ + unzip \ + webp \ + zip \ + && rm -rf /var/lib/apt/lists/* + +RUN set -eux; \ + install-php-extensions \ + @composer \ + amqp \ + apcu \ + bcmath \ + exif \ + ffi \ + gd \ + gmp \ + igbinary \ + imagick \ + intl \ + maxminddb \ + mongodb \ + opcache \ + pcntl \ + pdo_mysql \ + pdo_pgsql \ + redis \ + sockets \ + sysvmsg \ + sysvsem \ + sysvshm \ + uuid \ + xsl \ + zip \ + ; + +# Copying manifest files to host +COPY ./8.4-frankenphp/manifest / \ No newline at end of file diff --git a/8.4-frankenphp/docker-entrypoint.sh b/8.4-frankenphp/docker-entrypoint.sh new file mode 100644 index 0000000..3f2ea2c --- /dev/null +++ b/8.4-frankenphp/docker-entrypoint.sh @@ -0,0 +1,8 @@ +#!/bin/sh +set -e + +if [ -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.4-frankenphp/manifest/etc/caddy/Caddyfile b/8.4-frankenphp/manifest/etc/caddy/Caddyfile new file mode 100644 index 0000000..bdaf309 --- /dev/null +++ b/8.4-frankenphp/manifest/etc/caddy/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.4-frankenphp/manifest/etc/caddy/worker.Caddyfile b/8.4-frankenphp/manifest/etc/caddy/worker.Caddyfile new file mode 100644 index 0000000..8095c40 --- /dev/null +++ b/8.4-frankenphp/manifest/etc/caddy/worker.Caddyfile @@ -0,0 +1,4 @@ +worker { + file /app/public/index.php + env APP_RUNTIME Runtime\FrankenPhpSymfony\Runtime +} diff --git a/8.4-frankenphp/manifest/etc/supervisor/conf.d/frankenphp.conf b/8.4-frankenphp/manifest/etc/supervisor/conf.d/frankenphp.conf new file mode 100644 index 0000000..32dd395 --- /dev/null +++ b/8.4-frankenphp/manifest/etc/supervisor/conf.d/frankenphp.conf @@ -0,0 +1,7 @@ +[program:frankenphp] +command=/usr/local/bin/frankenphp run --config /etc/caddy/Caddyfile --adapter caddyfile +autostart=true +autorestart=true +priority=10 +stdout_events_enabled=true +stderr_events_enabled=true diff --git a/8.4-frankenphp/manifest/etc/supervisord.conf b/8.4-frankenphp/manifest/etc/supervisord.conf new file mode 100644 index 0000000..68dc04e --- /dev/null +++ b/8.4-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.4/manifest/usr/local/etc/php/conf.d/apc.ini b/8.4-frankenphp/manifest/usr/local/etc/php/app.conf.d/10-apc.ini similarity index 100% rename from 8.4/manifest/usr/local/etc/php/conf.d/apc.ini rename to 8.4-frankenphp/manifest/usr/local/etc/php/app.conf.d/10-apc.ini diff --git a/8.4-frankenphp/manifest/usr/local/etc/php/app.conf.d/10-ffi.ini b/8.4-frankenphp/manifest/usr/local/etc/php/app.conf.d/10-ffi.ini new file mode 100644 index 0000000..f5cbee2 --- /dev/null +++ b/8.4-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.4/manifest/usr/local/etc/php/conf.d/opcache.ini b/8.4-frankenphp/manifest/usr/local/etc/php/app.conf.d/10-opcache.ini similarity index 100% rename from 8.4/manifest/usr/local/etc/php/conf.d/opcache.ini rename to 8.4-frankenphp/manifest/usr/local/etc/php/app.conf.d/10-opcache.ini diff --git a/8.4-frankenphp/manifest/usr/local/etc/php/app.conf.d/10-php.ini b/8.4-frankenphp/manifest/usr/local/etc/php/app.conf.d/10-php.ini new file mode 100644 index 0000000..9ad9eac --- /dev/null +++ b/8.4-frankenphp/manifest/usr/local/etc/php/app.conf.d/10-php.ini @@ -0,0 +1,14 @@ +[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 = 0 +date.timezone = UTC +session_use_strict_mode = 1 +session.auto_start = Off +short_open_tag = Off +zend.detect_unicode = 0 diff --git a/8.4-frankenphp/manifest/usr/local/etc/php/app.conf.d/10-realpath.ini b/8.4-frankenphp/manifest/usr/local/etc/php/app.conf.d/10-realpath.ini new file mode 100644 index 0000000..47f462e --- /dev/null +++ b/8.4-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=4096K + +; save the results for 10 minutes (600 seconds) +realpath_cache_ttl=600 diff --git a/8.4/Dockerfile b/8.4/Dockerfile index a726e6f..469ec10 100644 --- a/8.4/Dockerfile +++ b/8.4/Dockerfile @@ -15,7 +15,7 @@ RUN CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH xcaddy build # ----------------------------------------------------- # App Itself # ----------------------------------------------------- -FROM php:$PHP_VERSION-fpm-alpine +FROM php:$PHP_VERSION-fpm ARG PORT=9001 ARG PUBLIC_DIR=public @@ -23,16 +23,10 @@ ARG PUBLIC_DIR=public ENV PORT=$PORT ENV PUBLIC_DIR=$PUBLIC_DIR -ENV REQUIRED_PACKAGES="git make zip curl libpq supervisor gettext acl fcgi python3 ca-certificates pcre rabbitmq-c icu libavif libwebp libpng freetype libjpeg-turbo libacl libheif libde265 imagemagick imagemagick-dev imagemagick-libs jpegoptim optipng pngquant gifsicle linux-headers file" -ENV EXTENSIONS="redis apcu ast maxminddb amqp zip pdo_mysql pdo_pgsql bcmath opcache gettext intl exif pcntl sysvmsg sysvsem sysvshm xsl uuid igbinary bz2 gmp sockets Imagick/imagick@65e27f2bc0 gd" +ENV EXTENSIONS="redis apcu ast maxminddb amqp zip pdo_mysql pdo_pgsql bcmath opcache gettext intl exif pcntl sysvmsg sysvsem sysvshm xsl uuid igbinary bz2 gmp sockets imagick gd" -ENV DOCKER=true ENV COMPOSER_ALLOW_SUPERUSER=1 COMPOSER_NO_INTERACTION=1 COMPOSER_CACHE_DIR="/tmp" - -WORKDIR /app - -# Copying manifest files to host -COPY ./8.4/manifest / +ENV PHP_INI_SCAN_DIR=":$PHP_INI_DIR/app.conf.d" # Caddy COPY --from=builder /usr/bin/caddy /usr/local/bin/caddy @@ -40,15 +34,38 @@ COPY --from=builder /usr/bin/caddy /usr/local/bin/caddy # Composer install COPY --from=composer/composer:2-bin /composer /usr/bin/composer +WORKDIR /app + +# Copying manifest files to host +COPY ./8.4/manifest / + # 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 apk add --update --no-cache $REQUIRED_PACKAGES && rm -rf /var/cache/apk/* +RUN apt-get update && apt-get install -y --no-install-recommends \ + acl \ + file \ + gettext \ + gifsicle \ + git \ + imagemagick \ + jpegoptim \ + libexif-dev \ + libheif-dev \ + libvips42 \ + optipng \ + pngquant \ + procps \ + supervisor \ + unzip \ + webp \ + zip \ + && rm -rf /var/lib/apt/lists/* # Install PHP extensions -RUN IPE_ICU_EN_ONLY=1 install-php-extensions $EXTENSIONS +RUN set -eux; install-php-extensions $EXTENSIONS # Update ulimit -RUN ulimit -n 16384 +RUN ulimit -n 16384 \ No newline at end of file diff --git a/8.4/manifest/usr/local/etc/php/conf.d/realpath.ini b/8.4/manifest/usr/local/etc/php/app.conf.d/10-.ini similarity index 100% rename from 8.4/manifest/usr/local/etc/php/conf.d/realpath.ini rename to 8.4/manifest/usr/local/etc/php/app.conf.d/10-.ini diff --git a/8.4/manifest/usr/local/etc/php/app.conf.d/10-apc.ini b/8.4/manifest/usr/local/etc/php/app.conf.d/10-apc.ini new file mode 100644 index 0000000..d061fd0 --- /dev/null +++ b/8.4/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.4/manifest/usr/local/etc/php/app.conf.d/10-opcache.ini b/8.4/manifest/usr/local/etc/php/app.conf.d/10-opcache.ini new file mode 100644 index 0000000..149fb43 --- /dev/null +++ b/8.4/manifest/usr/local/etc/php/app.conf.d/10-opcache.ini @@ -0,0 +1,5 @@ +[opcache] +opcache.memory_consumption=256M +opcache.max_accelerated_files=20000 +opcache_enable_file_override=1 +opcache.interned_strings_buffer=16 diff --git a/8.4/manifest/usr/local/etc/php/conf.d/php.ini b/8.4/manifest/usr/local/etc/php/app.conf.d/10-php.ini similarity index 100% rename from 8.4/manifest/usr/local/etc/php/conf.d/php.ini rename to 8.4/manifest/usr/local/etc/php/app.conf.d/10-php.ini