From 0ccfbdc358b1f689e2694eceb3549b3cdf825a36 Mon Sep 17 00:00:00 2001 From: William Oldham Date: Sun, 28 Jul 2024 21:02:56 +0100 Subject: [PATCH] Properly set architecture when using --platform for CI builds --- Dockerfile | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 8d14606..572b014 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,8 +8,11 @@ RUN dotnet restore "PKHaX.csproj" COPY . . -ARG ARCHITECTURE=x64 -RUN dotnet publish "PKHaX.csproj" -c Release -o /app/publish -r "linux-$ARCHITECTURE" +# This if logic is done to set the correct architecture for the runtime, dotnet publish needs x64 wheras Docker uses amd64 +# TARGETARCH is automatically set by Docker when building the image with the --platform flag +ARG TARGETARCH +RUN if [ "$TARGETARCH" = "amd64" ] ; then export ARCH="x64" ; else export ARCH=$TARGETARCH ; fi; \ + dotnet publish "PKHaX.csproj" -c Release -o /app/publish -r "linux-$ARCH" FROM debian:12 WORKDIR /app