#!/bin/bash
set -e

echo "Entrypoint started"

# Wait for Postgres to be ready
until pg_isready -h postgres -p 5432 -U taf; do
  echo "Waiting for Postgres..."
  sleep 2
done

echo "Postgres is ready."

# Run deploy.sh
cd /var/www/html
./deploy.sh

# Start Apache
exec apache2-foreground
