/home/techb158/cosmic-risk.abdallabala.com/scripts
NameSizeModeActions
auto-deploy.sh21450644editdlrm
backup-db.sh11030644editdlrm
check-config.js10810644editdlrm
create-users.js17280644editdlrm
deploy-prod.sh27090644editdlrm
monitor-health.sh14850644editdlrm
run-scheduled-reports.js17240644editdlrm
setup-backup-cron.sh11890644editdlrm
setup-monitoring-cron.sh5920644editdlrm
setup-supabase.sh12800644editdlrm
Edit: /home/techb158/cosmic-risk.abdallabala.com/scripts/deploy-prod.sh (2709B)
#!/usr/bin/env bash set -euo pipefail # COSMIC AI-Risk — Production Deployment Script # Run this on your VPS after cloning/uploading the saas-app directory # # Prerequisites: # - Docker + Docker Compose installed # - Cloudflare Tunnel configured (points to http://localhost:8092) # - .env file created from .env.production template with secrets filled in APP_DIR="$(cd "$(dirname "$0")/.." && pwd)" cd "$APP_DIR" echo "=== COSMIC AI-Risk Production Deploy ===" echo "" # 1. Check prerequisites if ! command -v docker &>/dev/null; then echo "ERROR: Docker not found"; exit 1; fi if ! command -v docker-compose &>/dev/null && ! docker compose version &>/dev/null; then echo "ERROR: Docker Compose not found"; exit 1 fi if [ ! -f .env ]; then echo "ERROR: .env file not found. Create from .env.production"; exit 1; fi # Determine compose command COMPOSE="docker-compose" if docker compose version &>/dev/null; then COMPOSE="docker compose"; fi # 2. Pull latest images echo "→ Pulling base images..." docker pull node:20-bookworm-slim docker pull postgres:16-alpine docker pull redis:7-alpine # 3. Build and start echo "→ Building application..." $COMPOSE -f docker-compose.prod.yml build --pull app echo "→ Starting services..." $COMPOSE -f docker-compose.prod.yml up -d # 4. Wait for database echo "→ Waiting for database..." until $COMPOSE -f docker-compose.prod.yml exec -T postgres pg_isready -U cosmic -d cosmic_saas 2>/dev/null; do sleep 2 done echo "✓ Database ready" # 5. Push schema and seed echo "→ Running schema migration..." $COMPOSE -f docker-compose.prod.yml exec -T app npx prisma db push --accept-data-loss echo "→ Seeding database..." $COMPOSE -f docker-compose.prod.yml exec -T app node prisma/seed.js # 6. Health check echo "→ Waiting for app to be ready..." sleep 5 HEALTH=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:8092/api/health 2>/dev/null || echo "000") if [ "$HEALTH" = "200" ]; then echo "✓ App is healthy (HTTP $HEALTH)" else echo "⚠ App health check returned HTTP $HEALTH — check logs: $COMPOSE logs app" fi echo "" echo "=== Deploy Complete ===" echo "App: https://balavpn.abdallabala.com" echo "Login: super-owner@cosmic.local / cosmic123" echo "" echo "Management:" echo " Logs: $COMPOSE -f docker-compose.prod.yml logs -f" echo " Restart: $COMPOSE -f docker-compose.prod.yml restart" echo " Stop: $COMPOSE -f docker-compose.prod.yml down" echo " Update: $COMPOSE -f docker-compose.prod.yml pull && $COMPOSE -f docker-compose.prod.yml up -d --build" echo " DB backup: $COMPOSE -f docker-compose.prod.yml exec postgres pg_dump -U cosmic cosmic_saas > backup_\$(date +%Y%m%d).sql"