From fa6a5cdb8684d47bf50b33b506846449ff51669c Mon Sep 17 00:00:00 2001 From: Benjamin Bach Date: Wed, 24 Jul 2024 22:29:07 +0200 Subject: [PATCH] Revert healtcheck on Postgres, do it in the entrypoint --- docker-compose.yml | 11 ++--------- entrypoint.sh | 11 +++++++++++ 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index c957cd0..9bd0957 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,3 +1,4 @@ +--- services: app: build: @@ -11,8 +12,7 @@ services: volumes: - ./:/app/ depends_on: - postgres: - condition: service_healthy + - postgres env_file: - .env @@ -24,13 +24,6 @@ services: - 5432:5432 env_file: - .env - # This healthcheck has a large number of retries, this is currently based on the number of - # retries necessary to get the database running in GitHub Actions. - healthcheck: - test: [ "CMD-SHELL", "pg_isready -U postgres -d postgres" ] - interval: 5s - timeout: 5s - retries: 30 volumes: postgres_data: diff --git a/entrypoint.sh b/entrypoint.sh index 008f7be..9df57b6 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,5 +1,16 @@ #!/bin/sh +echo "Waiting for postgres..." + +POSTGRES_PORT=${POSTGRES_PORT:-5432} +POSTGRES_HOST=${POSTGRES_HOST:-localhost} + +while ! nc -z "$POSTGRES_HOST" "$POSTGRES_PORT"; do + sleep 0.1 +done + +echo "PostgreSQL started" + # Only migrate, collectstatic and compilemessages if we are NOT in development if [ -z "$DEBUG" ]; then python src/manage.py migrate;