fix: use container IP instead of port mapping for health check
Docker Build and Push / lint (pull_request) Successful in 13s
Docker Build and Push / build (pull_request) Successful in 1m4s
Docker Build and Push / test (pull_request) Failing after 1h7m58s
Docker Build and Push / push (pull_request) Failing after 14m37s

When running inside Gitea Actions runner (Docker-in-Docker),
127.0.0.1:HOST_PORT doesn't work because the runner container
doesn't have access to the host's port mappings.
Use docker inspect to get the container's direct IP address.
This commit is contained in:
2026-06-08 16:46:13 +00:00
parent 97ccaee674
commit 268d8d2b62
+3 -3
View File
@@ -39,10 +39,10 @@ assert_match() {
echo "Running container: $IMAGE"
docker run -d --name "$CONTAINER_NAME" -p 0:8080 "$IMAGE" >/dev/null
HOST_PORT=$(docker port "$CONTAINER_NAME" 8080/tcp | head -1 | cut -d: -f2)
BASE_URL="http://127.0.0.1:${HOST_PORT}"
CONTAINER_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' "$CONTAINER_NAME")
BASE_URL="http://${CONTAINER_IP}:8080"
echo "Waiting for container (port $HOST_PORT)..."
echo "Waiting for container (ip $CONTAINER_IP)..."
for i in $(seq 1 30); do
if curl -sf "$BASE_URL/" >/dev/null 2>&1; then
echo "Container ready after ${i}s"