From 988ddbcb12d8f6a4adec56367cdef7af936c4d41 Mon Sep 17 00:00:00 2001 From: "qwen.ai[bot]" Date: Mon, 11 May 2026 15:07:56 +0000 Subject: [PATCH 1/2] Replace FrankenPHP with FreeUnit runtime - Change base image from dunglas/frankenphp to ghcr.io/freeunitorg/freeunit:latest-php8.5 - Replace Caddyfile configurations with Unit JSON configuration for Yii2 - Add unit-config.json for development and production environments - Update Dockerfile to use Unit control socket directory instead of Caddy directories - Configure Unit routes and applications according to Yii2 framework requirements per https://docs.freeunit.org/howto/yii/ --- docker/Caddyfile | 19 ---------------- docker/Dockerfile | 20 ++++++++--------- docker/dev/Caddyfile | 20 ----------------- docker/dev/unit-config.json | 43 +++++++++++++++++++++++++++++++++++++ docker/unit-config.json | 43 +++++++++++++++++++++++++++++++++++++ 5 files changed, 96 insertions(+), 49 deletions(-) delete mode 100644 docker/Caddyfile delete mode 100644 docker/dev/Caddyfile create mode 100644 docker/dev/unit-config.json create mode 100644 docker/unit-config.json diff --git a/docker/Caddyfile b/docker/Caddyfile deleted file mode 100644 index 72d9a56..0000000 --- a/docker/Caddyfile +++ /dev/null @@ -1,19 +0,0 @@ -# Production mode config -# https://frankenphp.dev/docs/config -# https://caddyserver.com/docs/caddyfile - -{ - skip_install_trust - - frankenphp { - - } -} - -{$SERVER_NAME::80} { - encode zstd br gzip - php_server { - try_files {path} index.php - root /app/public - } -} diff --git a/docker/Dockerfile b/docker/Dockerfile index f8b0368..7e451a6 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,9 +1,10 @@ FROM composer/composer:2-bin AS composer -FROM dunglas/frankenphp:1-php8.5-bookworm AS base +FROM ghcr.io/freeunitorg/freeunit:latest-php8.5 AS base RUN apt update && apt -y install \ - unzip + unzip \ + curl RUN install-php-extensions \ opcache \ @@ -37,17 +38,16 @@ ARG GROUP_NAME=appuser COPY --from=composer /composer /usr/bin/composer -# Based on https://frankenphp.dev/docs/docker/#running-as-a-non-root-user RUN \ - groupadd --gid ${GROUP_ID} ${GROUP_NAME}; \ + groupadd --gid ${GROUP_ID} ${GROUP_NAME}; \ useradd --gid ${GROUP_ID} --uid ${USER_ID} ${GROUP_NAME}; \ - # Add additional capability to bind to port 80 and 443 - setcap CAP_NET_BIND_SERVICE=+eip /usr/local/bin/frankenphp; \ - # Give write access to /data/caddy and /config/caddy - chown -R ${USER_NAME}:${GROUP_NAME} /data/caddy && chown -R ${USER_NAME}:${GROUP_NAME} /config/caddy + # Give write access to /var/run for Unit control socket + mkdir -p /var/run && chown -R ${USER_NAME}:${GROUP_NAME} /var/run; \ + # Give write access to runtime directory + mkdir -p /app/runtime && chown -R ${USER_NAME}:${GROUP_NAME} /app/runtime USER ${USER_NAME} -COPY docker/dev/Caddyfile /etc/frankenphp/Caddyfile +COPY docker/dev/unit-config.json /var/lib/unit/config.json # # Production @@ -62,6 +62,6 @@ RUN --mount=type=cache,target=/tmp/cache \ FROM base AS prod ENV APP_ENV=prod -COPY docker/Caddyfile /etc/frankenphp/Caddyfile +COPY docker/unit-config.json /var/lib/unit/config.json COPY --from=prod-builder --chown=www-data:www-data /app /app USER www-data diff --git a/docker/dev/Caddyfile b/docker/dev/Caddyfile deleted file mode 100644 index 2b99130..0000000 --- a/docker/dev/Caddyfile +++ /dev/null @@ -1,20 +0,0 @@ -# Development mode config -# https://frankenphp.dev/docs/config -# https://caddyserver.com/docs/caddyfile - -{ - auto_https off - skip_install_trust - - frankenphp { - - } -} - -{$SERVER_NAME::80} { - encode zstd br gzip - php_server { - try_files {path} index.php - root /app/public - } -} diff --git a/docker/dev/unit-config.json b/docker/dev/unit-config.json new file mode 100644 index 0000000..2edde8c --- /dev/null +++ b/docker/dev/unit-config.json @@ -0,0 +1,43 @@ +{ + "listeners": { + "*:80": { + "pass": "routes" + } + }, + "routes": [ + { + "match": { + "uri": [ + "!/assets/*", + "*.php", + "*.php/*" + ] + }, + "action": { + "pass": "applications/yii/direct" + } + }, + { + "action": { + "share": "/app/public$uri", + "fallback": { + "pass": "applications/yii/index" + } + } + } + ], + "applications": { + "yii": { + "type": "php", + "targets": { + "direct": { + "root": "/app/public/" + }, + "index": { + "root": "/app/public/", + "script": "index.php" + } + } + } + } +} diff --git a/docker/unit-config.json b/docker/unit-config.json new file mode 100644 index 0000000..2edde8c --- /dev/null +++ b/docker/unit-config.json @@ -0,0 +1,43 @@ +{ + "listeners": { + "*:80": { + "pass": "routes" + } + }, + "routes": [ + { + "match": { + "uri": [ + "!/assets/*", + "*.php", + "*.php/*" + ] + }, + "action": { + "pass": "applications/yii/direct" + } + }, + { + "action": { + "share": "/app/public$uri", + "fallback": { + "pass": "applications/yii/index" + } + } + } + ], + "applications": { + "yii": { + "type": "php", + "targets": { + "direct": { + "root": "/app/public/" + }, + "index": { + "root": "/app/public/", + "script": "index.php" + } + } + } + } +} From d901657b25afc42fc7435ae684ff140d8d151359 Mon Sep 17 00:00:00 2001 From: "qwen.ai[bot]" Date: Mon, 11 May 2026 15:10:51 +0000 Subject: [PATCH 2/2] Replace FrankenPHP with FreeUnit runtime --- docker/compose.yml | 2 -- docker/prod/compose.yml | 13 ++----------- 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/docker/compose.yml b/docker/compose.yml index 8d3a7ec..0e1f5fa 100644 --- a/docker/compose.yml +++ b/docker/compose.yml @@ -4,7 +4,5 @@ services: - "host.docker.internal:host-gateway" volumes: - caddy_data: - caddy_config: postgres_data: valkey_data: diff --git a/docker/prod/compose.yml b/docker/prod/compose.yml index 411608d..6045ee9 100644 --- a/docker/prod/compose.yml +++ b/docker/prod/compose.yml @@ -1,12 +1,10 @@ services: app: image: ${IMAGE}:${IMAGE_TAG} - networks: - - caddy_public + ports: + - "80:80" volumes: - runtime:/app/runtime - - caddy_data:/data - - caddy_config:/config env_file: - path: ./prod/.env - path: ./prod/override.env @@ -27,13 +25,6 @@ services: delay: 5s max_attempts: 3 window: 120s - labels: - caddy: ${PROD_HOST:-app-api.example.com} - caddy.reverse_proxy: "{{upstreams 80}}" volumes: runtime: - -networks: - caddy_public: - external: true