Files
vindn.de/frontend/Dockerfile.prod
T
2026-08-17 01:56:40 +02:00

43 lines
2.0 KiB
Docker

FROM dunglas/frankenphp:latest
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
ADD --chmod=0755 https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
RUN install-php-extensions pdo_pgsql zip
# The imported event data and the site's audience are both German-local;
# default to that instead of UTC so any "now"/"today" computation doesn't
# quietly disagree with the data for the two hours after every UTC midnight.
ENV TZ=Europe/Berlin
RUN echo "date.timezone = Europe/Berlin" > $PHP_INI_DIR/conf.d/timezone.ini
WORKDIR /app
COPY . .
# 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
# HTTP-only on that port, which is what we want — Traefik terminates TLS
# and forwards plain HTTP to this container.
ENV SERVER_NAME=:8000
EXPOSE 8000