ci: run the image smoke test in the job network

The job container cannot reach a port published on the Docker host loopback. Start the app in the job's network namespace and check it on localhost.
This commit is contained in:
vhaudiquet committed 2026-11-28 11:57:37 +01:00
1 parent 22c838eafe
commit 135dd3143c
1 file changed
+16 -2
+16 -2
View File
@@ -136,8 +136,22 @@ jobs:
run: | run: |
docker rm -f rhema-together-ci || true docker rm -f rhema-together-ci || true
trap 'docker rm -f rhema-together-ci || true' EXIT trap 'docker rm -f rhema-together-ci || true' EXIT
docker run -d --name rhema-together-ci \
-p 127.0.0.1:18000:7800 rhema-together:ci # The job runs in a container with the host Docker socket. A
# published port binds the host loopback, which the job cannot
# reach. Run the app in the job's network namespace instead.
job_container="$(hostname)"
if ! docker inspect "$job_container" >/dev/null 2>&1; then
job_container="$(docker ps --filter 'name=GITEA-ACTIONS-TASK' --format '{{.ID}}' | head -n1)"
fi
if [ -n "$job_container" ] && [ "$(docker inspect -f '{{.HostConfig.NetworkMode}}' "$job_container")" != "host" ]; then
network="container:${job_container}"
else
network="host"
fi
docker run -d --name rhema-together-ci --network "$network" \
-e TOGETHER_LISTEN=127.0.0.1:18000 rhema-together:ci
ok=0 ok=0
for i in $(seq 1 30); do for i in $(seq 1 30); do
if curl -fsS http://127.0.0.1:18000/api/bootstrap > /tmp/bootstrap.json; then if curl -fsS http://127.0.0.1:18000/api/bootstrap > /tmp/bootstrap.json; then