Skip to content

Commit b6ecccd

Browse files
authored
🩺 Add DB healthcheck (fastapi#1342)
1 parent 0cd832d commit b6ecccd

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

docker-compose.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@ services:
22
db:
33
image: postgres:12
44
restart: always
5+
healthcheck:
6+
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}"]
7+
interval: 10s
8+
retries: 5
9+
start_period: 30s
10+
timeout: 10s
511
volumes:
612
- app-db-data:/var/lib/postgresql/data/pgdata
713
env_file:
@@ -42,7 +48,9 @@ services:
4248
- traefik-public
4349
- default
4450
depends_on:
45-
- db
51+
db:
52+
condition: service_healthy
53+
restart: true
4654
env_file:
4755
- .env
4856
environment:

0 commit comments

Comments
 (0)