From 34f463071f286df7d3738df1addeb172105b6893 Mon Sep 17 00:00:00 2001 From: Hendrik Behme Date: Mon, 17 Aug 2026 01:56:40 +0200 Subject: [PATCH] fixed frontend build --- frontend/Dockerfile.prod | 22 ++++++++++++++++++++-- frontend/docker-entrypoint.prod.sh | 10 ++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 frontend/docker-entrypoint.prod.sh diff --git a/frontend/Dockerfile.prod b/frontend/Dockerfile.prod index 41eb392..bc974d0 100644 --- a/frontend/Dockerfile.prod +++ b/frontend/Dockerfile.prod @@ -13,8 +13,26 @@ RUN echo "date.timezone = Europe/Berlin" > $PHP_INI_DIR/conf.d/timezone.ini WORKDIR /app COPY . . -RUN composer install --no-interaction --no-dev --optimize-autoloader \ - && php bin/console cache:clear --env=prod --no-debug + +# Symfony's dotenv bootstrap (SymfonyRuntime) unconditionally looks for +# .env/.env.dist on every boot. Real config (DATABASE_URL etc.) is injected +# as actual container env vars at runtime instead (see docker-compose.yaml's +# env_file), which doesn't exist yet at build time — an empty placeholder +# just satisfies dotenv's file-exists check; real env vars always take +# precedence over anything (not) found in it. +RUN touch .env \ + && composer install --no-interaction --no-dev --optimize-autoloader + +# cache:clear needs real config (DATABASE_URL) to compile the container, so +# it can't run here at build time — it runs at container start instead, via +# this entrypoint, once env_file has actually been applied. +COPY docker-entrypoint.prod.sh /usr/local/bin/docker-entrypoint.prod.sh +RUN chmod +x /usr/local/bin/docker-entrypoint.prod.sh +ENTRYPOINT ["docker-entrypoint.prod.sh"] +# Docker resets CMD to empty whenever a Dockerfile sets a new ENTRYPOINT, +# even without touching CMD — restate the base image's own default here or +# the wrapper above execs with no arguments and FrankenPHP never starts. +CMD ["--config", "/etc/frankenphp/Caddyfile", "--adapter", "caddyfile"] # Caddy's default site address in the base image's Caddyfile is # {$SERVER_NAME:localhost}; a bare ":8000" (no hostname) makes it listen diff --git a/frontend/docker-entrypoint.prod.sh b/frontend/docker-entrypoint.prod.sh new file mode 100644 index 0000000..51dd16a --- /dev/null +++ b/frontend/docker-entrypoint.prod.sh @@ -0,0 +1,10 @@ +#!/bin/sh +set -e + +# Real config (DATABASE_URL etc.) only exists as actual container env vars +# at this point — injected via docker-compose.yaml's env_file — not during +# the image build, so cache-warming has to happen here instead of a RUN +# step in Dockerfile.prod. +php bin/console cache:clear --env=prod --no-debug + +exec docker-php-entrypoint "$@"