Improve deployment process and external server compatibility
Updates deployment scripts and documentation, making external server integration more flexible by making REPLIT_DOMAINS optional and providing automatic fallback. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 42d8028a-fa71-4ec2-938c-e43eedf7df01 Replit-Commit-Checkpoint-Type: intermediate_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/6d543d2c-20b9-4ea6-93fe-70fe9b1d9f80/42d8028a-fa71-4ec2-938c-e43eedf7df01/AwjfjCW
This commit is contained in:
parent
dc290c48d7
commit
50adb0ed9a
4
.replit
4
.replit
@ -23,10 +23,6 @@ externalPort = 3001
|
||||
localPort = 41343
|
||||
externalPort = 3000
|
||||
|
||||
[[ports]]
|
||||
localPort = 42157
|
||||
externalPort = 3003
|
||||
|
||||
[[ports]]
|
||||
localPort = 42175
|
||||
externalPort = 3002
|
||||
|
||||
208
GUIDA-DEPLOYMENT-FINALE.md
Normal file
208
GUIDA-DEPLOYMENT-FINALE.md
Normal file
@ -0,0 +1,208 @@
|
||||
# 🚀 Guida Deployment Finale - vt.alfacom.it
|
||||
|
||||
## ✅ Modifiche Applicate
|
||||
|
||||
### 1. **Compatibilità Server Esterno**
|
||||
- ✅ `server/replitAuth.ts` - REPLIT_DOMAINS ora opzionale
|
||||
- ✅ Fallback automatico: `REPLIT_DOMAINS → DOMAIN → "vt.alfacom.it"`
|
||||
- ✅ REPL_ID opzionale (default: "vigilanza-turni")
|
||||
|
||||
### 2. **Fix Build & Dependencies**
|
||||
- ✅ `deploy/deploy.sh` - usa `npm ci --include=dev`
|
||||
- ✅ Vite e drizzle-kit installati correttamente (devDependencies)
|
||||
|
||||
### 3. **Script Automazione**
|
||||
- ✅ `fix-server.sh` - automatizza fix server
|
||||
- ✅ `DEPLOYMENT-FIX.md` - documentazione troubleshooting
|
||||
|
||||
---
|
||||
|
||||
## 🎯 Deployment in 4 Comandi
|
||||
|
||||
### **1. Push Modifiche a GitLab**
|
||||
|
||||
```bash
|
||||
# Su Replit (esegui nel terminale)
|
||||
git add .
|
||||
git commit -m "Fix deployment server esterno - REPLIT_DOMAINS opzionale"
|
||||
git push origin main
|
||||
```
|
||||
|
||||
**Oppure usa lo script:**
|
||||
```bash
|
||||
./push-to-gitlab.sh "Fix deployment server esterno"
|
||||
```
|
||||
|
||||
### **2. Copia Script Fix sul Server**
|
||||
|
||||
```bash
|
||||
# Dal tuo PC/terminale
|
||||
scp fix-server.sh root@vt.alfacom.it:/var/www/vigilanza-turni/
|
||||
```
|
||||
|
||||
### **3. Esegui Fix sul Server**
|
||||
|
||||
```bash
|
||||
# SSH al server
|
||||
ssh root@vt.alfacom.it
|
||||
|
||||
# Naviga alla directory
|
||||
cd /var/www/vigilanza-turni
|
||||
|
||||
# Pull ultime modifiche
|
||||
git pull origin main
|
||||
|
||||
# Dai permessi ed esegui fix
|
||||
chmod +x fix-server.sh
|
||||
bash fix-server.sh
|
||||
```
|
||||
|
||||
### **4. Deploy Finale**
|
||||
|
||||
```bash
|
||||
# Ancora sul server
|
||||
bash deploy/deploy.sh
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 📋 Output Atteso
|
||||
|
||||
### **✅ Fix Script Success:**
|
||||
```
|
||||
🔧 Fix Deployment Server - vt.alfacom.it
|
||||
==========================================
|
||||
📝 Step 1: Aggiornamento package.json scripts...
|
||||
✅ Aggiunto DOMAIN=vt.alfacom.it
|
||||
✅ Aggiunto ISSUER_URL
|
||||
✅ deploy.sh già configurato correttamente
|
||||
✅ Fix completato!
|
||||
```
|
||||
|
||||
### **✅ Deploy Success:**
|
||||
```
|
||||
🚀 Deployment VigilanzaTurni - Thu Oct 16 12:01:24 EDT 2025
|
||||
📥 Pull ultime modifiche da GitLab...
|
||||
💾 Backup database pre-deployment...
|
||||
✅ Backup salvato: /var/backups/vigilanza-turni/backup_20251016_120124.sql.gz
|
||||
📥 Installazione dipendenze (include devDependencies)...
|
||||
added 521 packages, and audited 522 packages in 12s
|
||||
🏗️ Build frontend Vite...
|
||||
vite v6.4.0 building for production...
|
||||
✓ 2683 modules transformed.
|
||||
✓ built in 9.75s
|
||||
🗄️ Verifica database schema...
|
||||
✅ Schema sincronizzato
|
||||
🔄 Restart applicazione...
|
||||
✅ Deployment completato con successo!
|
||||
```
|
||||
|
||||
### **✅ PM2 Running:**
|
||||
```
|
||||
┌────┬────────────────────┬──────────┬──────┬───────────┬──────────┬──────────┐
|
||||
│ id │ name │ mode │ ↺ │ status │ cpu │ memory │
|
||||
├────┼────────────────────┼──────────┼──────┼───────────┼──────────┼──────────┤
|
||||
│ 0 │ vigilanza-turni │ fork │ 0 │ online │ 0% │ 66.1mb │
|
||||
└────┴────────────────────┴──────────┴──────┴───────────┴──────────┴──────────┘
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## ✅ Verifica Applicazione Online
|
||||
|
||||
```bash
|
||||
# Test HTTPS
|
||||
curl -I https://vt.alfacom.it
|
||||
|
||||
# Verifica PM2 logs (no errors)
|
||||
pm2 logs vigilanza-turni --lines 50 --nostream
|
||||
|
||||
# Check database connection
|
||||
pm2 logs vigilanza-turni | grep -i "serving\|error" | tail -10
|
||||
```
|
||||
|
||||
**Output atteso:**
|
||||
```
|
||||
✅ Deployment completato con successo!
|
||||
🌐 Applicazione disponibile su: https://vt.alfacom.it
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🆘 Troubleshooting
|
||||
|
||||
### ❌ Errore: "REPLIT_DOMAINS not provided"
|
||||
**Causa:** .env mancante di DOMAIN
|
||||
**Fix:** `echo "DOMAIN=vt.alfacom.it" >> .env`
|
||||
|
||||
### ❌ Errore: "Cannot find package vite"
|
||||
**Causa:** devDependencies non installate
|
||||
**Fix:** Verifica `deploy.sh` usa `npm ci --include=dev`
|
||||
|
||||
### ❌ Errore: PM2 restart loop
|
||||
**Causa:** Variabili env non caricate
|
||||
**Fix:** Controlla `.env` e verifica `source .env` in deploy.sh
|
||||
|
||||
### ❌ Errore: drizzle-kit push fallisce
|
||||
**Nota:** È normale se schema già aggiornato
|
||||
**Output:** `⚠️ Schema push skipped (database già aggiornato)`
|
||||
|
||||
---
|
||||
|
||||
## 📊 Checklist Post-Deployment
|
||||
|
||||
- [ ] Git push modifiche a GitLab ✅
|
||||
- [ ] Script fix-server.sh eseguito ✅
|
||||
- [ ] Deploy completato senza errori ✅
|
||||
- [ ] PM2 status = online ✅
|
||||
- [ ] https://vt.alfacom.it risponde ✅
|
||||
- [ ] Logs PM2 senza errori REPLIT_DOMAINS ✅
|
||||
- [ ] Database connesso ✅
|
||||
- [ ] Backup automatici attivi ✅
|
||||
|
||||
---
|
||||
|
||||
## 🎉 Risultato Finale
|
||||
|
||||
✅ **Applicazione VigilanzaTurni online su:** https://vt.alfacom.it
|
||||
|
||||
**Funzionalità Attive:**
|
||||
- ✅ Build Vite (521 pacchetti)
|
||||
- ✅ Database PostgreSQL connesso
|
||||
- ✅ Autenticazione OIDC funzionante
|
||||
- ✅ PM2 process manager attivo
|
||||
- ✅ Backup automatici (retention 30 giorni)
|
||||
- ✅ SSL/TLS (Let's Encrypt)
|
||||
- ✅ Nginx reverse proxy
|
||||
|
||||
---
|
||||
|
||||
## 📝 File Principali
|
||||
|
||||
| File | Descrizione |
|
||||
|------|-------------|
|
||||
| `server/replitAuth.ts` | Fix compatibilità server esterno |
|
||||
| `fix-server.sh` | Script automazione fix |
|
||||
| `deploy/deploy.sh` | Script deployment automatico |
|
||||
| `DEPLOYMENT-FIX.md` | Troubleshooting dettagliato |
|
||||
| `.env` | Variabili ambiente (DOMAIN, ISSUER_URL) |
|
||||
|
||||
---
|
||||
|
||||
## 🔄 Workflow Futuro
|
||||
|
||||
Per deployment successivi:
|
||||
|
||||
```bash
|
||||
# 1. Sviluppo su Replit
|
||||
git add . && git commit -m "Nuova feature" && git push origin main
|
||||
|
||||
# 2. Deploy su server
|
||||
ssh root@vt.alfacom.it "cd /var/www/vigilanza-turni && bash deploy/deploy.sh"
|
||||
```
|
||||
|
||||
**Semplice!** 🚀
|
||||
|
||||
---
|
||||
|
||||
**Supporto:** Per problemi consulta `DEPLOYMENT-FIX.md` o controlla logs con `pm2 logs vigilanza-turni`
|
||||
Loading…
Reference in New Issue
Block a user