Files
git-contribution-graph/Dockerfile
T
haylan 50256c97ef build(docker): warm prod cache at build time and add prod compose file
- Run cache:warmup in the build stage so containers start with a
  pre-built Symfony kernel and DI container
- Scope the cache volume to var/cache/prod/pools where Symfony writes
  pool data, preserving the warmed kernel across container restarts
- Add docker-compose.prod.yml for deploying the registry image without
  the dev override being picked up automatically
- Expand .dockerignore to exclude vendor/, tests/, docs, compose files,
  and env files from the build context

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-30 15:15:51 +02:00

61 lines
2.1 KiB
Docker

FROM dunglas/frankenphp:1-php8.4-alpine AS base
RUN apk add --no-cache \
curl \
icu-libs \
libzip
WORKDIR /app
# ── deps stage (prod vendor) ───────────────────────────────────────────────────
FROM base AS deps
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
COPY composer.json composer.lock* ./
RUN composer install \
--no-dev \
--no-scripts \
--no-interaction \
--optimize-autoloader \
--prefer-dist
# ── build stage (generate optimised classmap with source present) ──────────────
FROM deps AS build
COPY . .
RUN composer dump-autoload --optimize --no-dev --no-interaction && \
mkdir -p var/cache var/log && \
APP_ENV=prod APP_SECRET=placeholder php bin/console cache:warmup --no-debug
# ── dev stage (all deps + Xdebug, source is mounted at runtime) ───────────────
FROM base AS dev
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
RUN apk add --no-cache ${PHPIZE_DEPS} linux-headers \
&& pecl install xdebug \
&& docker-php-ext-enable xdebug \
&& apk del ${PHPIZE_DEPS}
COPY docker/php/xdebug.ini /usr/local/etc/php/conf.d/docker-xdebug.ini
COPY docker/frankenphp/Caddyfile.dev /etc/caddy/Caddyfile
COPY composer.json composer.lock* ./
RUN composer install --no-scripts --no-interaction --prefer-dist
EXPOSE 8080
ENV APP_ENV=dev APP_DEBUG=1
CMD ["frankenphp", "run", "--config", "/etc/caddy/Caddyfile"]
# ── final (prod) stage — no composer binary ────────────────────────────────────
FROM base AS final
RUN addgroup -S app && adduser -S -G app app
COPY --from=build /app/vendor /app/vendor
COPY --from=build /app/var/cache/prod /app/var/cache/prod
COPY . .
COPY docker/frankenphp/Caddyfile /etc/caddy/Caddyfile
RUN mkdir -p var/cache/prod/pools var/log && chown -R app:app /app
USER app
EXPOSE 8080
ENV APP_ENV=prod APP_DEBUG=0
CMD ["frankenphp", "run", "--config", "/etc/caddy/Caddyfile"]