Files
ratebubble/scripts/startup.sh
2026-02-28 02:44:41 +03:00

31 lines
918 B
Bash
Executable File

#!/bin/sh
set -e
echo "=== Netflix Scraper API Startup ==="
# Set DATABASE_URL from individual POSTGRES_* environment variables
# This overrides the dummy value set during Docker build
export DATABASE_URL="postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DB}"
echo "Database URL configured: postgresql://${POSTGRES_USER}:***@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DB}"
# Wait for database to be ready
echo "Waiting for database..."
until nc -z $POSTGRES_HOST $POSTGRES_PORT; do
echo "Database not ready, waiting..."
sleep 2
done
echo "Database is ready!"
# Run migrations
echo "Running database migrations..."
npx prisma migrate deploy
# Run seed (optional, won't fail if already seeded)
echo "Running seed..."
npx tsx prisma/seed.ts || echo "Seed already run or not needed"
# Start the application
echo "Starting application..."
exec node dist/index.js