From 40ffc73aa800945fd3a0c1340abe082e948616a8 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Thu, 16 Apr 2026 12:50:19 -0700 Subject: [PATCH] ci(pjdfstest): cache docker layers via GHA to avoid apt mirror flakes (#9106) * ci(pjdfstest): cache docker layers via GHA to avoid apt mirror flakes Replace the local buildx cache + manual fallback with docker/setup-buildx-action and docker/build-push-action using type=gha cache. The e2e and pjdfstest Dockerfile layers now persist across runs in GitHub's own cache backend, so apt-get update only hits Ubuntu mirrors when the Dockerfiles change. Also add Acquire::Retries and Timeout so first-run cache-miss builds survive transient mirror sync errors. * ci(pjdfstest): use local registry to share e2e image across buildx builds The docker-container buildx driver cannot see images loaded into the host Docker daemon, so the second build's FROM chrislusf/seaweedfs:e2e failed with "not found" on registry-1.docker.io. Run a local registry:2 on the runner, push both images to localhost:5000, remap the FROM via build-contexts so the Dockerfile stays unchanged, then tag the pulled images locally for docker compose to consume. --- .github/workflows/pjdfstest.yml | 45 ++++++++++++++++++++++++++++----- docker/Dockerfile.e2e | 4 +-- test/pjdfstest/Dockerfile | 4 +-- 3 files changed, 42 insertions(+), 11 deletions(-) diff --git a/.github/workflows/pjdfstest.yml b/.github/workflows/pjdfstest.yml index c23ef5bb1..c95fe3ae4 100644 --- a/.github/workflows/pjdfstest.yml +++ b/.github/workflows/pjdfstest.yml @@ -39,18 +39,49 @@ jobs: with: go-version-file: 'go.mod' - - name: Build SeaweedFS e2e image + - name: Start local Docker registry + run: docker run -d --restart=always -p 5000:5000 --name registry registry:2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v4 + with: + driver-opts: network=host + + - name: Build weed race binary run: | cd docker - make build_e2e || { - echo "Retrying without buildx cache..." - make binary_race - docker build --no-cache -t chrislusf/seaweedfs:e2e -f Dockerfile.e2e . - } + make binary_race + + - name: Build SeaweedFS e2e image + uses: docker/build-push-action@v6 + with: + context: docker + file: docker/Dockerfile.e2e + tags: localhost:5000/chrislusf/seaweedfs:e2e + push: true + cache-from: type=gha,scope=pjdfstest-e2e + cache-to: type=gha,mode=max,scope=pjdfstest-e2e + + - name: Tag e2e image for docker compose + run: | + docker pull localhost:5000/chrislusf/seaweedfs:e2e + docker tag localhost:5000/chrislusf/seaweedfs:e2e chrislusf/seaweedfs:e2e - name: Build pjdfstest image + uses: docker/build-push-action@v6 + with: + context: test/pjdfstest + build-contexts: | + chrislusf/seaweedfs:e2e=docker-image://localhost:5000/chrislusf/seaweedfs:e2e + tags: localhost:5000/chrislusf/seaweedfs:pjdfstest + push: true + cache-from: type=gha,scope=pjdfstest-harness + cache-to: type=gha,mode=max,scope=pjdfstest-harness + + - name: Tag pjdfstest image for docker compose run: | - docker build -t chrislusf/seaweedfs:pjdfstest test/pjdfstest/ + docker pull localhost:5000/chrislusf/seaweedfs:pjdfstest + docker tag localhost:5000/chrislusf/seaweedfs:pjdfstest chrislusf/seaweedfs:pjdfstest - name: Start SeaweedFS cluster run: | diff --git a/docker/Dockerfile.e2e b/docker/Dockerfile.e2e index 1c1710af4..77e93eaed 100644 --- a/docker/Dockerfile.e2e +++ b/docker/Dockerfile.e2e @@ -7,8 +7,8 @@ LABEL author="Chris Lu" # Production images (Dockerfile.go_build) use proper user isolation with su-exec. # For testing purposes, running as root avoids permission complexities and dependency # on Alpine-specific tools like su-exec (not available in Ubuntu repos). -RUN apt-get update && \ - DEBIAN_FRONTEND=noninteractive apt-get install -y \ +RUN apt-get -o Acquire::Retries=5 -o Acquire::http::Timeout=30 update && \ + DEBIAN_FRONTEND=noninteractive apt-get -o Acquire::Retries=5 -o Acquire::http::Timeout=30 install -y \ --no-install-recommends \ --no-install-suggests \ curl \ diff --git a/test/pjdfstest/Dockerfile b/test/pjdfstest/Dockerfile index ce1f1a950..9aeb1c3ca 100644 --- a/test/pjdfstest/Dockerfile +++ b/test/pjdfstest/Dockerfile @@ -1,7 +1,7 @@ FROM chrislusf/seaweedfs:e2e -RUN apt-get update && \ - DEBIAN_FRONTEND=noninteractive apt-get install -y \ +RUN apt-get -o Acquire::Retries=5 -o Acquire::http::Timeout=30 update && \ + DEBIAN_FRONTEND=noninteractive apt-get -o Acquire::Retries=5 -o Acquire::http::Timeout=30 install -y \ --no-install-recommends \ --no-install-suggests \ autoconf \