fix(build): NuGet cache mount sharing=locked to avoid concurrent restore races
Build Docker Image / build (push) Failing after 18m21s
Build Docker Image / deploy (push) Has been skipped

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.
This commit is contained in:
2026-05-17 14:02:20 +08:00
parent a4492d4938
commit 5028490ce2
+2 -2
View File
@@ -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 \