Skip to content

Commit 4a73aa3

Browse files
Copilotjbtronics
andcommitted
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 <[email protected]>
1 parent 09bbbd3 commit 4a73aa3

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

Dockerfile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,38 @@ RUN composer install --no-dev --no-scripts --no-autoloader --prefer-dist --ignor
1414

1515
# ---
1616

17+
# Stage to generate Symfony translations needed for webpack
18+
FROM composer:latest AS translations
19+
20+
WORKDIR /build
21+
22+
# Copy composer dependencies and application files
23+
COPY --from=composer-deps /build/vendor ./vendor
24+
COPY composer.json composer.lock symfony.lock ./
25+
COPY bin ./bin
26+
COPY config ./config
27+
COPY public ./public
28+
COPY src ./src
29+
COPY templates ./templates
30+
COPY translations ./translations
31+
32+
# Generate autoloader and dump translations
33+
RUN composer dump-autoload --no-dev --classmap-authoritative && \
34+
php bin/console cache:clear --no-warmup && \
35+
php bin/console cache:warmup
36+
37+
# ---
38+
1739
FROM node:22-bookworm-slim AS assets
1840

1941
WORKDIR /build
2042

2143
# Copy vendor directory from composer stage (needed for Symfony UX packages)
2244
COPY --from=composer-deps /build/vendor ./vendor
2345

46+
# Copy generated translations from Symfony
47+
COPY --from=translations /build/var/translations ./var/translations
48+
2449
# Copy package files
2550
COPY package.json yarn.lock webpack.config.js ./
2651
COPY assets ./assets

Dockerfile-frankenphp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,38 @@ RUN composer install --no-dev --no-scripts --no-autoloader --prefer-dist --ignor
1111

1212
# ---
1313

14+
# Stage to generate Symfony translations needed for webpack
15+
FROM composer:latest AS translations
16+
17+
WORKDIR /build
18+
19+
# Copy composer dependencies and application files
20+
COPY --from=composer-deps /build/vendor ./vendor
21+
COPY composer.json composer.lock symfony.lock ./
22+
COPY bin ./bin
23+
COPY config ./config
24+
COPY public ./public
25+
COPY src ./src
26+
COPY templates ./templates
27+
COPY translations ./translations
28+
29+
# Generate autoloader and dump translations
30+
RUN composer dump-autoload --no-dev --classmap-authoritative && \
31+
php bin/console cache:clear --no-warmup && \
32+
php bin/console cache:warmup
33+
34+
# ---
35+
1436
FROM node:22-bookworm-slim AS assets
1537

1638
WORKDIR /build
1739

1840
# Copy vendor directory from composer stage (needed for Symfony UX packages)
1941
COPY --from=composer-deps /build/vendor ./vendor
2042

43+
# Copy generated translations from Symfony
44+
COPY --from=translations /build/var/translations ./var/translations
45+
2146
# Copy package files
2247
COPY package.json yarn.lock webpack.config.js ./
2348
COPY assets ./assets

0 commit comments

Comments
 (0)