From 68ab2c773a10a2342737f3447cb5d85c33e7d86a Mon Sep 17 00:00:00 2001 From: nanxun Date: Fri, 3 Jul 2026 17:22:48 +0800 Subject: [PATCH] fix: merge restore+publish+RID into one RUN so shell var persists The case statement that sets RID based on TARGETARCH runs in a /bin/sh subshell. When it was in a separate RUN from dotnet restore/publish, the RID variable was not available to the publish command. Merge the case dispatch, dotnet restore, and dotnet publish into a single RUN so the RID shell variable stays in scope. Also restores the COPY . . directive that was accidentally dropped. Co-Authored-By: Claude Opus 4.8 (1M context) --- src/LiveRecorder.WebApi/Dockerfile | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/LiveRecorder.WebApi/Dockerfile b/src/LiveRecorder.WebApi/Dockerfile index 91fd44e..9109e28 100644 --- a/src/LiveRecorder.WebApi/Dockerfile +++ b/src/LiveRecorder.WebApi/Dockerfile @@ -24,12 +24,6 @@ ENV HTTP_PROXY=${HTTP_PROXY} \ # resolve to the correct platform. Framework-dependent output — apphost stays # at /p:UseAppHost=false. ARG TARGETARCH -RUN case "$TARGETARCH" in \ - amd64) DOTNET_RID=linux-x64 ;; \ - arm64) DOTNET_RID=linux-arm64 ;; \ - *) echo "ERROR: unknown TARGETARCH=$TARGETARCH" >&2; exit 1 ;; \ - esac ; \ - echo "Building for TARGETARCH=$TARGETARCH -> RID=$DOTNET_RID" COPY . . @@ -38,10 +32,16 @@ ENV DOTNET_EnableWriteXorExecute=0 ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=1 ENV DOTNET_GCConserveMemory=9 -RUN dotnet restore "src/LiveRecorder.WebApi/LiveRecorder.WebApi.csproj" -p:RestoreUseStaticGraphEvaluation=true --disable-parallel || \ +RUN case "$TARGETARCH" in \ + amd64) RID=linux-x64 ;; \ + arm64) RID=linux-arm64 ;; \ + *) echo "ERROR: unknown TARGETARCH=$TARGETARCH" >&2; exit 1 ;; \ + esac ; \ + echo "Building for TARGETARCH=$TARGETARCH -> RID=$RID" ; \ dotnet restore "src/LiveRecorder.WebApi/LiveRecorder.WebApi.csproj" -p:RestoreUseStaticGraphEvaluation=true --disable-parallel || \ - dotnet restore "src/LiveRecorder.WebApi/LiveRecorder.WebApi.csproj" -p:RestoreUseStaticGraphEvaluation=true --disable-parallel -RUN dotnet publish "src/LiveRecorder.WebApi/LiveRecorder.WebApi.csproj" -c Release -o /app/publish -r $DOTNET_RID /p:UseAppHost=false /p:DebugType=None /p:DebugSymbols=false /maxcpucount:1 + dotnet restore "src/LiveRecorder.WebApi/LiveRecorder.WebApi.csproj" -p:RestoreUseStaticGraphEvaluation=true --disable-parallel || \ + dotnet restore "src/LiveRecorder.WebApi/LiveRecorder.WebApi.csproj" -p:RestoreUseStaticGraphEvaluation=true --disable-parallel ; \ + dotnet publish "src/LiveRecorder.WebApi/LiveRecorder.WebApi.csproj" -c Release -o /app/publish -r "$RID" /p:UseAppHost=false /p:DebugType=None /p:DebugSymbols=false /maxcpucount:1 FROM ${DOTNET_RUNTIME_IMAGE} AS runtime