Skip to content

Commit 64cc781

Browse files
committed
chore: make health checks robuster
1 parent f42f218 commit 64cc781

3 files changed

Lines changed: 30 additions & 12 deletions

File tree

.github/workflows/docker-compose-integration.yml

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,18 @@ jobs:
2424
- name: Wait for services to be healthy
2525
run: |
2626
echo "Waiting for all services to be healthy..."
27-
# Wait for services with health checks to be healthy (4 services) and all services to be up
28-
timeout 300 bash -c 'until [ $(docker compose ps --format "{{.Health}}" | grep -c "healthy") -ge 4 ] && [ $(docker compose ps --format "{{.Status}}" | grep -c "Up") -ge 5 ]; do sleep 5; done'
27+
# Wait for services with health checks to be healthy (7 services) and all services to be up
28+
# Increased timeout to 10 minutes for CI environment
29+
timeout 600 bash -c 'while true; do
30+
healthy_count=$(docker compose ps --format "{{.Health}}" | grep -c "healthy" || echo "0")
31+
up_count=$(docker compose ps --format "{{.Status}}" | grep -c "Up" || echo "0")
32+
echo "Progress: $healthy_count/7 healthy, $up_count services up"
33+
if [ "$healthy_count" -ge 7 ] && [ "$up_count" -ge 7 ]; then
34+
echo "All services are healthy!"
35+
break
36+
fi
37+
sleep 5
38+
done'
2939
docker compose ps
3040
3141
- name: Test dashboard endpoints
@@ -45,15 +55,12 @@ jobs:
4555
run: |
4656
echo "=== Docker Compose Services Status ==="
4757
docker compose ps
48-
echo "=== Traefik Logs ==="
49-
docker compose logs traefik
50-
echo "=== Sticker Award Logs ==="
51-
docker compose logs sticker-award
52-
echo "=== User Management Logs ==="
53-
docker compose logs user-management
54-
echo "=== Database Logs ==="
55-
docker compose logs sticker-award-db
56-
docker compose logs user-management-db
58+
echo "=== All Service Logs ==="
59+
docker compose logs --tail=50
60+
echo "=== Health Check Details ==="
61+
docker compose ps --format "table {{.Name}}\t{{.Status}}\t{{.Health}}"
62+
echo "=== Resource Usage ==="
63+
docker stats --no-stream
5764
5865
- name: Cleanup
5966
if: always()

docker-compose.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,11 @@ services:
185185
QUARKUS_S3_AWS_CREDENTIALS_STATIC_PROVIDER_SECRET_ACCESS_KEY: minioadmin
186186
QUARKUS_S3_PATH_STYLE_ACCESS: "true"
187187
STICKER_IMAGES_BUCKET: sticker-images
188+
healthcheck:
189+
test: ["CMD", "curl", "-f", "http://localhost:8080/health"]
190+
interval: 10s
191+
timeout: 5s
192+
retries: 5
188193
labels:
189194
- "traefik.enable=true"
190195
- "traefik.http.routers.sticker-award.rule=PathPrefix(`/api/award`)"
@@ -210,6 +215,11 @@ services:
210215
KAFKA__BOOTSTRAPSERVERS: "redpanda:9092"
211216
KAFKA__SCHEMAREGISTRY: "http://redpanda:8082"
212217
KAFKA__GROUPID: "stickerlandia-user-management"
218+
healthcheck:
219+
test: ["CMD", "curl", "-f", "http://localhost:8080/api/users/v1/health"]
220+
interval: 10s
221+
timeout: 5s
222+
retries: 5
213223
labels:
214224
- "traefik.enable=true"
215225
- "traefik.http.routers.user-management.rule=PathPrefix(`/api/users`)"

user-management/src/Stickerlandia.UserManagement.Api/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ COPY . ./
1212
# Publish the application
1313
RUN dotnet publish src/Stickerlandia.UserManagement.Api/Stickerlandia.UserManagement.Api.csproj -o out -c Release -r linux-arm64
1414

15-
FROM mcr.microsoft.com/dotnet/aspnet:8.0-noble-chiseled AS runtime
15+
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS runtime
16+
RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/*
1617
WORKDIR /App
1718
COPY --from=build /App/out .
1819
EXPOSE 80

0 commit comments

Comments
 (0)