Skip to content

Commit 42f7e17

Browse files
JOYclaude
andcommitted
ci: Add healthchecks for zero-downtime deploys
- db: pg_isready - redis-db: redis-cli ping - backend: curl /api/v2/stats (start_period: 60s for migrations) - frontend: curl localhost:3000 (start_period: 30s) - caddy: depends_on backend+frontend service_healthy - backend depends_on db+redis service_healthy Services start in correct order and Caddy only routes traffic when backend/frontend are confirmed healthy. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 17dfca7 commit 42f7e17

1 file changed

Lines changed: 32 additions & 5 deletions

File tree

docker-compose/docker-compose-mainnet.yml

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ services:
1414
command: redis-server
1515
volumes:
1616
- redis_data:/data
17+
healthcheck:
18+
test: ["CMD", "redis-cli", "ping"]
19+
interval: 15s
20+
timeout: 5s
21+
retries: 3
1722

1823
db-init:
1924
image: postgres:15
@@ -43,14 +48,21 @@ services:
4348
- "127.0.0.1:7432:5432"
4449
volumes:
4550
- postgres_data:/var/lib/postgresql/data
51+
healthcheck:
52+
test: ["CMD-SHELL", "pg_isready -U postgres"]
53+
interval: 15s
54+
timeout: 5s
55+
retries: 5
4656

4757
# ==========================================================================
4858
# Backend - Blockscout Latest
4959
# ==========================================================================
5060
backend:
5161
depends_on:
52-
- db
53-
- redis-db
62+
db:
63+
condition: service_healthy
64+
redis-db:
65+
condition: service_healthy
5466
image: doscan-backend:latest
5567
pull_policy: never
5668
restart: always
@@ -65,13 +77,20 @@ services:
6577
- db:database
6678
ports:
6779
- "127.0.0.1:4000:4000"
80+
healthcheck:
81+
test: ["CMD", "curl", "-f", "http://localhost:4000/api/v2/stats"]
82+
interval: 30s
83+
timeout: 10s
84+
retries: 5
85+
start_period: 60s
6886

6987
# ==========================================================================
7088
# Frontend - Blockscout Latest
7189
# ==========================================================================
7290
frontend:
7391
depends_on:
74-
- backend
92+
backend:
93+
condition: service_healthy
7594
image: doscan-frontend:latest
7695
pull_policy: never
7796
restart: always
@@ -80,6 +99,12 @@ services:
8099
- ./envs/common-frontend.env
81100
ports:
82101
- "127.0.0.1:3000:3000"
102+
healthcheck:
103+
test: ["CMD", "curl", "-f", "http://localhost:3000"]
104+
interval: 30s
105+
timeout: 10s
106+
retries: 3
107+
start_period: 30s
83108

84109
# ==========================================================================
85110
# Microservices
@@ -171,8 +196,10 @@ services:
171196
# ==========================================================================
172197
caddy:
173198
depends_on:
174-
- backend
175-
- frontend
199+
backend:
200+
condition: service_healthy
201+
frontend:
202+
condition: service_healthy
176203
image: caddy:latest
177204
container_name: caddy
178205
restart: always

0 commit comments

Comments
 (0)