VigilanzaTurni/deploy/deploy.sh
marco370 5a51a65218 Add deployment guide and scripts for automated server setup and deployment
Adds a comprehensive DEPLOYMENT.md guide, a setup-server.sh script for AlmaLinux 9 to install Node.js, PostgreSQL, Nginx, and PM2, a deploy.sh script for CI/CD deployment, an nginx.conf for server configuration, and a push-to-gitlab.sh helper script for Replit integration.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 99f0fce6-9386-489a-9632-1d81223cab44
Replit-Commit-Checkpoint-Type: intermediate_checkpoint
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/6d543d2c-20b9-4ea6-93fe-70fe9b1d9f80/99f0fce6-9386-489a-9632-1d81223cab44/H8Wilyj
2025-10-16 07:12:27 +00:00

54 lines
1.2 KiB
Bash
Executable File

#!/bin/bash
set -e
# Script di deployment automatico per VigilanzaTurni
# Eseguito da GitLab CI/CD Runner
APP_DIR="/var/www/vigilanza-turni"
APP_NAME="vigilanza-turni"
echo "🚀 Deployment VigilanzaTurni - $(date)"
# Vai alla directory applicazione
cd $APP_DIR
# Pull ultime modifiche (già fatto da GitLab Runner)
echo "📦 Repository aggiornato"
# Installa dipendenze
echo "📥 Installazione dipendenze..."
npm ci --production
# Build frontend
echo "🏗️ Build frontend Vite..."
export NODE_ENV=production
npm run build
# Database migrations (se necessario)
echo "🗄️ Verifica database schema..."
npm run db:push || true
# Restart applicazione con PM2
echo "🔄 Restart applicazione..."
if pm2 show $APP_NAME > /dev/null 2>&1; then
pm2 reload $APP_NAME --update-env
else
pm2 start npm --name $APP_NAME -- start
pm2 save
fi
# Health check
echo "🏥 Health check..."
sleep 5
if pm2 show $APP_NAME | grep -q "online"; then
echo "✅ Deployment completato con successo!"
pm2 logs $APP_NAME --lines 20 --nostream
else
echo "❌ Errore: applicazione non online"
pm2 logs $APP_NAME --lines 50 --nostream
exit 1
fi
echo "📊 Status PM2:"
pm2 status