#!/bin/bash

echo "Waiting for database..."
while ! nc -z db 5432; do
  sleep 0.1
done
echo "Database is ready!"

echo "Waiting for Redis..."
while ! nc -z redis 6379; do
  sleep 0.1
done
echo "Redis is ready!"

echo "Running database migrations..."
flask db upgrade

echo "Creating admin user..."
flask create-admin

echo "Starting application..."
exec "$@" 