VigilanzaTurni/QUICKSTART-DEPLOYMENT.md
marco370 3cdc6931bb Improve deployment process by generating secure passwords
Update deployment scripts to automatically generate secure PostgreSQL passwords, store them securely, and use them in environment configuration.

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:15:54 +00:00

173 lines
3.4 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 🚀 Quick Start - Deployment VigilanzaTurni
Guida rapida per deployment da Replit → GitLab → Server AlmaLinux 9
## 📝 Checklist Pre-Deployment
- [ ] Server AlmaLinux 9 disponibile (min 2GB RAM)
- [ ] Dominio configurato (es. vigilanza.tuodominio.it)
- [ ] Account GitLab su git.alfacom.it
- [ ] SSH access al server
---
## ⚡ Setup Rapido (15 minuti)
### 1⃣ Setup Server (5 min)
```bash
# SSH nel server
ssh root@ip-del-server
# Download e esegui setup automatico
curl -o setup.sh https://git.alfacom.it/marco/VigilanzaTurni/-/raw/main/deploy/setup-server.sh
chmod +x setup.sh
sudo bash setup.sh
# ⚠️ IMPORTANTE: Salva la password PostgreSQL mostrata!
```
### 2⃣ Configura GitLab CI/CD (3 min)
**Genera SSH Key:**
```bash
# Sul tuo PC
ssh-keygen -t ed25519 -C "gitlab-deploy" -f ~/.ssh/gitlab-deploy
ssh-copy-id -i ~/.ssh/gitlab-deploy.pub root@ip-del-server
cat ~/.ssh/gitlab-deploy # Copia output
```
**GitLab → Settings → CI/CD → Variables:**
| Nome | Valore |
|------|--------|
| `SSH_PRIVATE_KEY` | [chiave privata copiata sopra] |
| `DEPLOY_HOST` | ip-del-server |
| `DEPLOY_USER` | root |
| `DEPLOY_DOMAIN` | vigilanza.tuodominio.it |
### 3⃣ Configura Replit (2 min)
```bash
# In Replit Shell
git remote add production https://git.alfacom.it/marco/VigilanzaTurni.git
# Crea Personal Access Token su GitLab e salvalo in Replit Secrets
# GitLab → User Settings → Access Tokens → write_repository
```
### 4⃣ Configura Server .env (3 min)
```bash
# Sul server
cd /var/www/vigilanza-turni
# Clone iniziale
git clone https://git.alfacom.it/marco/VigilanzaTurni.git .
# Crea .env
cp .env.production.example .env
nano .env
```
**Inserisci:**
```bash
# Password DB dal setup (vedi /root/.vigilanza_db_password)
DATABASE_URL=postgresql://vigilanza_user:PASSWORD_GENERATA@localhost:5432/vigilanza_turni
SESSION_SECRET=$(openssl rand -base64 32)
REPLIT_DOMAINS=vigilanza.tuodominio.it
```
### 5⃣ Nginx e SSL (2 min)
```bash
# Copia config Nginx
sudo cp deploy/nginx.conf /etc/nginx/conf.d/vigilanza-turni.conf
# Modifica con il tuo dominio
sudo nano /etc/nginx/conf.d/vigilanza-turni.conf
# Sostituisci "tuodominio.it" → "vigilanza.tuodominio.it"
# Test e reload
sudo nginx -t
sudo systemctl reload nginx
# SSL Certificate
sudo certbot --nginx -d vigilanza.tuodominio.it
```
### 6⃣ Primo Deploy (1 min)
```bash
# Sul server
cd /var/www/vigilanza-turni
bash deploy/deploy.sh
```
---
## 🔄 Workflow Quotidiano
### Da Replit → Produzione
```bash
# 1. Fai modifiche in Replit
# 2. Push a GitLab
bash push-to-gitlab.sh
# 3. Vai su GitLab
https://git.alfacom.it/marco/VigilanzaTurni/-/pipelines
# 4. Clicca su "deploy_production" quando pronto
```
---
## 📊 Comandi Utili
```bash
# Status applicazione
pm2 status
# Logs real-time
pm2 logs vigilanza-turni
# Restart
pm2 restart vigilanza-turni
# Backup database
sudo -u postgres pg_dump vigilanza_turni > backup_$(date +%Y%m%d).sql
```
---
## 🆘 Problemi Comuni
**App non risponde:**
```bash
pm2 restart vigilanza-turni
sudo systemctl reload nginx
```
**Errore database:**
```bash
# Verifica password in .env corrisponde a quella in /root/.vigilanza_db_password
cat /root/.vigilanza_db_password
```
**SSL scaduto:**
```bash
sudo certbot renew
sudo systemctl reload nginx
```
---
## 📚 Documentazione Completa
Per dettagli completi: [DEPLOYMENT.md](./DEPLOYMENT.md)
---
**Setup completato?** ✅ Vai su https://vigilanza.tuodominio.it