Files
git-contribution-graph/Dockerfile
T
haylan ecdb8c1716 fix(docker): commit composer.lock and install intl extension
- Remove composer.lock from .gitignore so it is tracked and included in
  the build context; without it composer install resolves fresh versions
  on every CI build, causing cache/vendor mismatches that produce the
  RewindableGenerator and LazyGhostTrait runtime errors in prod
- Install the intl PHP extension in the base stage to remove the
  Symfony startup deprecation warning; icu-dev and libzip-dev are only
  kept for the compile step, then deleted to keep the layer lean

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

61 lines
2.2 KiB
Docker

FROM dunglas/frankenphp:1-php8.4-alpine AS base
RUN apk add --no-cache icu-dev libzip-dev \
&& docker-php-ext-install -j$(nproc) intl \
&& apk del icu-dev libzip-dev \
&& 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"]