Edit: /opt/mawid/deploy.sh (789B)
#!/usr/bin/env bash
# Deploy to the VPS (PROJECT_PLAN Phase 7 task 5).
# Usage: ./deploy.sh [.env.production|.env.staging] (default .env.production)
set -euo pipefail
cd "$(dirname "$0")"
ENV_FILE=${1:-.env.production}
[ -f "$ENV_FILE" ] || { echo "missing $ENV_FILE — copy .env.example and fill it in"; exit 1; }
COMPOSE=(docker compose --env-file "$ENV_FILE" -f docker-compose.yml -f docker-compose.prod.yml)
git pull --ff-only
"${COMPOSE[@]}" build
"${COMPOSE[@]}" up -d postgres redis
"${COMPOSE[@]}" up -d api dashboard caddy
# Apply pending migrations with the CLI bundled in the api image.
"${COMPOSE[@]}" exec -T api node node_modules/prisma/build/index.js migrate deploy \
--schema packages/db/prisma/schema.prisma
"${COMPOSE[@]}" ps
echo "deploy complete ($ENV_FILE)"