#!/bin/bash set -e DB_HOST="${POSTGRES_HOST:-db}" DB_USER="${POSTGRES_USER:-postgres}" DB_NAME="${POSTGRES_DB:-Zoneco_ORG}" echo "Waiting for PostgreSQL to be ready at ${DB_HOST}..." while ! pg_isready -h "${DB_HOST}" -U "${DB_USER}" -d "${DB_NAME}"; do echo "PostgreSQL is unavailable - sleeping" sleep 1 done echo "PostgreSQL is up" echo "Collecting static files..." python manage.py collectstatic --noinput echo "Running migrations..." python manage.py migrate --noinput # Create/update admin from environment variables (no hardcoded credentials). # Set ADMIN_USERNAME and ADMIN_PASSWORD in the server .env / compose env. if [ -n "${ADMIN_USERNAME:-}" ] && [ -n "${ADMIN_PASSWORD:-}" ]; then echo "Ensuring admin user from environment variables..." python manage.py shell <