- Add proxmox/lxc106-gitea/README.md: app.ini editing, Docker restart, webhook ALLOWED_HOST_LIST fix (hairpin NAT), troubleshooting - Add proxmox/lxc103-dokploy/docs/space-booking-app.md: full deploy guide with env vars, auto-seed accounts, SMTP, troubleshooting - Update proxmox/README.md: add LXC 106 entry and quick start - Update lxc103-dokploy/README.md: add space.roa.romfast.ro in domains table, ASCII architecture, and docs links Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
202 lines
5.7 KiB
Markdown
202 lines
5.7 KiB
Markdown
# space-booking — Deploy pe Dokploy LXC 103
|
|
|
|
## Descriere
|
|
|
|
Aplicație de rezervare spații (săli de conferință, birouri), cu backend FastAPI și
|
|
frontend Vue.js. Deployată pe Dokploy/LXC 103 ca serviciu Docker Compose.
|
|
|
|
- **Domeniu:** `space.roa.romfast.ro`
|
|
- **Server:** LXC 103 (10.0.20.167)
|
|
- **Deployment:** Dokploy → Docker Compose
|
|
- **Repo:** `git@gitea.romfast.ro:romfast/space-booking.git`
|
|
|
|
### Arhitectură
|
|
|
|
```
|
|
Browser → VM 201 IIS (SSL) → LXC 103 Traefik → frontend (nginx:80)
|
|
↓
|
|
backend (FastAPI:8000)
|
|
↓
|
|
SQLite /data/space_booking.db
|
|
```
|
|
|
|
Servicii Docker Compose:
|
|
- `frontend` — Vue.js servit de nginx, expus prin Traefik
|
|
- `backend` — FastAPI pe port 8000, intern (fără expunere directă)
|
|
|
|
---
|
|
|
|
## Deploy în Dokploy UI
|
|
|
|
### 1. Creare Service
|
|
|
|
1. Deschide https://dokploy.romfast.ro
|
|
2. **Services** → **Create Service** → **Docker Compose**
|
|
3. Name: `space-booking`
|
|
4. Server: **LXC 103 (local)**
|
|
|
|
### 2. Configurare Git Source
|
|
|
|
- Provider: **Gitea** (sau Custom Git)
|
|
- URL: `http://gitea.romfast.ro/romfast/space-booking.git`
|
|
- Branch: `master`
|
|
|
|
### 3. Domain Configuration
|
|
|
|
În Dokploy, secțiunea **Domains**:
|
|
- Domain: `space.roa.romfast.ro`
|
|
- HTTPS: enabled
|
|
- Certificate: managed by Traefik
|
|
|
|
### 4. Variabile de Mediu (Environment)
|
|
|
|
Setează în Dokploy → **Environment** tab:
|
|
|
|
| Variabilă | Obligatoriu | Valoare exemplu | Descriere |
|
|
|-----------|-------------|-----------------|-----------|
|
|
| `SECRET_KEY` | **DA** | `<token hex 32>` | JWT signing key |
|
|
| `FRONTEND_URL` | **DA** | `https://space.roa.romfast.ro` | URL frontend pentru CORS/redirect |
|
|
| `SMTP_ENABLED` | Nu | `true` | Activează trimitere email |
|
|
| `SMTP_HOST` | Nu* | `smtp.example.com` | Server SMTP |
|
|
| `SMTP_PORT` | Nu* | `587` | Port SMTP |
|
|
| `SMTP_USER` | Nu* | `user@example.com` | User autentificare SMTP |
|
|
| `SMTP_PASSWORD` | Nu* | `parola` | Parolă SMTP |
|
|
| `SMTP_FROM_ADDRESS` | Nu* | `rezervari@romfast.ro` | Adresă expeditor |
|
|
|
|
> *Necesare doar dacă `SMTP_ENABLED=true`
|
|
|
|
**Generare SECRET_KEY:**
|
|
```bash
|
|
python -c "import secrets; print(secrets.token_hex(32))"
|
|
```
|
|
|
|
### 5. Deploy
|
|
|
|
Click **Deploy** → monitorizează logs în Dokploy UI.
|
|
|
|
---
|
|
|
|
## Conturi Demo Create Automat
|
|
|
|
La primul deploy, `entrypoint.sh` rulează automat `seed_db.py` (idempotent).
|
|
|
|
| Email | Parolă | Rol |
|
|
|-------|--------|-----|
|
|
| `admin@example.com` | `adminpassword` | Superadmin |
|
|
| `manager@example.com` | `managerpassword` | Manager |
|
|
| `user@example.com` | `userpassword` | User |
|
|
|
|
> **Atenție:** Schimbă parolele în producție după primul login!
|
|
|
|
Date demo create: 2 proprietăți ("Clădirea Centrală", "Biroul Privat"), 3 spații, 2 organizații.
|
|
|
|
---
|
|
|
|
## Verificare Post-Deploy
|
|
|
|
```bash
|
|
# Health check backend (prin Traefik)
|
|
curl -s https://space.roa.romfast.ro/health
|
|
# Răspuns așteptat: {"status": "ok"}
|
|
|
|
# Health check direct (din LAN)
|
|
curl -s http://10.0.20.167/health -H "Host: space.roa.romfast.ro"
|
|
|
|
# Verificare logs backend (seed automat)
|
|
# În Dokploy UI → space-booking → Logs → backend
|
|
# Trebuie să apară:
|
|
# [entrypoint] Running database seed...
|
|
# Database already seeded. Skipping... ← la redeploy-uri ulterioare
|
|
# [entrypoint] Starting application...
|
|
|
|
# Test autentificare
|
|
curl -s -X POST https://space.roa.romfast.ro/api/auth/login \
|
|
-H "Content-Type: application/json" \
|
|
-d '{"email":"admin@example.com","password":"adminpassword"}' | jq .
|
|
```
|
|
|
|
---
|
|
|
|
## Configurare SMTP
|
|
|
|
### Cu SMTP (email de confirmare rezervare)
|
|
|
|
În Dokploy → Environment, setează:
|
|
```
|
|
SMTP_ENABLED=true
|
|
SMTP_HOST=smtp.example.com
|
|
SMTP_PORT=587
|
|
SMTP_USER=user@example.com
|
|
SMTP_PASSWORD=parola_smtp
|
|
SMTP_FROM_ADDRESS=rezervari@romfast.ro
|
|
```
|
|
|
|
Redeploy → verificare logs pentru mesaje email la rezervare.
|
|
|
|
### Fără SMTP (implicit)
|
|
|
|
Aplicația funcționează normal fără SMTP. Rezervările se fac, dar nu se trimit emailuri de confirmare. Setare implicită: `SMTP_ENABLED=false`.
|
|
|
|
---
|
|
|
|
## DNS
|
|
|
|
```
|
|
space.roa.romfast.ro A 188.26.14.103
|
|
```
|
|
|
|
Domeniu sub `*.roa.romfast.ro` → wildcard DNS acoperă automat.
|
|
|
|
---
|
|
|
|
## SSL Certificate (Win-ACME pe VM 201)
|
|
|
|
Dacă wildcardul `*.roa.romfast.ro` e deja configurat, SSL funcționează automat.
|
|
|
|
Dacă e nevoie de cert explicit:
|
|
```powershell
|
|
cd C:\Tools\win-acme
|
|
Import-Module WebAdministration
|
|
Get-Website | Select-Object ID, Name
|
|
|
|
.\wacs.exe --source iis --siteid <ID_space> --accepttos --emailaddress admin@romfast.ro
|
|
iisreset
|
|
```
|
|
|
|
---
|
|
|
|
## Troubleshooting
|
|
|
|
### 502 Bad Gateway
|
|
|
|
Cauze posibile:
|
|
1. **dnsrr fix** — Docker Swarm VIP issue (standard pe LXC 103)
|
|
```bash
|
|
journalctl -u dokploy-dnsrr-fix -n 20
|
|
# Trebuie să apară: OK - space-booking-... now uses dnsrr
|
|
```
|
|
2. **Backend nu a pornit** — verifică logs backend în Dokploy UI
|
|
|
|
### Seed DB nu rulează
|
|
|
|
```bash
|
|
# Verificare logs în Dokploy UI → backend
|
|
# Dacă apare eroare la seed, verifică DATABASE_URL și permisiuni volum
|
|
docker volume ls | grep space-booking
|
|
```
|
|
|
|
### SMTP nu trimite emailuri
|
|
|
|
1. Verifică `SMTP_ENABLED=true` în Dokploy → Environment
|
|
2. Verifică că `SMTP_USER` și `SMTP_PASSWORD` sunt setate (nu doar `SMTP_HOST`)
|
|
3. Redeploy după setarea variabilelor
|
|
4. Verifică logs backend pentru erori SMTP
|
|
|
|
### Resetare bază de date (date demo)
|
|
|
|
```bash
|
|
# ATENȚIE: șterge toate datele!
|
|
docker volume rm space-booking_backend_data
|
|
# La redeploy următor, seed_db.py recreează datele demo
|
|
```
|