Skip to content

Commit 7c519ad

Browse files
committed
ci(build): route PR base-image pulls through mirror.gcr.io
The Pull Request Build job authenticates only to the push registry (OCIR), so every base image (golang, ubuntu, alpine, nginx, ...) is pulled from Docker Hub anonymously. Those pulls intermittently fail at auth.docker.io/token under Docker Hub's anonymous-pull rate limit, leaving the base image unresolved and failing make build. Build on a docker-container buildx builder whose buildkitd routes docker.io through mirror.gcr.io, Google's public pull-through cache for Docker Hub: no auth, far higher limits, transparent fall-through to Docker Hub on a miss. This reuses the builder pattern already proven in build-main.yaml (same make build, same DOCKER_CONFIG auth forwarding); only the committed hack/buildkitd.toml mirror config is new. Fail-safe: if mirror.gcr.io is unreachable, BuildKit falls back to registry-1.docker.io and the build still succeeds, so this strictly reduces build failures without adding a new hard dependency. Assisted-By: Claude <[email protected]> Signed-off-by: Aleksei Sviridkin <[email protected]>
1 parent 29bf56f commit 7c519ad

2 files changed

Lines changed: 43 additions & 0 deletions

File tree

‎.github/workflows/pull-requests.yaml‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,32 @@ jobs:
9999
env:
100100
DOCKER_CONFIG: ${{ runner.temp }}/.docker
101101

102+
# Build on a docker-container buildx builder whose buildkitd routes
103+
# docker.io base-image pulls through mirror.gcr.io (hack/buildkitd.toml).
104+
# The default embedded `docker` driver pulls base images from Docker Hub
105+
# anonymously and intermittently trips its anonymous-pull rate limit
106+
# (auth.docker.io/token failures leaving golang/ubuntu/nginx unresolved);
107+
# the mirror sidesteps that and falls back to Docker Hub on a miss/outage.
108+
# Mirrors build-main.yaml: create the builder under the SAME DOCKER_CONFIG
109+
# the Build step reads (runner.temp/.docker, holding the OCIR auth) so
110+
# buildx forwards push/cache auth to the container builder.
111+
- name: Set up Buildx (docker-container driver, docker.io mirror)
112+
id: buildx
113+
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3
114+
with:
115+
driver: docker-container
116+
buildkitd-config: hack/buildkitd.toml
117+
env:
118+
DOCKER_CONFIG: ${{ runner.temp }}/.docker
119+
102120
- name: Build
103121
run: make build
104122
env:
105123
DOCKER_CONFIG: ${{ runner.temp }}/.docker
124+
# Build on the docker-container builder created above so base-image
125+
# pulls go through the docker.io mirror (BUILDX_ARGS adds
126+
# --builder=$(BUILDER)).
127+
BUILDER: ${{ steps.buildx.outputs.name }}
106128
# Unique per (PR, commit) so concurrent PR builds never push the same
107129
# tag. PUBLISH_VERSIONED/PUBLISH_FLOATING stay off — PR images are
108130
# consumed by digest, and :latest belongs to release builds.

‎hack/buildkitd.toml‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# BuildKit daemon config for CI builds.
2+
#
3+
# Route docker.io base-image pulls through mirror.gcr.io, Google's public
4+
# pull-through cache for Docker Hub. The Build job authenticates only to the
5+
# push registry (OCIR), so every base image (golang, alpine, ubuntu, nginx, ...)
6+
# is otherwise pulled from Docker Hub ANONYMOUSLY and is subject to Docker Hub's
7+
# anonymous-pull rate limit -- which intermittently fails the build at
8+
# auth.docker.io/token with the base image left unresolved.
9+
#
10+
# mirror.gcr.io needs no auth, carries far higher limits, and transparently
11+
# falls through to Docker Hub on a cache miss. This config only takes effect on
12+
# a buildx builder created with `--config hack/buildkitd.toml` (CI wires this via
13+
# docker/setup-buildx-action `buildkitd-config:`); a plain local `make build` on
14+
# the default builder is unaffected.
15+
#
16+
# FAIL-SAFE: if mirror.gcr.io is unreachable, BuildKit logs "trying next host"
17+
# and falls back to registry-1.docker.io, so the build still succeeds (verified:
18+
# a build pointed at a non-resolving mirror fell back to Docker Hub and exited 0).
19+
# This strictly reduces build failures; it never introduces a new hard dependency.
20+
[registry."docker.io"]
21+
mirrors = ["mirror.gcr.io"]

0 commit comments

Comments
 (0)