Second failure mode: act_runner executes job steps in executor containers running with network=host (despite container.network config — that only applies to job containers). The buildx CLI therefore resolves tcp://buildkitd:8375 in the HOST namespace, where docker DNS names do not resolve. Fix: publish buildkitd's TCP port to host loopback (-p 127.0.0.1:8375:8375) and use tcp://127.0.0.1:8375 as the endpoint. Works from both host-network executors and job containers; port is not exposed on any external interface. Validated on oracle: buildx remote Status running, platforms linux/arm64,v7,v6.
58 lines
2.2 KiB
YAML
58 lines
2.2 KiB
YAML
name: 'Setup BuildKit (with labels)'
|
|
description: 'Idempotently start a labeled buildkitd container and point buildx at it via the remote driver. The default docker-container driver cannot set container labels, and the Docker API has no PATCH-labels for existing containers — so we manage the container ourselves and Watchtower/Dockhand see the labels.'
|
|
inputs:
|
|
container_name:
|
|
description: 'Name of the buildkitd container'
|
|
required: false
|
|
default: 'buildkitd'
|
|
image:
|
|
description: 'BuildKit image'
|
|
required: false
|
|
default: 'moby/buildkit:buildx-stable-1'
|
|
monitor_only:
|
|
description: 'Value for com.centurylinklabs.watchtower.monitor-only'
|
|
required: false
|
|
default: 'false'
|
|
dockhand_notify:
|
|
description: 'Value for dockhand.notify'
|
|
required: false
|
|
default: 'false'
|
|
cleanup:
|
|
description: 'Stop the buildkitd container after the job (idle cleanup; container restarts on demand on the next run)'
|
|
required: false
|
|
default: 'true'
|
|
network:
|
|
description: 'Docker network for the buildkitd container — MUST match the network the job containers run on, otherwise the name is unresolvable'
|
|
required: false
|
|
default: 'git_default'
|
|
port:
|
|
description: 'TCP port buildkitd listens on'
|
|
required: false
|
|
default: '8375'
|
|
|
|
runs:
|
|
using: 'composite'
|
|
steps:
|
|
- name: Start BuildKit container (with labels)
|
|
shell: bash
|
|
run: |
|
|
docker ps -a --format '{{.Names}}' | grep -qx '${{ inputs.container_name }}' || \
|
|
docker run -d --name ${{ inputs.container_name }} --privileged \
|
|
--network ${{ inputs.network }} \
|
|
-p 127.0.0.1:${{ inputs.port }}:${{ inputs.port }} \
|
|
--restart unless-stopped \
|
|
--label com.centurylinklabs.watchtower.monitor-only=${{ inputs.monitor_only }} \
|
|
--label dockhand.notify=${{ inputs.dockhand_notify }} \
|
|
${{ inputs.image }} --addr tcp://0.0.0.0:${{ inputs.port }}
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v4
|
|
with:
|
|
driver: remote
|
|
endpoint: tcp://127.0.0.1:${{ inputs.port }}
|
|
|
|
- name: Stop BuildKit (idle cleanup)
|
|
if: ${{ inputs.cleanup == 'true' && always() }}
|
|
shell: bash
|
|
run: docker stop ${{ inputs.container_name }} || true
|