Fix multi-arch web image build: pin builder stage to native platform

vite build was failing under QEMU-emulated arm64 (npm install mangles
esbuild/rollup's platform-specific native binaries under emulation,
surfacing as an unrelated tinyglobby module-resolution error). The
build output is static files, arch-independent, so there's no reason
to build it under emulation at all.
This commit is contained in:
Duarte Santos committed 2026-07-21 11:24:37 +02:00
1 parent 0c240ba6f8
commit 17cad3fa3a
1 file changed
+8 -1
+8 -1
View File
@@ -1,6 +1,13 @@
# Multi-stage: build the React app, then serve it with nginx.
# Self-hosters never need Node locally — `docker compose up` builds everything.
FROM node:22-alpine AS build
#
# --platform=$BUILDPLATFORM pins the build stage to the host's native arch even when
# cross-building for other targets (e.g. amd64 host building an arm64 image). The build
# output (static JS/CSS/HTML) is arch-independent, so there's no reason to run it under
# QEMU — and QEMU-emulated npm installs are known to corrupt esbuild/rollup's platform-
# specific native binaries, which is what breaks `vite build` with unrelated-looking
# module-resolution errors.
FROM --platform=$BUILDPLATFORM node:22-alpine AS build
WORKDIR /app
COPY frontend/package.json frontend/package-lock.json* ./
RUN npm ci 2>/dev/null || npm install