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
173 lines
3.4 KiB
Markdown
173 lines
3.4 KiB
Markdown
# 🚀 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
|