From af7a3d1276427f462b77686efa4b7af3b78fc788 Mon Sep 17 00:00:00 2001 From: nanxun Date: Fri, 3 Jul 2026 13:39:15 +0800 Subject: [PATCH] fix: declare proxy ARGs in build stage so dotnet restore reaches nuget.org nuget.org is only reachable through the 7890 proxy from the build network (direct hits return a 302 redirect loop; proxied requests return 200, verified 8/8). The pipeline passes --build-arg HTTP_PROXY/HTTPS_PROXY, but Dockerfile did not declare these ARGs in the build stage, so buildkit did not inject them into the RUN environment and 'dotnet restore' tried nuget.org directly -> NU1301 'Unable to load the service index'. Declare HTTP_PROXY/HTTPS_PROXY/NO_PROXY (upper+lower case) as build-stage ARGs and promote them to ENV so dotnet's HttpClient uses the proxy. Also add two restore retries (--disable-parallel) to smooth over transient proxy blips. Co-Authored-By: Claude Opus 4.8 (1M context) --- src/LiveRecorder.WebApi/Dockerfile | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/LiveRecorder.WebApi/Dockerfile b/src/LiveRecorder.WebApi/Dockerfile index d3e2c08..09c6c62 100644 --- a/src/LiveRecorder.WebApi/Dockerfile +++ b/src/LiveRecorder.WebApi/Dockerfile @@ -4,6 +4,22 @@ ARG DOTNET_RUNTIME_IMAGE=mcr.microsoft.com/dotnet/aspnet:8.0-bookworm-slim FROM ${DOTNET_SDK_IMAGE} AS build WORKDIR /src +# Proxy settings for NuGet restore (nuget.org is only reachable via the proxy +# from the build network). Declared as ARG then promoted to ENV so dotnet and +# the underlying HttpClient pick them up during restore/publish. +ARG HTTP_PROXY +ARG HTTPS_PROXY +ARG NO_PROXY +ARG http_proxy +ARG https_proxy +ARG no_proxy +ENV HTTP_PROXY=${HTTP_PROXY} \ + HTTPS_PROXY=${HTTPS_PROXY} \ + NO_PROXY=${NO_PROXY} \ + http_proxy=${http_proxy} \ + https_proxy=${https_proxy} \ + no_proxy=${no_proxy} + COPY . . # Workaround for QEMU ARM64 emulation @@ -11,7 +27,9 @@ 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 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 FROM ${DOTNET_RUNTIME_IMAGE} AS runtime