#!/command/with-contenv bash
# Runs on every container start (after DB/Redis are reachable on the Coolify network).
set -e

cd /var/www/html

# Storage symlink (idempotent)
php artisan storage:link 2>/dev/null || true

# Run pending migrations
php artisan migrate --force --no-interaction || true

# Cache config/routes/views for production speed
php artisan config:cache
php artisan route:cache
php artisan view:cache
