From c5210a33c4c59b68d44c3d14080a2df8f023cd65 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 7 Dec 2025 21:06:09 +0000 Subject: [PATCH] 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 <5410681+jbtronics@users.noreply.github.com> --- Dockerfile | 6 ++++-- Dockerfile-frankenphp | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index f07b65b9..1cfb0e5a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 diff --git a/Dockerfile-frankenphp b/Dockerfile-frankenphp index ba4b01db..0f523189 100644 --- a/Dockerfile-frankenphp +++ b/Dockerfile-frankenphp @@ -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