chore: persist Docker build cache mounts across CI runs (#32700)
This commit is contained in:
parent
3a0335cdd8
commit
6786ea8b2b
6 changed files with 67 additions and 2 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
.cache
|
.cache
|
||||||
.claude
|
.claude
|
||||||
|
.docker-cache
|
||||||
.idea
|
.idea
|
||||||
.omc
|
.omc
|
||||||
.playwright-mcp
|
.playwright-mcp
|
||||||
|
|
|
||||||
45
.github/actions/docker-cache/action.yml
vendored
Normal file
45
.github/actions/docker-cache/action.yml
vendored
Normal file
|
|
@ -0,0 +1,45 @@
|
||||||
|
name: Docker build cache
|
||||||
|
description: >
|
||||||
|
Restores the Dockerfile's Go and npm cache mounts and persists them afterwards.
|
||||||
|
BuildKit cache mounts live in the builder daemon and are not covered by any
|
||||||
|
cache exporter, so they have to be injected and extracted explicitly. Requires
|
||||||
|
Buildx to be set up and must run before the build.
|
||||||
|
|
||||||
|
inputs:
|
||||||
|
builder:
|
||||||
|
description: Buildx builder name
|
||||||
|
required: true
|
||||||
|
cache-scope:
|
||||||
|
description: >
|
||||||
|
Cache namespace, mirroring build-toolchain. "main" (default) writes the
|
||||||
|
shared cache. Untrusted callers (e.g. PR builds) should pass a different
|
||||||
|
value such as "pr": writes stay isolated so they cannot poison the shared
|
||||||
|
cache, while reads still fall back to it.
|
||||||
|
default: main
|
||||||
|
|
||||||
|
runs:
|
||||||
|
using: composite
|
||||||
|
steps:
|
||||||
|
# Rotates with the dependency set. Source changes keep using the existing
|
||||||
|
# cache, which still covers the third-party packages dominating the build.
|
||||||
|
- name: Cache mount contents
|
||||||
|
id: cache
|
||||||
|
uses: actions/cache@v6
|
||||||
|
with:
|
||||||
|
path: .docker-cache
|
||||||
|
key: ${{ runner.os }}-docker-mounts-${{ inputs.cache-scope }}-${{ hashFiles('go.sum', 'package-lock.json') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-docker-mounts-${{ inputs.cache-scope }}-
|
||||||
|
${{ runner.os }}-docker-mounts-main-
|
||||||
|
|
||||||
|
- name: Inject cache mounts
|
||||||
|
uses: reproducible-containers/buildkit-cache-dance@5422eac04292c961a382e0f584ea0f03ad9da723 # v3.4.0
|
||||||
|
with:
|
||||||
|
builder: ${{ inputs.builder }}
|
||||||
|
cache-map: |
|
||||||
|
{
|
||||||
|
".docker-cache/go-build": "/root/.cache/go-build",
|
||||||
|
".docker-cache/go-mod": "/root/.cache/go-mod",
|
||||||
|
".docker-cache/npm": "/root/.npm"
|
||||||
|
}
|
||||||
|
skip-extraction: ${{ steps.cache.outputs.cache-hit }}
|
||||||
7
.github/workflows/command-pr-build.yml
vendored
7
.github/workflows/command-pr-build.yml
vendored
|
|
@ -129,8 +129,15 @@ jobs:
|
||||||
password: ${{ secrets.DOCKER_PASS }}
|
password: ${{ secrets.DOCKER_PASS }}
|
||||||
|
|
||||||
- name: Setup Buildx
|
- name: Setup Buildx
|
||||||
|
id: buildx
|
||||||
uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4
|
uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4
|
||||||
|
|
||||||
|
- name: Restore build cache
|
||||||
|
uses: ./.github/actions/docker-cache
|
||||||
|
with:
|
||||||
|
builder: ${{ steps.buildx.outputs.name }}
|
||||||
|
cache-scope: pr
|
||||||
|
|
||||||
- name: Publish
|
- name: Publish
|
||||||
uses: docker/build-push-action@f9f3042f7e2789586610d6e8b85c8f03e5195baf # v7
|
uses: docker/build-push-action@f9f3042f7e2789586610d6e8b85c8f03e5195baf # v7
|
||||||
with:
|
with:
|
||||||
|
|
|
||||||
6
.github/workflows/nightly-docker.yml
vendored
6
.github/workflows/nightly-docker.yml
vendored
|
|
@ -28,8 +28,14 @@ jobs:
|
||||||
password: ${{ secrets.DOCKER_PASS }}
|
password: ${{ secrets.DOCKER_PASS }}
|
||||||
|
|
||||||
- name: Setup Buildx
|
- name: Setup Buildx
|
||||||
|
id: buildx
|
||||||
uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4
|
uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4
|
||||||
|
|
||||||
|
- name: Restore build cache
|
||||||
|
uses: ./.github/actions/docker-cache
|
||||||
|
with:
|
||||||
|
builder: ${{ steps.buildx.outputs.name }}
|
||||||
|
|
||||||
- name: Define tags
|
- name: Define tags
|
||||||
id: meta
|
id: meta
|
||||||
uses: docker/metadata-action@80c7e94dd9b9319bd5eb7a0e0fe9291e23a2a2e9 # v6
|
uses: docker/metadata-action@80c7e94dd9b9319bd5eb7a0e0fe9291e23a2a2e9 # v6
|
||||||
|
|
|
||||||
6
.github/workflows/release.yml
vendored
6
.github/workflows/release.yml
vendored
|
|
@ -60,8 +60,14 @@ jobs:
|
||||||
password: ${{ secrets.DOCKER_PASS }}
|
password: ${{ secrets.DOCKER_PASS }}
|
||||||
|
|
||||||
- name: Setup Buildx
|
- name: Setup Buildx
|
||||||
|
id: buildx
|
||||||
uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4
|
uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4
|
||||||
|
|
||||||
|
- name: Restore build cache
|
||||||
|
uses: ./.github/actions/docker-cache
|
||||||
|
with:
|
||||||
|
builder: ${{ steps.buildx.outputs.name }}
|
||||||
|
|
||||||
- name: Meta
|
- name: Meta
|
||||||
id: meta
|
id: meta
|
||||||
uses: docker/metadata-action@80c7e94dd9b9319bd5eb7a0e0fe9291e23a2a2e9 # v6
|
uses: docker/metadata-action@80c7e94dd9b9319bd5eb7a0e0fe9291e23a2a2e9 # v6
|
||||||
|
|
|
||||||
|
|
@ -49,12 +49,12 @@ RUN --mount=type=cache,target=${GOMODCACHE} go mod download
|
||||||
COPY Makefile .
|
COPY Makefile .
|
||||||
COPY cmd/implement/ cmd/implement/
|
COPY cmd/implement/ cmd/implement/
|
||||||
COPY api/ api/
|
COPY api/ api/
|
||||||
RUN --mount=type=cache,target=${GOMODCACHE} make install
|
RUN --mount=type=cache,target=${GOMODCACHE} --mount=type=cache,target=${GOCACHE} make install
|
||||||
|
|
||||||
# prepare
|
# prepare
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN make patch-asn1
|
RUN make patch-asn1
|
||||||
RUN --mount=type=cache,target=${GOMODCACHE} make assets
|
RUN --mount=type=cache,target=${GOMODCACHE} --mount=type=cache,target=${GOCACHE} make assets
|
||||||
|
|
||||||
# copy ui
|
# copy ui
|
||||||
COPY --from=node /build/dist /build/dist
|
COPY --from=node /build/dist /build/dist
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue