Skip to content

Commit b3e0687

Browse files
authored
Merge pull request #1172 from AlexandreCarlton/wait-for-postgres-to-be-ready-in-compose
Ensure `db` is ready to accept connections prior to migration
2 parents ac05b6e + 81b2917 commit b3e0687

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

docker-compose.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ services:
1414
POSTGRES_DB: ${POSTGRES_DB:-pokeapi}
1515
volumes:
1616
- pg_data:/var/lib/postgresql/data
17+
healthcheck:
18+
test: pg_isready
19+
interval: 1s
20+
timeout: 5s
21+
retries: 10
1722
restart: always
1823

1924
app:
@@ -28,8 +33,10 @@ services:
2833
- db
2934
- cache
3035
depends_on:
31-
- db
32-
- cache
36+
db:
37+
condition: service_healthy
38+
cache:
39+
condition: service_started
3340
restart: always
3441

3542
web:

0 commit comments

Comments
 (0)