From 5028490ce24eb8c77abd3d7f2f80df30162e9d4f Mon Sep 17 00:00:00 2001 From: Zhengchen Tao Date: Sun, 17 May 2026 14:02:20 +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 2e15f25..82de9fe 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,12 +6,12 @@ WORKDIR /src # 先只复制 csproj,利用层缓存加速 restore COPY obsidian-mcp.csproj ./ -RUN --mount=type=cache,target=/root/.nuget/packages \ +RUN --mount=type=cache,target=/root/.nuget/packages,sharing=locked \ dotnet restore obsidian-mcp.csproj # 复制全部源码并 publish COPY . . -RUN --mount=type=cache,target=/root/.nuget/packages \ +RUN --mount=type=cache,target=/root/.nuget/packages,sharing=locked \ dotnet publish obsidian-mcp.csproj \ --configuration Release \ --no-restore \