From aaa4af40c523295a451f475ab9716eff8deea271 Mon Sep 17 00:00:00 2001 From: hsiegeln <37154749+hsiegeln@users.noreply.github.com> Date: Sat, 4 Apr 2026 22:31:22 +0200 Subject: [PATCH] fix: use BUILDPLATFORM for native cross-compilation, remove broken cache mounts Build and frontend stages now use --platform=$BUILDPLATFORM so Maven and Node run natively on the ARM64 CI runner instead of under QEMU emulation. Only the final JRE runtime stage targets amd64. Removed --mount=type=cache which doesn't persist across CI runs with buildx --push; the registry layer cache (--cache-from/--cache-to in CI) handles caching the dependency layer. Co-Authored-By: Claude Opus 4.6 (1M context) --- Dockerfile | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 941dddb..c9b8f29 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,7 @@ # syntax=docker/dockerfile:1 -FROM node:22-alpine AS frontend + +# Frontend: runs natively on build host +FROM --platform=$BUILDPLATFORM node:22-alpine AS frontend ARG REGISTRY_TOKEN WORKDIR /ui COPY ui/package.json ui/package-lock.json ui/.npmrc ./ @@ -7,15 +9,18 @@ RUN echo "//gitea.siegeln.net/api/packages/cameleer/npm/:_authToken=${REGISTRY_T COPY ui/ . RUN npm run build -FROM eclipse-temurin:21-jdk-alpine AS build +# Maven build: runs natively on build host (no QEMU emulation) +FROM --platform=$BUILDPLATFORM eclipse-temurin:21-jdk-alpine AS build WORKDIR /build COPY .mvn/ .mvn/ COPY mvnw pom.xml ./ -RUN --mount=type=cache,target=/root/.m2/repository ./mvnw dependency:go-offline -B +# Cache deps — only re-downloaded when POM changes +RUN ./mvnw dependency:go-offline -B || true COPY src/ src/ COPY --from=frontend /src/main/resources/static/ src/main/resources/static/ -RUN --mount=type=cache,target=/root/.m2/repository ./mvnw package -DskipTests -B +RUN ./mvnw package -DskipTests -B +# Runtime: target platform (amd64) FROM eclipse-temurin:21-jre-alpine WORKDIR /app RUN addgroup -S cameleer && adduser -S cameleer -G cameleer