From df70b64956a96d2e06bd3fdaa21ed79120f81db1 Mon Sep 17 00:00:00 2001 From: nanxun Date: Thu, 11 Jun 2026 17:52:18 +0800 Subject: [PATCH] build: target linux-arm64 and streamline the Docker image build Pin the WebApi to RuntimeIdentifier=linux-arm64 (framework-dependent) and rework the Dockerfile for ARM64: copy the full context up front, add QEMU emulation workarounds, and drop debug symbols / cap parallelism during publish. Co-Authored-By: Claude Opus 4.8 --- src/LiveRecorder.WebApi/Dockerfile | 17 ++++++++--------- .../LiveRecorder.WebApi.csproj | 2 ++ 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/LiveRecorder.WebApi/Dockerfile b/src/LiveRecorder.WebApi/Dockerfile index 4608037..d3e2c08 100644 --- a/src/LiveRecorder.WebApi/Dockerfile +++ b/src/LiveRecorder.WebApi/Dockerfile @@ -4,16 +4,15 @@ ARG DOTNET_RUNTIME_IMAGE=mcr.microsoft.com/dotnet/aspnet:8.0-bookworm-slim FROM ${DOTNET_SDK_IMAGE} AS build WORKDIR /src -COPY ["LiveRecorder.sln", "./"] -COPY ["src/LiveRecorder.Domain/LiveRecorder.Domain.csproj", "src/LiveRecorder.Domain/"] -COPY ["src/LiveRecorder.Application/LiveRecorder.Application.csproj", "src/LiveRecorder.Application/"] -COPY ["src/LiveRecorder.Infrastructure/LiveRecorder.Infrastructure.csproj", "src/LiveRecorder.Infrastructure/"] -COPY ["src/LiveRecorder.WebApi/LiveRecorder.WebApi.csproj", "src/LiveRecorder.WebApi/"] - -RUN dotnet restore "src/LiveRecorder.WebApi/LiveRecorder.WebApi.csproj" - COPY . . -RUN dotnet publish "src/LiveRecorder.WebApi/LiveRecorder.WebApi.csproj" -c Release -o /app/publish /p:UseAppHost=false + +# Workaround for QEMU ARM64 emulation +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 +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 FROM ${DOTNET_RUNTIME_IMAGE} AS runtime diff --git a/src/LiveRecorder.WebApi/LiveRecorder.WebApi.csproj b/src/LiveRecorder.WebApi/LiveRecorder.WebApi.csproj index 252de69..e6c09cf 100644 --- a/src/LiveRecorder.WebApi/LiveRecorder.WebApi.csproj +++ b/src/LiveRecorder.WebApi/LiveRecorder.WebApi.csproj @@ -17,6 +17,8 @@ net8.0 enable enable + linux-arm64 + false