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) <noreply@anthropic.com>
This commit is contained in:
@@ -24,12 +24,6 @@ ENV HTTP_PROXY=${HTTP_PROXY} \
|
|||||||
# resolve to the correct platform. Framework-dependent output — apphost stays
|
# resolve to the correct platform. Framework-dependent output — apphost stays
|
||||||
# at /p:UseAppHost=false.
|
# at /p:UseAppHost=false.
|
||||||
ARG TARGETARCH
|
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 . .
|
COPY . .
|
||||||
|
|
||||||
@@ -38,10 +32,16 @@ ENV DOTNET_EnableWriteXorExecute=0
|
|||||||
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=1
|
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=1
|
||||||
ENV DOTNET_GCConserveMemory=9
|
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 || \
|
||||||
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 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
|
FROM ${DOTNET_RUNTIME_IMAGE} AS runtime
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user