#!/usr/bin/env bash # ============================================================================== # Orfel Viz - Server Deployment Script (Ubuntu / Debian / Linux VPS) # ============================================================================== set -e echo "🚀 Deploying Orfel Viz..." # Check if Docker is available if command -v docker &> /dev/null && command -v docker compose &> /dev/null; then echo "🐳 Docker detected. Pulling and starting container..." docker compose down || true docker compose pull docker compose up -d echo "✅ Orfel Viz is running in Docker on port 3000!" echo "👉 Open http://localhost:3000 or http://:3000" exit 0 fi # Fallback: Native Node.js & PM2 setup echo "📦 Docker not found. Checking Node.js and FFmpeg..." if ! command -v ffmpeg &> /dev/null; then echo "Installing FFmpeg..." sudo apt-get update && sudo apt-get install -y ffmpeg fi if ! command -v node &> /dev/null; then echo "❌ Node.js is not installed. Please install Node.js 18+ first." exit 1 fi npm install --omit=dev if command -v pm2 &> /dev/null; then echo "Starting with PM2..." pm2 delete orfel-viz || true pm2 start server.mjs --name "orfel-viz" pm2 save echo "✅ Running with PM2!" else echo "Starting in background..." nohup node server.mjs > server.log 2>&1 & echo "✅ Server started in background (PID: $!). Logs in server.log" fi echo "🎉 Deployment complete!"