From ca1d3f504d1db78b2aa4b2f2e3e07a28d6888e56 Mon Sep 17 00:00:00 2001 From: Ashwin Kumar Sivakumar Date: Sun, 12 Jul 2026 18:28:17 +0530 Subject: [PATCH] fix(ci): detect docker gateway instead of hardcoding 127.0.0.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Every build on this branch has been failing with "Cannot connect to the Docker daemon at tcp://127.0.0.1:2375" — the job container is nested one level inside the runner pod's dind sidecar, so its own loopback isn't the sidecar's. nxtgauge-backend-rust already carries the fix (read the container's default-route gateway from /proc/net/route); porting the same step here. --- .forgejo/workflows/build.yaml | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/.forgejo/workflows/build.yaml b/.forgejo/workflows/build.yaml index 8ccb141..96b44cd 100644 --- a/.forgejo/workflows/build.yaml +++ b/.forgejo/workflows/build.yaml @@ -14,7 +14,6 @@ jobs: build: runs-on: docker-ready env: - DOCKER_HOST: tcp://127.0.0.1:2375 DOCKER_BUILDKIT: "1" steps: - name: Checkout @@ -22,6 +21,20 @@ jobs: with: fetch-depth: 0 + - name: Point DOCKER_HOST at this container's own gateway + run: | + set -euo pipefail + # 127.0.0.1 doesn't work: the job container is nested one level + # inside the runner pod's dind sidecar, so its own loopback isn't + # the sidecar's. Read the container's actual default-route gateway + # directly from /proc/net/route instead of relying on `ip`/`route` + # CLI tools being installed in the job image. + GATEWAY="$(awk '$2 == "00000000" {print $3}' /proc/net/route | head -1 | \ + sed -E 's/(..)(..)(..)(..)/0x\4 0x\3 0x\2 0x\1/' | \ + { read -r a b c d; printf '%d.%d.%d.%d' "$a" "$b" "$c" "$d"; })" + echo "Detected docker host gateway: $GATEWAY" + echo "DOCKER_HOST=tcp://$GATEWAY:2375" >> "$GITHUB_ENV" + - name: Set up Docker Buildx run: | set -euo pipefail