Skip to content

Commit 6a1792d

Browse files
Copilotjbtronics
andcommitted
Simplify asset build: copy entire project instead of individual files
Refactored to copy the entire project directory in composer-deps and assets stages instead of cherry-picking specific files. This: - Eliminates the separate translations stage - Avoids missing file issues - Simplifies the build process - Maintains performance benefit of building assets once on native platform Both stages now use COPY . . to get all project files, avoiding the complexity of tracking which files are needed. Co-authored-by: jbtronics <[email protected]>
1 parent 9402382 commit 6a1792d

File tree

2 files changed

+14
-64
lines changed

2 files changed

+14
-64
lines changed

Dockerfile

Lines changed: 7 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,12 @@ FROM composer:latest AS composer-deps
88

99
WORKDIR /build
1010

11-
# Copy composer files and install PHP dependencies (needed for Symfony UX assets)
12-
COPY composer.json composer.lock symfony.lock ./
13-
RUN composer install --no-dev --no-scripts --no-autoloader --prefer-dist --ignore-platform-reqs
11+
# Copy entire project to install dependencies and generate translations
12+
COPY . .
1413

15-
# ---
16-
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 .env ./
26-
COPY bin ./bin
27-
COPY config ./config
28-
COPY public ./public
29-
COPY src ./src
30-
COPY templates ./templates
31-
COPY translations ./translations
32-
33-
# Generate autoloader and dump translations
34-
RUN composer dump-autoload --no-dev --classmap-authoritative && \
14+
# Install composer dependencies (needed for Symfony UX assets and cache warmup)
15+
RUN composer install --no-dev --no-scripts --no-autoloader --prefer-dist --ignore-platform-reqs && \
16+
composer dump-autoload --no-dev --classmap-authoritative && \
3517
php bin/console cache:clear --no-warmup && \
3618
php bin/console cache:warmup
3719

@@ -41,15 +23,8 @@ FROM node:22-bookworm-slim AS assets
4123

4224
WORKDIR /build
4325

44-
# Copy vendor directory from composer stage (needed for Symfony UX packages)
45-
COPY --from=composer-deps /build/vendor ./vendor
46-
47-
# Copy generated translations from Symfony
48-
COPY --from=translations /build/var/translations ./var/translations
49-
50-
# Copy package files
51-
COPY package.json yarn.lock webpack.config.js ./
52-
COPY assets ./assets
26+
# Copy entire project with vendor and generated translations from composer-deps stage
27+
COPY --from=composer-deps /build ./
5328

5429
# Install dependencies and build assets
5530
RUN yarn install --network-timeout 600000 && \

Dockerfile-frankenphp

Lines changed: 7 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,12 @@ FROM composer:latest AS composer-deps
55

66
WORKDIR /build
77

8-
# Copy composer files and install PHP dependencies (needed for Symfony UX assets)
9-
COPY composer.json composer.lock symfony.lock ./
10-
RUN composer install --no-dev --no-scripts --no-autoloader --prefer-dist --ignore-platform-reqs
8+
# Copy entire project to install dependencies and generate translations
9+
COPY . .
1110

12-
# ---
13-
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 .env ./
23-
COPY bin ./bin
24-
COPY config ./config
25-
COPY public ./public
26-
COPY src ./src
27-
COPY templates ./templates
28-
COPY translations ./translations
29-
30-
# Generate autoloader and dump translations
31-
RUN composer dump-autoload --no-dev --classmap-authoritative && \
11+
# Install composer dependencies (needed for Symfony UX assets and cache warmup)
12+
RUN composer install --no-dev --no-scripts --no-autoloader --prefer-dist --ignore-platform-reqs && \
13+
composer dump-autoload --no-dev --classmap-authoritative && \
3214
php bin/console cache:clear --no-warmup && \
3315
php bin/console cache:warmup
3416

@@ -38,15 +20,8 @@ FROM node:22-bookworm-slim AS assets
3820

3921
WORKDIR /build
4022

41-
# Copy vendor directory from composer stage (needed for Symfony UX packages)
42-
COPY --from=composer-deps /build/vendor ./vendor
43-
44-
# Copy generated translations from Symfony
45-
COPY --from=translations /build/var/translations ./var/translations
46-
47-
# Copy package files
48-
COPY package.json yarn.lock webpack.config.js ./
49-
COPY assets ./assets
23+
# Copy entire project with vendor and generated translations from composer-deps stage
24+
COPY --from=composer-deps /build ./
5025

5126
# Install dependencies and build assets
5227
RUN yarn install --network-timeout 600000 && \

0 commit comments

Comments
 (0)