70 lines
2.3 KiB
Markdown
70 lines
2.3 KiB
Markdown
# Testing & Deployment (Gitea → Docker → Nginx Proxy Manager)
|
||
|
||
## Ziel
|
||
|
||
- **Production**: Branch `production` → Container `portfolio-app` → `dk0.dev` (Port `3000`)
|
||
- **Testing**: Branch `testing` → Container `portfolio-app-testing` → `testing.dk0.dev` (Port `3002`)
|
||
|
||
Beide Stacks laufen parallel und sind komplett getrennt (eigene Postgres/Redis/Volumes).
|
||
|
||
## DNS / Nginx Proxy Manager
|
||
|
||
### DNS
|
||
- Setze `A` (oder `CNAME`) Records:
|
||
- `dk0.dev` → dein Server
|
||
- `testing.dk0.dev` → dein Server
|
||
|
||
### Nginx Proxy Manager
|
||
Lege zwei Proxy Hosts an:
|
||
|
||
- **`dk0.dev`**
|
||
- Forward Hostname/IP: `127.0.0.1` (oder Server-IP)
|
||
- Forward Port: `3000`
|
||
|
||
- **`testing.dk0.dev`**
|
||
- Forward Hostname/IP: `127.0.0.1` (oder Server-IP)
|
||
- Forward Port: `3002`
|
||
|
||
Dann SSL Zertifikate (Let’s Encrypt) aktivieren.
|
||
|
||
## Gitea Workflows
|
||
|
||
- `production` push → `.gitea/workflows/production-deploy.yml`
|
||
- `testing` push → `.gitea/workflows/dev-deploy.yml` (umbenannt im Namen, Inhalt ist Testing)
|
||
|
||
### Benötigte Variables (Gitea)
|
||
- `NEXT_PUBLIC_BASE_URL_PRODUCTION` = `https://dk0.dev`
|
||
- `NEXT_PUBLIC_BASE_URL_TESTING` = `https://testing.dk0.dev`
|
||
- optional: `MY_EMAIL`, `MY_INFO_EMAIL`, `LOG_LEVEL`, `N8N_WEBHOOK_URL`, `N8N_API_KEY`
|
||
|
||
### Benötigte Secrets (Gitea)
|
||
- `MY_PASSWORD`
|
||
- `MY_INFO_PASSWORD`
|
||
- `ADMIN_BASIC_AUTH` (z.B. `admin:<starkes_passwort>`)
|
||
- `ADMIN_SESSION_SECRET` (mind. 32 Zeichen, zufällig; für Session-Login im Admin)
|
||
- optional: `N8N_SECRET_TOKEN`
|
||
|
||
## Docker Compose Files
|
||
|
||
- Production: `docker-compose.production.yml` (Port 3000)
|
||
- Testing: `docker-compose.testing.yml` (Port 3002)
|
||
|
||
Wenn du “dev” nicht mehr brauchst, kannst du den Branch einfach nicht mehr benutzen.
|
||
|
||
## Prisma Migrations (Auto-Deploy)
|
||
|
||
Der App-Container führt beim Start automatisch aus:
|
||
- `prisma migrate deploy`
|
||
|
||
### Wichtig: bestehende Datenbank (Baseline)
|
||
Wenn deine DB bereits existiert (vor Einführung von Prisma Migrations), dann würde die initiale Migration sonst mit “table already exists” scheitern.
|
||
|
||
**Einmalig beim ersten Deploy**:
|
||
- Setze `PRISMA_AUTO_BASELINE=true` (z.B. als Compose env oder Gitea Variable/Secret)
|
||
- Deploy ausführen
|
||
- Danach wieder auf `false` setzen
|
||
|
||
Alternative (manuell/sauber):
|
||
- Baseline per `prisma migrate resolve --applied <init_migration_name>` ausführen (z.B. lokal gegen die Prod-DB)
|
||
|