fix: use container IP instead of port mapping for health check
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:
+3
-3
@@ -39,10 +39,10 @@ assert_match() {
|
|||||||
echo "Running container: $IMAGE"
|
echo "Running container: $IMAGE"
|
||||||
docker run -d --name "$CONTAINER_NAME" -p 0:8080 "$IMAGE" >/dev/null
|
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)
|
CONTAINER_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' "$CONTAINER_NAME")
|
||||||
BASE_URL="http://127.0.0.1:${HOST_PORT}"
|
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
|
for i in $(seq 1 30); do
|
||||||
if curl -sf "$BASE_URL/" >/dev/null 2>&1; then
|
if curl -sf "$BASE_URL/" >/dev/null 2>&1; then
|
||||||
echo "Container ready after ${i}s"
|
echo "Container ready after ${i}s"
|
||||||
|
|||||||
Reference in New Issue
Block a user