Files
websitedev/DOCKER.md
T
Do SikiandClaude Sonnet 5 1b3ae07811
CI Pipeline with Test Management / 🧪 Run Tests & Generate Reports (push) Canceled after 0s
Test Reporting & Gherkin Analysis / 🧪 Run Tests & Generate Reports (push) Canceled after 0s
CI Pipeline with Test Management / 🐳 Docker Integration Tests (push) Canceled after 0s
CI Pipeline with Test Management / 🏗️ Build Docker Image (push) Canceled after 0s
CI Pipeline with Test Management / 📊 Generate Test Summary (push) Canceled after 0s
Test Reporting & Gherkin Analysis / 📊 Analyze Test Coverage (push) Canceled after 0s
Test Reporting & Gherkin Analysis / 🔄 Sync with Linear (push) Canceled after 0s
Test Reporting & Gherkin Analysis / ⚡ Performance Monitoring (push) Canceled after 0s
feat(deploy): staging/production Docker deploy for Payload (MITHOME-97)
Fixes a real, previously-undiscovered build failure and a bigger
architectural gap found while testing an actual `docker build` of
proto/Dockerfile for the first time since the Payload migration:

1. Docker build failure: the (frontend)/[locale] pages use
   generateStaticParams, so `next build` fully prerenders them (SSG) —
   which calls the Payload Local API during the build. With no
   MONGODB_URI/PAYLOAD_SECRET reachable in the build stage, `docker
   build` failed outright ("missing secret key").

2. Bigger problem underneath: even if the build could reach a DB,
   full SSG means a Payload admin edit would NOT appear on the public
   site until a full rebuild + redeploy — directly undermining the
   project's whole reason for migrating to Payload (self-service
   content editing for the client).

Fix (user-confirmed direction: force-dynamic): dropped
generateStaticParams from (frontend)/[locale]/layout.tsx and
[locale]/[slug]/page.tsx, added `export const dynamic = 'force-dynamic'`
to layout.tsx + both page.tsx files. Every request now reads Payload
live — publishing in the admin is visible immediately, and the Docker
build no longer needs any DB connectivity at all (verified: a full
`docker build --target builder` now succeeds with zero env vars set).

Docker/Compose changes:
- docker-compose.staging.yml / docker-compose.prod.yml: wired
  PAYLOAD_SECRET through to the app container (was documented in
  .env.*.example since MITHOME-86 but never actually passed to the
  container — Payload would have refused to start). No fallback,
  same fail-loudly pattern as MONGODB_URI.
- Same two files: added a named `media_data_{staging,prod}` volume
  mounted at /app/media — Payload's local upload storage (Media.ts)
  writes there at the container's runtime cwd; without a volume,
  `deploy.sh`'s `--force-recreate` would silently wipe every uploaded
  logo/image on each deploy.
- docker-compose.dev.yml: was missing PAYLOAD_SECRET entirely (only
  discovered because the same "missing secret key" error reproduces
  there too) — added a dev-only literal value. Media persistence
  already works there via the existing `./proto:/app` bind mount, no
  volume needed. Also dropped the obsolete `version: '3.8'` key
  (compose warns it's ignored).
- DOCKER.md: one-paragraph note on the new PAYLOAD_SECRET requirement
  and where the admin account gets created.

Verified:
- `docker build --target builder` succeeds from a clean context with
  zero environment variables (previously failed).
- `docker build --target runner` + `docker run` against the real dev
  MongoDB (PAYLOAD_SECRET + MONGODB_URI supplied at runtime only):
  /hu, /admin and /api/health all return 200 inside the container;
  confirmed live in the browser that Payload content renders
  correctly end-to-end through the production Next.js server, not
  just `next dev`.
- `docker compose -f docker-compose.{staging,prod,dev}.yml config`
  parses cleanly.
- Full gate green: tsc, lint, proto unit tests (51 passed),
  scripts/pre-deploy-tests.sh (proto tests, tsc, lint, content schema,
  plane-sync — all pass).

deploy.sh itself needs no changes: it already just runs
`docker compose up --build`, and that now works without any
build-time DB wiring.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-11 22:12:01 +02:00

149 lines
3.6 KiB
Markdown
Executable File

# 🐳 Docker Fejlesztői Környezet
## Gyors Indítás
### Előfeltételek
- Docker és Docker Compose telepítve
- Git repository klónozva
### Teljes Stack Indítása
```bash
# Projekt gyökerében
docker-compose -f docker-compose.dev.yml up --build
# Vagy a proto könyvtárból
cd proto && npm run docker:dev
```
## 🚀 Szolgáltatások
A Docker stack a következő szolgáltatásokat indítja:
| Szolgáltatás | Port | URL | Leírás |
|--------------|------|-----|--------|
| **Next.js App** | 8080 | http://localhost:8080 | Fő alkalmazás |
| **MongoDB** | 27018 | mongodb://localhost:27018 | Adatbázis |
| **Mongo Express** | 8081 | http://localhost:8081 | MongoDB Web UI |
| **Loki** | 3100 | http://localhost:3100 | Log aggregátor |
| **Grafana** | 3001 | http://localhost:3001 | Monitoring dashboard |
### 🔐 Alapértelmezett Bejelentkezési Adatok
**MongoDB:**
- Username: `admin`
- Password: `password123`
**Grafana:**
- Username: `admin`
- Password: `admin123`
**Payload CMS admin** (http://localhost:8080/admin): nincs előre létrehozott felhasználó — az első betöltéskor a Payload felkínálja az admin fiók létrehozását. A `docker-compose.dev.yml` egy fix, nem titkos `PAYLOAD_SECRET`-et ad át (MITHOME-97) — staging/production környezetben ez kötelezően a saját `.env.<env>` fájlból jön, nincs alapértelmezett érték (a konténer el sem indul nélküle).
## 📊 MongoDB Hozzáférés
### 1. Mongo Express Web UI
- URL: http://localhost:8081
- Böngészőben egyszerűen elérhető
- Adatbázis: `mozdit`
### 2. MongoDB Shell (ha telepítve van)
```bash
# Kapcsolódás a containerhez
docker exec -it mozdit-mongodb-dev mongosh
# Vagy közvetlenül
mongosh "mongodb://admin:password123@localhost:27017/mozdit"
```
### 3. Alkalmazásból
Az alkalmazás automatikusan csatlakozik:
```
MONGODB_URI=mongodb://admin:password123@mongodb:27017/mozdit?authSource=admin
```
## 🛠️ Fejlesztési Parancsok
```bash
# Stack indítása (build-del)
npm run docker:dev
# Stack leállítása
npm run docker:dev:down
# Alkalmazás logok követése
npm run docker:dev:logs
# Egyedi Docker build
npm run docker:build
# Standalone container futtatása
npm run docker:run
```
## 📁 Adatok Perzisztencia
A következő Docker volume-ok tárolják az adatokat:
- `mongodb_data` - MongoDB adatok
- `loki_data` - Log adatok
- `grafana_data` - Grafana beállítások
Adatok törlése:
```bash
docker-compose -f docker-compose.dev.yml down -v
```
## 🔄 Hot Reload
A fejlesztői környezet támogatja a hot reload-ot:
- Kód változások automatikusan frissülnek
- MongoDB adatok megmaradnak restart után
- Volume mounting biztosítja a gyors fejlesztést
## 🚨 Hibaelhárítás
### Port foglaltság
Ha a 3000-es port foglalt:
```bash
# Meglévő process keresése
lsof -i :3000
# Vagy másik port használata
docker-compose -f docker-compose.dev.yml up --build -p 3002:3000
```
### MongoDB kapcsolat hiba
```bash
# Container logok ellenőrzése
docker logs mozdit-mongodb-dev
# Újraindítás
docker-compose -f docker-compose.dev.yml restart mongodb
```
### Teljes tisztítás
```bash
# Minden container és volume törlése
docker-compose -f docker-compose.dev.yml down -v --remove-orphans
docker system prune -a
```
## 🏗️ Production Build
```bash
# Production image build
docker build -t mozdit-app:latest ./proto
# Production futtatás
docker run -p 3000:3000 \
-e NODE_ENV=production \
-e MONGODB_URI=mongodb://your-prod-db:27017/mozdit \
mozdit-app:latest
```
## 📝 Megjegyzések
- A fejlesztői környezet **nem production-ready**
- Alapértelmezett jelszavak csak fejlesztésre
- SSL/TLS nincs konfigurálva
- Biztonsági headers minimálisak