docs(lxc103): staging autopass-test.roa.romfast.ro
Flux de lucru pentru mediu staging autopass: un branch = un environment (main->prod, staging->test), serviciu Dokploy separat autopass-test, domeniu via wildcard *.roa (fara IIS/cert nou), env care opreste trimiterile reale la RAR. Link incrucisat din autopass.md. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
147
proxmox/lxc103-dokploy/docs/autopass-staging.md
Normal file
147
proxmox/lxc103-dokploy/docs/autopass-staging.md
Normal file
@@ -0,0 +1,147 @@
|
||||
# autopass — Staging pe Dokploy LXC 103
|
||||
|
||||
Mediu de **staging** pentru gateway-ul RAR AUTOPASS, separat complet de producție.
|
||||
Producția e documentată în [autopass.md](autopass.md) — aici doar diferențele.
|
||||
|
||||
- **Domeniu staging:** `autopass-test.roa.romfast.ro` (acoperit de wildcard `*.roa` → **fără** site IIS / cert nou)
|
||||
- **Server:** LXC 103 (10.0.20.167) — același Dokploy/Traefik ca prod
|
||||
- **Repo:** `git@gitea.romfast.ro:romfast/rar-autopass.git`, branch **`staging`**
|
||||
- **Serviciu Dokploy:** `autopass-test` (separat de `autopass`)
|
||||
|
||||
---
|
||||
|
||||
## Model: un branch = un environment
|
||||
|
||||
```
|
||||
main → autopass.romfast.ro (PROD, serviciu Dokploy "autopass")
|
||||
staging → autopass-test.roa.romfast.ro (STAGING, serviciu Dokploy "autopass-test")
|
||||
```
|
||||
|
||||
Flux de lucru:
|
||||
|
||||
```
|
||||
feature branch → merge în staging → autodeploy STAGING → validezi
|
||||
→ merge staging → main → autodeploy PROD
|
||||
```
|
||||
|
||||
Ce ajunge în prod a trecut deja prin staging. Cele două servicii Dokploy au fiecare
|
||||
project namespace propriu → **volumul `autopass-data` (SQLite) e fizic separat**, bazele
|
||||
nu se ating.
|
||||
|
||||
---
|
||||
|
||||
## De ce `*.roa` și nu `autopass-test.romfast.ro`
|
||||
|
||||
`autopass-test.roa.romfast.ro` cade sub binding-ul wildcard `*.roa.romfast.ro` + regula
|
||||
catch-all URL Rewrite din site-ul IIS `roa-apps` (VM 201) care forwardează tot către
|
||||
Traefik LXC 103. Deci pentru staging **nu** adaugi nimic în IIS și nu generezi cert nou —
|
||||
doar domeniul în Dokploy.
|
||||
|
||||
Un nume single-name (`autopass-test.romfast.ro`) ar fi cerut site IIS dedicat + cert
|
||||
win-acme + intrare în `monitor-ssl-certificates.sh` (vezi secțiunea „Domeniu public" din
|
||||
[autopass.md](autopass.md)). Pentru staging nu merită.
|
||||
|
||||
---
|
||||
|
||||
## Pași de setup (o singură dată)
|
||||
|
||||
### 1. Branch `staging` în repo
|
||||
|
||||
```bash
|
||||
cd /workspace/autopass
|
||||
git checkout main && git pull
|
||||
git checkout -b staging && git push -u origin staging
|
||||
```
|
||||
|
||||
### 2. Parametrizare env în `docker-compose.yml`
|
||||
|
||||
`docker-compose.yml` are **hardcodat** `AUTOPASS_RAR_ENV: prod` (api) și
|
||||
`AUTOPASS_WORKER_SEND_ENABLED: "true"` (worker). Valoarea literală câștigă în fața
|
||||
Environment-ului din Dokploy → staging-ul ar trimite declarații **reale** la RAR.
|
||||
Parametrizează-le (pe `staging`, backward-compatible cu prod prin default-uri):
|
||||
|
||||
```yaml
|
||||
# api:
|
||||
AUTOPASS_RAR_ENV: ${AUTOPASS_RAR_ENV:-prod}
|
||||
# worker:
|
||||
AUTOPASS_RAR_ENV: ${AUTOPASS_RAR_ENV:-test}
|
||||
AUTOPASS_WORKER_SEND_ENABLED: ${AUTOPASS_WORKER_SEND_ENABLED:-true}
|
||||
```
|
||||
|
||||
Astfel prod (fără override) rămâne identic, iar staging poate forța `test`/`false` din
|
||||
Dokploy.
|
||||
|
||||
### 3. Creare serviciu `autopass-test` în Dokploy
|
||||
|
||||
https://dokploy.romfast.ro → **Services** → **Create Service** → **Docker Compose**
|
||||
|
||||
- Name: **`autopass-test`**, Server: **LXC 103 (local)**
|
||||
- Provider **`</> Git`** (Custom Git — Gitea nativ dă "Unauthorized", la fel ca prod):
|
||||
- Repository URL: `git@gitea.romfast.ro:romfast/rar-autopass.git`
|
||||
- Branch: **`staging`**
|
||||
- Compose Path: `./docker-compose.yml`
|
||||
- SSH: refolosește **același deploy key** deja adăugat în Gitea (read-only pe repo,
|
||||
valabil pentru ambele servicii)
|
||||
|
||||
### 4. Environment (în Dokploy, NU în .env)
|
||||
|
||||
| Variabilă | Staging |
|
||||
|-----------|---------|
|
||||
| `AUTOPASS_CREDS_KEY` | cheie Fernet **proprie staging-ului** — NU o partaja cu prod |
|
||||
| `AUTOPASS_RAR_ENV` | `test` |
|
||||
| `AUTOPASS_WORKER_SEND_ENABLED` | `false` (staging NU trimite la RAR — Legea 142/2023) |
|
||||
| `AUTOPASS_REQUIRE_API_KEY` | `true` (testezi auth-ul real ca în prod) |
|
||||
|
||||
```bash
|
||||
# Generare AUTOPASS_CREDS_KEY (nouă, doar pentru staging):
|
||||
python3 -c "from cryptography.fernet import Fernet; print(Fernet.generate_key().decode())"
|
||||
```
|
||||
|
||||
### 5. Domain
|
||||
|
||||
**Domains** → **Add Domain**:
|
||||
- Host: `autopass-test.roa.romfast.ro`, Service: **`api`**, Container Port: **`8010`**, Path: `/`
|
||||
- **HTTPS: OFF** (entrypoint `web`) — TLS-ul public se termină la IIS; Certificate: **None**
|
||||
|
||||
### 6. Webhook autodeploy (branch filter `staging`)
|
||||
|
||||
Custom Git nu creează webhook automat → al doilea webhook în Gitea, separat de prod:
|
||||
|
||||
1. Dokploy → serviciul `autopass-test` → General → copiază **Webhook URL**
|
||||
2. Gitea → repo → Settings → Webhooks → Add Webhook → **Gitea**:
|
||||
- Target URL: *(URL-ul din Dokploy)*, Method `POST`, Content Type `application/json`
|
||||
- **Branch filter: `staging`**, trigger Push Events, Active
|
||||
- **Test Delivery** → trebuie `200`
|
||||
|
||||
Rezultat: push pe `staging` deployează doar staging-ul, push pe `main` doar producția.
|
||||
|
||||
---
|
||||
|
||||
## DNS
|
||||
|
||||
`autopass-test.roa.romfast.ro` e acoperit de wildcard `*.roa.romfast.ro` → **nu** se
|
||||
adaugă înregistrare DNS separată.
|
||||
|
||||
```
|
||||
*.roa.romfast.ro A 188.26.14.103 (deja existent)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Verificare post-deploy
|
||||
|
||||
```bash
|
||||
# Stare containere staging
|
||||
ssh root@10.0.20.201 "pct exec 103 -- docker ps --format '{{.Names}} -> {{.Status}}' | grep autopass-test"
|
||||
# Așteptat: api/worker/autoheal Up (healthy)
|
||||
|
||||
# API direct în Traefik (host header), pe LXC 103
|
||||
ssh root@10.0.20.201 'pct exec 103 -- sh -lc "curl -s -o /dev/null -w \"%{http_code}\n\" -H \"Host: autopass-test.roa.romfast.ro\" http://localhost/healthz"'
|
||||
# Așteptat: 200
|
||||
|
||||
# Lanț complet TLS (de oriunde) — root redirectează 303 → /login = OK
|
||||
curl -s -o /dev/null -w "%{http_code}\n" https://autopass-test.roa.romfast.ro/
|
||||
```
|
||||
|
||||
Înainte de pasul Domain (5): `https://autopass-test.roa.romfast.ro/` → **404** (Traefik
|
||||
n-are router pe acest Host). După: **303** (redirect /login) sau **200** pe `/healthz`.
|
||||
@@ -7,6 +7,7 @@ declară la RAR AUTOPASS (Legea 142/2023). Deployat pe Dokploy / LXC 103 ca serv
|
||||
Docker Compose.
|
||||
|
||||
- **Domenii:** `autopass.romfast.ro` (public, site IIS dedicat) + `autopass.roa.romfast.ro` (prin wildcard)
|
||||
- **Staging:** branch `staging` → `autopass-test.roa.romfast.ro` — vezi [autopass-staging.md](autopass-staging.md)
|
||||
- **Server:** LXC 103 (10.0.20.167)
|
||||
- **Deployment:** Dokploy → Docker Compose, provider **Custom Git**
|
||||
- **Repo:** `git@gitea.romfast.ro:romfast/rar-autopass.git`, branch **`main`**
|
||||
|
||||
Reference in New Issue
Block a user