fix: use docker TARGETARCH for runtime-specific dotnet publish
Removing RuntimeIdentifier from the csproj caused dotnet publish to produce ALL platform runtimes (20+) in the output, making runtime loading ambiguous and causing FileLoadException at startup. Instead of hardcoding the RID in the csproj, use Docker's built-in TARGETARCH ARG (injected automatically by buildx for multi-platform builds): amd64 -> -r linux-x64 arm64 -> -r linux-arm64 This ensures native deps (SQLitePCLRaw, EF Core) resolve to exactly one architecture per image, while keeping the csproj clean for local dev. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -20,6 +20,13 @@ ENV HTTP_PROXY=${HTTP_PROXY} \
|
||||
https_proxy=${https_proxy} \
|
||||
no_proxy=${no_proxy}
|
||||
|
||||
# Map Docker TARGETARCH to .NET RID so native dependencies (SQLite, EF Core)
|
||||
# resolve to the correct platform. Framework-dependent output — apphost stays
|
||||
# at /p:UseAppHost=false.
|
||||
ARG TARGETARCH
|
||||
RUN DOTNET_RID=$(case "$TARGETARCH" in amd64) echo linux-x64 ;; arm64) echo linux-arm64 ;; *) echo "unknown: $TARGETARCH" >&2; exit 1 ;; esac) ; \
|
||||
echo "Building for TARGETARCH=$TARGETARCH -> RID=$DOTNET_RID"
|
||||
|
||||
COPY . .
|
||||
|
||||
# Workaround for QEMU ARM64 emulation
|
||||
@@ -30,7 +37,7 @@ ENV DOTNET_GCConserveMemory=9
|
||||
RUN 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 /p:UseAppHost=false /p:DebugType=None /p:DebugSymbols=false /maxcpucount:1
|
||||
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
|
||||
|
||||
FROM ${DOTNET_RUNTIME_IMAGE} AS runtime
|
||||
|
||||
|
||||
Reference in New Issue
Block a user