diff --git a/.gitea/workflows/build-image.yml b/.gitea/workflows/build-image.yml index f7dd192..2713f5e 100644 --- a/.gitea/workflows/build-image.yml +++ b/.gitea/workflows/build-image.yml @@ -66,6 +66,10 @@ jobs: with: context: . push: true + # buildx 每次 CI 起新的 buildkit 实例,layer cache 默认会丢。用 registry + # 当跨 CI run 的缓存。mode=max 把所有中间层(含 NuGet restore 那层)都存。 + cache-from: type=registry,ref=git.zhengchentao.win/zhengchen.tao/gitea-mcp:buildcache + cache-to: type=registry,ref=git.zhengchentao.win/zhengchen.tao/gitea-mcp:buildcache,mode=max labels: | org.opencontainers.image.source=https://git.zhengchentao.win/zhengchen.tao/gitea-mcp org.opencontainers.image.revision=${{ steps.meta.outputs.full_sha }} diff --git a/Dockerfile b/Dockerfile index e02dafb..47f7e65 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,3 +1,4 @@ +# syntax=docker/dockerfile:1.6 # ── Stage 1: build ────────────────────────────────────────────── FROM mcr.microsoft.com/dotnet/sdk:10.0 AS builder @@ -5,11 +6,13 @@ WORKDIR /src # 先复制 csproj,单独 restore(利用层缓存) COPY gitea-mcp.csproj . -RUN dotnet restore gitea-mcp.csproj +RUN --mount=type=cache,target=/root/.nuget/packages \ + dotnet restore gitea-mcp.csproj # 复制剩余源码并发布 COPY . . -RUN dotnet publish gitea-mcp.csproj \ +RUN --mount=type=cache,target=/root/.nuget/packages \ + dotnet publish gitea-mcp.csproj \ -c Release \ -o /app/publish \ --no-restore