#!/bin/sh
set -e

echo "Waiting for postgres..."
while ! nc -z ${DB_HOST:-postgres} ${DB_PORT:-5432}; do
  sleep 0.5
done
echo "PostgreSQL started"

echo "Running migrations..."
python manage.py migrate --no-input

echo "Collecting static files..."
python manage.py collectstatic --no-input --clear

exec "$@"
