Skip to content

Commit b48d23d

Browse files
committed
fix(ci): decouple startup and improve healthcheck visibility
1 parent 93aa57c commit b48d23d

2 files changed

Lines changed: 18 additions & 18 deletions

File tree

.github/workflows/playwright.yml

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,28 +42,29 @@ jobs:
4242
- name: Wait for services to be healthy
4343
run: |
4444
echo "Waiting for services to become healthy..."
45-
# This command will wait for the healthchecks defined in docker-compose.yml to pass.
46-
# It will exit with an error if the services do not become healthy within the timeout.
47-
docker compose ps
4845
max_wait=300
4946
current_wait=0
5047
while [ $current_wait -lt $max_wait ]; do
51-
web_status=$(docker compose ps --format json web | jq -r '.[0].Health' 2>/dev/null || docker inspect -f '{{.State.Health.Status}}' $(docker compose ps -q web))
52-
firebird_status=$(docker compose ps --format json firebird | jq -r '.[0].Health' 2>/dev/null || docker inspect -f '{{.State.Health.Status}}' $(docker compose ps -q firebird))
48+
firebird_status=$(docker inspect --format='{{.State.Health.Status}}' $(docker compose ps -q firebird) 2>/dev/null || echo "starting")
49+
web_status=$(docker inspect --format='{{.State.Health.Status}}' $(docker compose ps -q web) 2>/dev/null || echo "starting")
5350
54-
if [ "$web_status" = "healthy" ] && [ "$firebird_status" = "healthy" ]; then
55-
echo "Services are healthy!"
51+
echo "Status: Firebird=$firebird_status, Web=$web_status (${current_wait}s)"
52+
53+
if [ "$firebird_status" = "healthy" ] && [ "$web_status" = "healthy" ]; then
54+
echo "All services are healthy!"
5655
exit 0
5756
fi
58-
echo "Waiting... Web: $web_status, Firebird: $firebird_status"
57+
5958
sleep 10
6059
current_wait=$((current_wait + 10))
6160
done
62-
echo "Services did not become healthy in time."
63-
echo "--- Firebird Healthcheck Logs ---"
64-
docker inspect --format='{{json .State.Health}}' $(docker compose ps -q firebird)
65-
echo "--- Web Healthcheck Logs ---"
66-
docker inspect --format='{{json .State.Health}}' $(docker compose ps -q web)
61+
62+
echo "ERROR: Services did not become healthy in time."
63+
echo "--- Firebird Detailed Status ---"
64+
docker inspect $(docker compose ps -q firebird)
65+
echo "--- Web Detailed Status ---"
66+
docker inspect $(docker compose ps -q web)
67+
echo "--- Container Logs ---"
6768
docker compose logs
6869
exit 1
6970

docker-compose.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ services:
77
FIREBIRD_ROOT_PASSWORD: test
88
FIREBIRD_DATABASE: test.fdb
99
healthcheck:
10-
test: ["CMD-SHELL", "/opt/firebird/bin/isql -user sysdba -password test 127.0.0.1:/var/lib/firebird/data/test.fdb -q -e 'quit;'"]
10+
test: ["CMD-SHELL", "timeout 1s bash -c ':> /dev/tcp/127.0.0.1/3050' || exit 1"]
1111
interval: 10s
12-
timeout: 10s
12+
timeout: 5s
1313
retries: 30
14-
start_period: 60s
14+
start_period: 30s
1515

1616
web:
1717
build:
@@ -22,8 +22,7 @@ services:
2222
volumes:
2323
- .:/var/www/html
2424
depends_on:
25-
firebird:
26-
condition: service_healthy
25+
- firebird
2726
healthcheck:
2827
test: ["CMD", "curl", "-f", "http://localhost/database.php"]
2928
interval: 10s

0 commit comments

Comments
 (0)