Add translations stage to generate Symfony translations for webpack

Webpack build requires var/translations files generated by Symfony's cache warmup. Added intermediate 'translations' stage that:
- Copies composer dependencies and app files
- Generates autoloader
- Runs cache warmup to create translation files
- Assets stage now copies these translations before building

This fixes the webpack build errors about missing translation exports.

Co-authored-by: jbtronics <5410681+jbtronics@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2025-12-07 18:43:51 +00:00 committed by Jan Böhmer
parent 564b8f2891
commit a604ec8476
2 changed files with 50 additions and 0 deletions

View file

@ -11,6 +11,28 @@ RUN composer install --no-dev --no-scripts --no-autoloader --prefer-dist --ignor
# ---
# Stage to generate Symfony translations needed for webpack
FROM composer:latest AS translations
WORKDIR /build
# Copy composer dependencies and application files
COPY --from=composer-deps /build/vendor ./vendor
COPY composer.json composer.lock symfony.lock ./
COPY bin ./bin
COPY config ./config
COPY public ./public
COPY src ./src
COPY templates ./templates
COPY translations ./translations
# Generate autoloader and dump translations
RUN composer dump-autoload --no-dev --classmap-authoritative && \
php bin/console cache:clear --no-warmup && \
php bin/console cache:warmup
# ---
FROM node:22-bookworm-slim AS assets
WORKDIR /build
@ -18,6 +40,9 @@ WORKDIR /build
# Copy vendor directory from composer stage (needed for Symfony UX packages)
COPY --from=composer-deps /build/vendor ./vendor
# Copy generated translations from Symfony
COPY --from=translations /build/var/translations ./var/translations
# Copy package files
COPY package.json yarn.lock webpack.config.js ./
COPY assets ./assets