Fetch the registry token from the public address, not the runner's #10

Merged
jcoffey-dev merged 1 commits from ci/registry-token-host into main 2026-09-22 01:20:48 +00:00
Showing only changes of commit 795fe43cec - Show all commits
+14 -10
View File
@@ -141,16 +141,20 @@ publish:
before_script: before_script:
- echo "$CI_REGISTRY_PASSWORD" | docker login -u "$CI_REGISTRY_USER" --password-stdin "$CI_REGISTRY" - echo "$CI_REGISTRY_PASSWORD" | docker login -u "$CI_REGISTRY_USER" --password-stdin "$CI_REGISTRY"
- docker run --privileged --rm tonistiigi/binfmt --install arm64 - docker run --privileged --rm tonistiigi/binfmt --install arm64
# The builder runs as a container on the host's daemon and does the push # The registry hands out push tokens from https://git.coffeylabs.org/jwt/auth,
# itself, including fetching a registry token from git.coffeylabs.org. # and buildx fetches them here, in the job, not in its builder. On ci-net
# On the runner's network that name resolves to an internal address # that name is the gitlab container itself (172.30.0.2), which serves
# (172.30.0.2) with nothing on 443, so the token request was refused and # plain HTTP to the runner and nothing on 443, so every push failed at the
# the push failed at the last step (job 513). On the host's network the # last step with "connection refused". The login above works because the
# name resolves as it does for `docker login` above. Only the token request # host's daemon does it, and the host resolves the name publicly. So, for
# uses it; layers still go to the registry's own DNS-only name. A new name, # this job only, point the name at its public address the same way. Only
# because `ci-builder` is a long-lived container shared between jobs and # the token request uses it; layers go to the registry's own DNS-only name.
# would keep whatever network it was created on. - |
- docker buildx create --use --name ci-builder-host --driver docker-container --driver-opt network=host || docker buildx use ci-builder-host public="$(nslookup "$CI_SERVER_HOST" 1.1.1.1 2>/dev/null | awk '/^Address: / && $2 !~ /:/ { print $2; exit }')"
if [ -z "$public" ]; then echo "Could not resolve $CI_SERVER_HOST publicly" >&2; exit 1; fi
echo "$public $CI_SERVER_HOST" >> /etc/hosts
echo "$CI_SERVER_HOST -> $public for the registry token"
- docker buildx create --use --name ci-builder --driver docker-container || docker buildx use ci-builder
script: script:
- | - |
docker buildx build \ docker buildx build \