Files

26 lines
658 B
Bash
Executable File

#!/usr/bin/env bash
# Start the full production stack on this box.
set -euo pipefail
cd "$(dirname "$0")/.."
# 1. DB up (idempotent)
docker compose up -d db
# 2. Wait for DB to be healthy
for i in $(seq 1 30); do
if docker exec crm_omt_db pg_isready -U postgres -d crm_omt >/dev/null 2>&1; then
break
fi
sleep 1
done
# 3. Build frontend (no-op if dist/ already current; safe to re-run)
if [ ! -d dist ] || [ -n "$(find src -newer dist -type f -print -quit 2>/dev/null)" ]; then
echo "[prod] building frontend..."
npm run build
fi
# 4. Start API in production mode (foreground; use a process manager for restart)
cd server
node src/index.js