Force asset build stages to run on native platform with --platform=$BUILDPLATFORM
Some checks failed
Docker Image Build / docker (push) Has been cancelled
Docker Image Build (FrankenPHP) / docker (push) Has been cancelled

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 <5410681+jbtronics@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2025-12-07 21:06:09 +00:00
parent 6a1792d46a
commit c5210a33c4
2 changed files with 8 additions and 4 deletions

View file

@ -4,7 +4,9 @@ ARG PHP_VERSION=8.4
# ---
# Build assets stage - runs on native platform (not emulated)
# This stage builds the frontend assets (JavaScript, CSS) using Node.js and Yarn
FROM composer:latest AS composer-deps
# The --platform=$BUILDPLATFORM ensures this stage runs on the native build platform (amd64)
# and not under emulation for ARM builds
FROM --platform=$BUILDPLATFORM composer:latest AS composer-deps
WORKDIR /build
@ -19,7 +21,7 @@ RUN composer install --no-dev --no-scripts --no-autoloader --prefer-dist --ignor
# ---
FROM node:22-bookworm-slim AS assets
FROM --platform=$BUILDPLATFORM node:22-bookworm-slim AS assets
WORKDIR /build

View file

@ -1,7 +1,9 @@
# ---
# Build assets stage - runs on native platform (not emulated)
# This stage builds the frontend assets (JavaScript, CSS) using Node.js and Yarn
FROM composer:latest AS composer-deps
# The --platform=$BUILDPLATFORM ensures this stage runs on the native build platform (amd64)
# and not under emulation for ARM builds
FROM --platform=$BUILDPLATFORM composer:latest AS composer-deps
WORKDIR /build
@ -16,7 +18,7 @@ RUN composer install --no-dev --no-scripts --no-autoloader --prefer-dist --ignor
# ---
FROM node:22-bookworm-slim AS assets
FROM --platform=$BUILDPLATFORM node:22-bookworm-slim AS assets
WORKDIR /build