docs: add localhost vs production comparison and fix Caddyfile example
- Add new section summarising the 4 differences between local dev and production: domain/HTTPS, env vars, server requirements, backups - Update production Caddyfile example to include /uploads/* static file handler (required for image serving)
This commit is contained in:
@@ -107,6 +107,46 @@ docker compose down -v # ferma e cancella anche il database
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
## Differenze tra localhost e produzione
|
||||||
|
|
||||||
|
Quattro cose cambiano quando si passa da localhost a un dominio reale.
|
||||||
|
|
||||||
|
### 1 — Dominio e HTTPS
|
||||||
|
|
||||||
|
Modificare **una sola riga** nel `Caddyfile`:
|
||||||
|
|
||||||
|
```
|
||||||
|
# localhost
|
||||||
|
localhost { ... }
|
||||||
|
|
||||||
|
# produzione
|
||||||
|
tuodominio.com { ... }
|
||||||
|
```
|
||||||
|
|
||||||
|
Caddy ottiene e rinnova automaticamente il certificato HTTPS tramite Let's Encrypt. Non serve nessuna configurazione SSL manuale.
|
||||||
|
|
||||||
|
### 2 — Variabili d'ambiente
|
||||||
|
|
||||||
|
Cinque variabili da aggiornare nel `.env`:
|
||||||
|
|
||||||
|
| Variabile | Localhost | Produzione |
|
||||||
|
|-----------|-----------|------------|
|
||||||
|
| `APP_URL` | `http://localhost` | `https://tuodominio.com` |
|
||||||
|
| `AUTH_SECRET` | qualsiasi stringa | `openssl rand -hex 32` |
|
||||||
|
| `STRIPE_SECRET_KEY` | `sk_test_...` (gratuita) | `sk_live_...` |
|
||||||
|
| `STRIPE_WEBHOOK_SECRET` | opzionale | obbligatorio |
|
||||||
|
| `SMTP_*` | Mailpit locale (porta 8025) | provider reale (Resend, Mailgun, SendGrid…) |
|
||||||
|
|
||||||
|
### 3 — Server
|
||||||
|
|
||||||
|
Serve un VPS Linux con Docker installato (DigitalOcean, Hetzner, OVH, ecc.) e il record DNS del dominio puntato all'IP del server. Il comando di avvio è identico: `docker compose up -d`.
|
||||||
|
|
||||||
|
### 4 — Backup
|
||||||
|
|
||||||
|
In locale i dati si perdono con `docker compose down -v`. In produzione è necessario un backup automatico del database (vedi sezione [Backup database](#backup-database)) e conservare il volume `uploads` che contiene le immagini dei prodotti.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## Deploy in produzione
|
## Deploy in produzione
|
||||||
|
|
||||||
### Prerequisiti
|
### Prerequisiti
|
||||||
@@ -172,6 +212,10 @@ Apri `Caddyfile` e sostituisci `localhost` con il tuo dominio:
|
|||||||
|
|
||||||
```
|
```
|
||||||
tuodominio.com {
|
tuodominio.com {
|
||||||
|
handle /uploads/* {
|
||||||
|
root * /srv
|
||||||
|
file_server
|
||||||
|
}
|
||||||
encode gzip zstd
|
encode gzip zstd
|
||||||
reverse_proxy app:3000
|
reverse_proxy app:3000
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user