#!/bin/bash set -e echo "Waiting for PostgreSQL to be ready..." while ! pg_isready -h db -U ${POSTGRES_USER:-postgres} -d ${POSTGRES_DB:-Zoneco_ORG}; do echo "PostgreSQL is unavailable - sleeping" sleep 1 done echo "PostgreSQL is up - executing command" # Collect static files echo "Collecting static files..." python manage.py collectstatic --noinput # Run migrations echo "Running migrations..." python manage.py migrate --noinput # Create superuser if it doesn't exist (optional, can be removed in production) # Uncomment and modify if needed: # echo "from django.contrib.auth import get_user_model; User = get_user_model(); User.objects.filter(username='admin').exists() or User.objects.create_superuser('admin', 'admin@example.com', 'admin')" | python manage.py shell echo "Starting application..." exec "$@"