Skip to content

Commit e842a14

Browse files
committed
fix: use healthcheck for postgres instead of pinging
1 parent fd309d6 commit e842a14

2 files changed

Lines changed: 17 additions & 12 deletions

File tree

config/docker/docker-compose.yml

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ services:
1212
- "othello_pgdata:/var/lib/postgresql"
1313
networks:
1414
- othello_network
15+
healthcheck:
16+
test: ["CMD-SHELL", "pg_isready -U othello -d othello"]
17+
interval: 5s
18+
timeout: 5s
19+
retries: 5
1520
othello_redis:
1621
container_name: othello_redis
1722
image: redis:latest
@@ -28,8 +33,10 @@ services:
2833
ports:
2934
- "8000:8000"
3035
depends_on:
31-
- othello_postgres
32-
- othello_redis
36+
othello_postgres:
37+
condition: service_healthy
38+
othello_redis:
39+
condition: service_started
3340
volumes:
3441
- ../../:/app
3542
working_dir: /app
@@ -45,8 +52,10 @@ services:
4552
container_name: othello_celery
4653
image: othello_django
4754
depends_on:
48-
- othello_postgres
49-
- othello_redis
55+
othello_postgres:
56+
condition: service_healthy
57+
othello_redis:
58+
condition: service_started
5059
volumes:
5160
- ../../:/app
5261
working_dir: /app
@@ -62,8 +71,10 @@ services:
6271
container_name: othello_gamequeue
6372
image: othello_django
6473
depends_on:
65-
- othello_postgres
66-
- othello_redis
74+
othello_postgres:
75+
condition: service_healthy
76+
othello_redis:
77+
condition: service_started
6778
volumes:
6879
- ../../:/app
6980
working_dir: /app

config/docker/entrypoint.sh

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,6 @@ set -e
33

44
uv sync
55
uv run manage.py collectstatic --noinput
6-
7-
until (PGPASSWORD=pwd psql -h "othello_postgres" -U "othello" -c '\q') 2> /dev/null; do
8-
>&2 echo "waiting for postgres"
9-
sleep 1
10-
done
11-
126
uv run manage.py makemigrations --noinput
137
uv run manage.py migrate
148
uv run manage.py shell -c "

0 commit comments

Comments
 (0)