diff --git a/docker-compose.yml b/docker-compose.yml index 4cd7b1f..4f45b92 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,3 +8,11 @@ services: command: gunicorn tldtest.wsgi:application --bind 0.0.0.0:8000 --timeout 600 ports: - 8000:8000 + depends_on: + - db + db: + image: postgres:15 + volumes: + - postgres_data:/var/lib/postgresql/data/ +volumes: + postgres_data: diff --git a/entrypoint.sh b/entrypoint.sh index 2a65464..575d9a2 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,5 +1,17 @@ #!/bin/sh +if [ "$DATABASE" = "postgres" ] +then + echo "Waiting for postgres..." + + while ! nc -z $SQL_HOST $SQL_PORT; do + sleep 0.1 + done + + echo "PostgreSQL started" +fi + + python manage.py makemigrations # Make migrations python manage.py migrate # Apply database migrations python manage.py collectstatic