ci: adapt to full-dind runner — drop dind service, resolve daemon endpoint

This commit is contained in:
2026-09-19 07:53:22 +00:00
parent 775b0e479a
commit 47381f2011
+60 -21
View File
@@ -11,37 +11,76 @@ jobs:
ci: ci:
name: build + unit + e2e name: build + unit + e2e
runs-on: ubuntu-latest runs-on: ubuntu-latest
services:
docker:
image: docker:dind
ports:
- "2375:2375"
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
# Resolve the dind daemon endpoint up front (fail fast if the runner's dind is # Full-dind runner: job containers already reach the runner's own docker daemon
# misconfigured). Gitea Actions services are sibling containers on the job network, # (pre-set DOCKER_HOST and/or a mounted /var/run/docker.sock) — no dind service.
# reachable by service id; depending on runner config published ports may also land # Resolve which endpoint works, export it as DOCKER_HOST, and derive E2E_BASE_URL
# on localhost — try both and export whichever answers. The app URL follows the same # from it: for tcp/https endpoints published ports live on that host; for a unix
# endpoint: the flight container's port 3000 is published inside dind, so it is # socket the daemon sits on the job's docker bridge, so its published ports are
# reachable wherever the daemon itself is. # reached via the default gateway.
- name: Resolve dind endpoint - name: Resolve dind endpoint
run: | run: |
for host in tcp://localhost:2375 tcp://docker:2375; do set -u
for i in $(seq 1 15); do
if DOCKER_HOST="$host" docker version --format '{{.Server.Version}}' >/dev/null 2>&1; then derive_url() {
echo "DOCKER_HOST=$host" >> "$GITHUB_ENV" ep="$1"
case "$host" in case "$ep" in
*localhost*) echo "E2E_BASE_URL=http://localhost:3000" >> "$GITHUB_ENV" ;; unix://*)
*) echo "E2E_BASE_URL=http://docker:3000" >> "$GITHUB_ENV" ;; gw=$(ip route show default 2>/dev/null | awk '{print $3; exit}')
esac if [ -z "${gw:-}" ]; then
echo "::error::unix-socket daemon but no default gateway found (needed to reach published ports)" >&2
return 1
fi
echo "http://$gw:3000" ;;
tcp://*|https://*)
hostpart=$(printf '%s' "$ep" | sed -e 's|^[a-z]*://||')
hostpart=${hostpart%%:*}
if [ -z "$hostpart" ]; then return 1; fi
echo "http://$hostpart:3000" ;;
*)
echo "::error::cannot derive app URL from endpoint '$ep'" >&2
return 1 ;;
esac
}
# 1) A pre-set DOCKER_HOST that answers is used as-is, no probing.
if [ -n "${DOCKER_HOST:-}" ]; then
i=0
while [ "$i" -lt 5 ]; do
if docker version --format '{{.Server.Version}}' >/dev/null 2>&1; then
url=$(derive_url "$DOCKER_HOST") || exit 1
echo "using pre-set DOCKER_HOST=$DOCKER_HOST (E2E_BASE_URL=$url)"
echo "DOCKER_HOST=$DOCKER_HOST" >> "$GITHUB_ENV"
echo "E2E_BASE_URL=$url" >> "$GITHUB_ENV"
exit 0 exit 0
fi fi
sleep 2 i=$((i+1)); sleep 2
done
fi
# 2) Otherwise probe candidates in order (short retry each).
tried=""
for ep in "${DOCKER_HOST:-}" unix:///var/run/docker.sock tcp://localhost:2375 tcp://localhost:2376 tcp://docker:2375 tcp://docker:2376; do
[ -n "$ep" ] || continue
case " $tried " in *" $ep "*) continue ;; esac
tried="$tried $ep"
i=0
while [ "$i" -lt 10 ]; do
if DOCKER_HOST="$ep" docker version --format '{{.Server.Version}}' >/dev/null 2>&1; then
url=$(derive_url "$ep") || exit 1
echo "using probed endpoint $ep (E2E_BASE_URL=$url)"
echo "DOCKER_HOST=$ep" >> "$GITHUB_ENV"
echo "E2E_BASE_URL=$url" >> "$GITHUB_ENV"
exit 0
fi
i=$((i+1)); sleep 2
done done
done done
echo "::error::no reachable dind endpoint (tried tcp://localhost:2375 and tcp://docker:2375)" >&2
echo "::error::no reachable docker daemon (tried: ${DOCKER_HOST:-<unset>}, unix:///var/run/docker.sock, tcp://localhost:2375, tcp://localhost:2376, tcp://docker:2375, tcp://docker:2376)" >&2
exit 1 exit 1
- name: Setup Node - name: Setup Node