From f5b925f2427364ccf360d7f3fe49902a5298bee2 Mon Sep 17 00:00:00 2001 From: Zhengchen Tao Date: Sun, 17 May 2026 14:02:32 +0800 Subject: [PATCH] fix(build): NuGet cache mount sharing=locked to avoid concurrent restore races With capacity=2 in the runner, two builds can run in parallel and share the same buildkit cache mount (sharing=shared is the default). dotnet restore writes NuGet temp files (*.ar5 etc.) that the OTHER build can race-remove mid-extraction, yielding 'Could not find file' errors like: error : Could not find file '/root/.nuget/packages/microsoft.identitymodel.abstractions/8.0.1/3wu4hkqc.ar5' sharing=locked serializes cache access (one build at a time can touch the mount). Still benefits from across-build caching, just no concurrency on the mount itself. --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 47f7e65..80d2ed6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,12 +6,12 @@ WORKDIR /src # 先复制 csproj,单独 restore(利用层缓存) COPY gitea-mcp.csproj . -RUN --mount=type=cache,target=/root/.nuget/packages \ +RUN --mount=type=cache,target=/root/.nuget/packages,sharing=locked \ dotnet restore gitea-mcp.csproj # 复制剩余源码并发布 COPY . . -RUN --mount=type=cache,target=/root/.nuget/packages \ +RUN --mount=type=cache,target=/root/.nuget/packages,sharing=locked \ dotnet publish gitea-mcp.csproj \ -c Release \ -o /app/publish \