Revert healtcheck on Postgres, do it in the entrypoint

This commit is contained in:
Benjamin Bach 2024-07-24 22:29:07 +02:00
parent 250f203900
commit fa6a5cdb86
No known key found for this signature in database
GPG key ID: 486F0D69C845416E
2 changed files with 13 additions and 9 deletions

View file

@ -1,3 +1,4 @@
---
services: services:
app: app:
build: build:
@ -11,8 +12,7 @@ services:
volumes: volumes:
- ./:/app/ - ./:/app/
depends_on: depends_on:
postgres: - postgres
condition: service_healthy
env_file: env_file:
- .env - .env
@ -24,13 +24,6 @@ services:
- 5432:5432 - 5432:5432
env_file: env_file:
- .env - .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: volumes:
postgres_data: postgres_data:

View file

@ -1,5 +1,16 @@
#!/bin/sh #!/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 # Only migrate, collectstatic and compilemessages if we are NOT in development
if [ -z "$DEBUG" ]; then if [ -z "$DEBUG" ]; then
python src/manage.py migrate; python src/manage.py migrate;