fix(build-and-push): create buildx builder from SSH endpoint, drop colliding context

buildx refuses a builder instance whose name matches an existing docker
context. Create the builder directly from the ssh:// endpoint and clean up
any leftover context/builder of the same name first (idempotent re-runs).
This commit is contained in:
2026-07-12 12:51:48 -03:00
parent 8689226ca6
commit 57e25a8fef

View File

@@ -78,20 +78,20 @@ runs:
run: |
# Never set the DOCKER_HOST env var to the builder hostname: a bare
# value is treated as tcp://host:2375 and, more importantly, DOCKER_HOST
# *overrides* the active docker context — which is exactly what broke
# the previous version (it tried tcp://docker-build.haven:2375 instead
# of the SSH context). We drive everything through a context instead.
# *overrides* the active docker context/builder. Keep it unset so buildx
# talks to the SSH endpoint we specify below.
unset DOCKER_HOST || true
docker context rm -f remote-builder 2>/dev/null || true
docker context create remote-builder \
--docker "host=ssh://${BUILDER_USER}@${BUILDER_HOST}"
# build-push-action's `builder: remote-builder` needs a *buildx builder
# instance* named remote-builder, not just a context. Create it from the
# SSH context so it resolves to the remote engine over SSH.
# Create the buildx builder directly from the SSH endpoint. We do NOT
# create a docker context of the same name first: buildx refuses to
# create a builder instance whose name collides with an existing
# context ("instance name already exists as context builder").
docker buildx rm -f remote-builder 2>/dev/null || true
docker buildx create --name remote-builder --use remote-builder
docker context rm -f remote-builder 2>/dev/null || true
docker buildx create \
--name remote-builder \
--use \
"ssh://${BUILDER_USER}@${BUILDER_HOST}"
docker buildx inspect --bootstrap
- name: Generate tags list