From ba3c0221a2b21d94255a0eb1dc785d36ca47b298 Mon Sep 17 00:00:00 2001 From: gsayer <9694317+gsayer@users.noreply.github.com> Date: Mon, 29 Jun 2026 17:03:15 +0200 Subject: [PATCH] ci(release): publish multi-arch image (linux/amd64,linux/arm64) The release workflow built for the runner arch only (amd64) and the Dockerfile was not arch-aware. Align it with the Backend/WebApp pattern: pin the build stage to $BUILDPLATFORM and branch restore/publish on $TARGETARCH (--runtime linux-arm64|linux-x64 --self-contained false). The final stage has no RUN, so buildx cross-builds the arm64 image from the amd64 runner with no QEMU. Add platforms to the build-push step. Verified locally: buildx --platform linux/amd64,linux/arm64 produces a multi-arch manifest list with no emulation. --- .github/workflows/release.yml | 1 + Dockerfile | 22 ++++++++++++++++------ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2e11d80..f6b2de8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -205,6 +205,7 @@ jobs: uses: docker/build-push-action@v6 with: context: . + platforms: linux/amd64,linux/arm64 push: true build-args: | GITHUB_TOKEN=${{ secrets.PAT_DISPATCH }} diff --git a/Dockerfile b/Dockerfile index fdbc2d0..995efe0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,7 @@ -# Build stage -FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build +# Build stage with multi-platform support +FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:10.0 AS build +ARG TARGETARCH +ARG BUILDPLATFORM ARG GITHUB_TOKEN ARG NUGET_SOURCE=github WORKDIR /src @@ -21,13 +23,21 @@ RUN if [ "${NUGET_SOURCE}" = "github" ]; then \ --store-password-in-clear-text; \ fi -# Restore dependencies (cached layer) -RUN dotnet restore "PayrollEngine.PayrollConsole.sln" +# Restore with architecture-specific runtime +RUN if [ "$TARGETARCH" = "arm64" ]; then \ + dotnet restore "PayrollEngine.PayrollConsole.sln" --runtime linux-arm64; \ + else \ + dotnet restore "PayrollEngine.PayrollConsole.sln" --runtime linux-x64; \ + fi -# Copy remaining source files and publish +# Copy remaining source files and publish with architecture-specific runtime COPY . . WORKDIR "/src/PayrollConsole" -RUN dotnet publish "PayrollEngine.PayrollConsole.csproj" -c Release -o /app/publish --no-restore +RUN if [ "$TARGETARCH" = "arm64" ]; then \ + dotnet publish "PayrollEngine.PayrollConsole.csproj" -c Release -o /app/publish --runtime linux-arm64 --self-contained false; \ + else \ + dotnet publish "PayrollEngine.PayrollConsole.csproj" -c Release -o /app/publish --runtime linux-x64 --self-contained false; \ + fi # Runtime stage FROM mcr.microsoft.com/dotnet/aspnet:10.0