diff --git a/build-and-push/action.yaml b/build-and-push/action.yaml index 8cdd83d..f1f1c0e 100644 --- a/build-and-push/action.yaml +++ b/build-and-push/action.yaml @@ -63,22 +63,35 @@ runs: shell: bash env: SSH_KEY: ${{ inputs.ssh_key }} - DOCKER_HOST: ${{ inputs.docker_host }} + BUILDER_HOST: ${{ inputs.docker_host }} run: | mkdir -p ~/.ssh echo "${SSH_KEY}" > ~/.ssh/id_ed25519 chmod 600 ~/.ssh/id_ed25519 - ssh-keyscan "${DOCKER_HOST}" >> ~/.ssh/known_hosts + ssh-keyscan "${BUILDER_HOST}" >> ~/.ssh/known_hosts - name: Set up remote Docker Buildx builder shell: bash env: - DOCKER_HOST: ${{ inputs.docker_host }} - DOCKER_USER: ${{ inputs.docker_user }} + BUILDER_HOST: ${{ inputs.docker_host }} + BUILDER_USER: ${{ inputs.docker_user }} 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. + unset DOCKER_HOST || true + + docker context rm -f remote-builder 2>/dev/null || true docker context create remote-builder \ - --docker "host=ssh://${DOCKER_USER}@${DOCKER_HOST}" - docker context use 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. + docker buildx rm -f remote-builder 2>/dev/null || true + docker buildx create --name remote-builder --context remote-builder --use docker buildx inspect --bootstrap - name: Generate tags list