Update deployment documentation and scripts to deploy to vt.alfacom.it, remove Replit references, and simplify the deployment workflow to two commands: `./push-to-gitlab.sh` and `bash deploy/deploy.sh`, including automated database backups. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 42d8028a-fa71-4ec2-938c-e43eedf7df01 Replit-Commit-Checkpoint-Type: intermediate_checkpoint
174 lines
3.3 KiB
Markdown
174 lines
3.3 KiB
Markdown
# 🚀 Quick Start - Deployment VigilanzaTurni
|
||
|
||
Guida rapida per deployment: Replit → GitLab → vt.alfacom.it
|
||
|
||
## 📝 Checklist Pre-Deployment
|
||
|
||
- [ ] Server AlmaLinux 9 disponibile (min 2GB RAM)
|
||
- [ ] Dominio vt.alfacom.it configurato
|
||
- [ ] Account GitLab
|
||
- [ ] SSH access al server
|
||
|
||
---
|
||
|
||
## ⚡ Setup Iniziale (15 minuti)
|
||
|
||
### 1️⃣ Setup Server (5 min)
|
||
|
||
```bash
|
||
# SSH nel server
|
||
ssh root@vt.alfacom.it
|
||
|
||
# Clone repository
|
||
cd /var/www
|
||
git clone https://git.alfacom.it/marco/VigilanzaTurni.git vigilanza-turni
|
||
cd vigilanza-turni
|
||
|
||
# Esegui setup automatico
|
||
sudo bash deploy/setup-server.sh
|
||
```
|
||
|
||
Lo script installa automaticamente:
|
||
- Node.js 20
|
||
- PostgreSQL 15 (con password: 553da84c94093919d46055d6ec37dfa2a03d0f46)
|
||
- PM2
|
||
- Nginx
|
||
- Certbot (SSL)
|
||
|
||
### 2️⃣ Configura Nginx (2 min)
|
||
|
||
```bash
|
||
# Copia configurazione Nginx
|
||
sudo cp deploy/nginx.conf /etc/nginx/conf.d/vigilanza-turni.conf
|
||
|
||
# Test e reload
|
||
sudo nginx -t
|
||
sudo systemctl reload nginx
|
||
|
||
# SSL Certificate
|
||
sudo certbot --nginx -d vt.alfacom.it
|
||
```
|
||
|
||
### 3️⃣ Configura .env (2 min)
|
||
|
||
```bash
|
||
cd /var/www/vigilanza-turni
|
||
|
||
# Crea .env produzione
|
||
cp .env.production.example .env
|
||
nano .env
|
||
```
|
||
|
||
**Inserisci in .env:**
|
||
```bash
|
||
DATABASE_URL=postgresql://vigilanza_user:553da84c94093919d46055d6ec37dfa2a03d0f46@localhost:5432/vigilanza_turni
|
||
SESSION_SECRET=$(openssl rand -base64 32)
|
||
NODE_ENV=production
|
||
PORT=5000
|
||
APP_URL=https://vt.alfacom.it
|
||
BACKUP_ENABLED=true
|
||
BACKUP_DIR=/var/backups/vigilanza-turni
|
||
```
|
||
|
||
### 4️⃣ Primo Deploy (2 min)
|
||
|
||
```bash
|
||
cd /var/www/vigilanza-turni
|
||
bash deploy/deploy.sh
|
||
```
|
||
|
||
---
|
||
|
||
## 🔄 Workflow Quotidiano
|
||
|
||
### Deploy in 2 Comandi
|
||
|
||
**Da Replit o locale:**
|
||
|
||
```bash
|
||
# 1. Push a GitLab
|
||
./push-to-gitlab.sh
|
||
|
||
# 2. Sul server: Deploy
|
||
ssh root@vt.alfacom.it "cd /var/www/vigilanza-turni && bash deploy/deploy.sh"
|
||
```
|
||
|
||
**Il deploy automaticamente:**
|
||
- ✅ Esegue backup database
|
||
- ✅ Pull ultime modifiche da GitLab
|
||
- ✅ Build frontend Vite
|
||
- ✅ Esegue migrations database
|
||
- ✅ Restart applicazione PM2
|
||
- ✅ Health check
|
||
|
||
---
|
||
|
||
## 📊 Comandi Utili
|
||
|
||
```bash
|
||
# Status applicazione
|
||
pm2 status
|
||
|
||
# Logs real-time
|
||
pm2 logs vigilanza-turni
|
||
|
||
# Restart
|
||
pm2 restart vigilanza-turni
|
||
|
||
# Verifica backup
|
||
ls -lht /var/backups/vigilanza-turni/
|
||
|
||
# Ripristina backup
|
||
gunzip -c /var/backups/vigilanza-turni/backup_20250116_143022.sql.gz | \
|
||
PGPASSWORD=553da84c94093919d46055d6ec37dfa2a03d0f46 \
|
||
psql -h localhost -U vigilanza_user -d vigilanza_turni
|
||
```
|
||
|
||
---
|
||
|
||
## 🆘 Troubleshooting
|
||
|
||
**App non risponde:**
|
||
```bash
|
||
pm2 restart vigilanza-turni
|
||
pm2 logs vigilanza-turni --lines 50
|
||
sudo systemctl reload nginx
|
||
```
|
||
|
||
**Errore database:**
|
||
```bash
|
||
# Verifica connessione
|
||
PGPASSWORD=553da84c94093919d46055d6ec37dfa2a03d0f46 \
|
||
psql -h localhost -U vigilanza_user -d vigilanza_turni -c "SELECT version();"
|
||
```
|
||
|
||
**Build fallito:**
|
||
```bash
|
||
cd /var/www/vigilanza-turni
|
||
rm -rf node_modules dist
|
||
npm ci
|
||
npm run build
|
||
pm2 restart vigilanza-turni
|
||
```
|
||
|
||
---
|
||
|
||
## 🌐 Accesso
|
||
|
||
**Applicazione:** https://vt.alfacom.it
|
||
|
||
**Backup automatici:**
|
||
- Directory: `/var/backups/vigilanza-turni/`
|
||
- Retention: 30 giorni
|
||
- Formato: `backup_YYYYMMDD_HHMMSS.sql.gz`
|
||
|
||
---
|
||
|
||
## 📚 File Importanti
|
||
|
||
- `deploy/deploy.sh` - Script deployment automatico
|
||
- `deploy/setup-server.sh` - Setup iniziale server
|
||
- `deploy/nginx.conf` - Configurazione reverse proxy
|
||
- `.env` - Variabili ambiente produzione
|
||
- `push-to-gitlab.sh` - Helper push GitLab
|