Skip to content

Commit c5210a3

Browse files
Copilotjbtronics
andcommitted
Force asset build stages to run on native platform with --platform=$BUILDPLATFORM
Added --platform=$BUILDPLATFORM to composer-deps and assets stages to ensure they run on the native build platform (amd64) instead of being built separately for each target architecture (amd64, arm64, arm/v7). This is the critical change that makes the optimization work: - Without this flag, Docker Buildx builds these stages for each target platform - With this flag, stages run once on native platform and results are copied to all targets - Eliminates ARM emulation overhead for CPU-intensive asset compilation Co-authored-by: jbtronics <[email protected]>
1 parent 6a1792d commit c5210a3

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

Dockerfile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ ARG PHP_VERSION=8.4
44
# ---
55
# Build assets stage - runs on native platform (not emulated)
66
# This stage builds the frontend assets (JavaScript, CSS) using Node.js and Yarn
7-
FROM composer:latest AS composer-deps
7+
# The --platform=$BUILDPLATFORM ensures this stage runs on the native build platform (amd64)
8+
# and not under emulation for ARM builds
9+
FROM --platform=$BUILDPLATFORM composer:latest AS composer-deps
810

911
WORKDIR /build
1012

@@ -19,7 +21,7 @@ RUN composer install --no-dev --no-scripts --no-autoloader --prefer-dist --ignor
1921

2022
# ---
2123

22-
FROM node:22-bookworm-slim AS assets
24+
FROM --platform=$BUILDPLATFORM node:22-bookworm-slim AS assets
2325

2426
WORKDIR /build
2527

Dockerfile-frankenphp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
# ---
22
# Build assets stage - runs on native platform (not emulated)
33
# This stage builds the frontend assets (JavaScript, CSS) using Node.js and Yarn
4-
FROM composer:latest AS composer-deps
4+
# The --platform=$BUILDPLATFORM ensures this stage runs on the native build platform (amd64)
5+
# and not under emulation for ARM builds
6+
FROM --platform=$BUILDPLATFORM composer:latest AS composer-deps
57

68
WORKDIR /build
79

@@ -16,7 +18,7 @@ RUN composer install --no-dev --no-scripts --no-autoloader --prefer-dist --ignor
1618

1719
# ---
1820

19-
FROM node:22-bookworm-slim AS assets
21+
FROM --platform=$BUILDPLATFORM node:22-bookworm-slim AS assets
2022

2123
WORKDIR /build
2224

0 commit comments

Comments
 (0)