Files
websitedev/docker-compose.dev.yml
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

114 lines
3.1 KiB
YAML
Executable File

services:
# Next.js Application
app:
build:
context: ./proto
dockerfile: Dockerfile
target: builder # Use builder stage for development
container_name: mozdit-app-dev
ports:
- "127.0.0.1:8080:3000"
environment:
- NODE_ENV=development
# WHY authSource=admin: the mongodb service below only creates a root
# user (via MONGO_INITDB_ROOT_USERNAME/PASSWORD), which forces --auth
# on the mongod process — an unauthenticated URI fails every query
# with "Command find requires authentication" (MITHOME-98).
- MONGODB_URI=mongodb://admin:password123@mongodb:27017/mozdit?authSource=admin
- MONGODB_DB=mozdit
# Dev-only, nem titkos (MITHOME-97) — Payload ez nélkül el sem indul
# ("missing secret key"), és ez a compose fájl eddig nem adta át.
- PAYLOAD_SECRET=dev-only-insecure-secret-do-not-use-in-staging-or-prod
- NEXT_PUBLIC_SITE_URL=http://localhost:8080
- NEXT_PUBLIC_COMPANY_NAME=mozdIT Bt.
- NEXT_PUBLIC_CONTACT_EMAIL=info@mozdit.hu
- NEXT_PUBLIC_WEBMAIL_URL=https://mail.mozdit.hu
- LOKI_HOST=http://loki:3100
volumes:
- ./proto:/app
- /app/node_modules
- /app/.next
command: npm run dev
depends_on:
- mongodb
- loki
networks:
- mozdit-network
restart: unless-stopped
# MongoDB Database
mongodb:
image: mongo:7.0
container_name: mozdit-mongodb-dev
ports:
- "127.0.0.1:27018:27017"
environment:
- MONGO_INITDB_ROOT_USERNAME=admin
- MONGO_INITDB_ROOT_PASSWORD=password123
- MONGO_INITDB_DATABASE=mozdit
volumes:
- mongodb_data:/data/db
- ./docker/mongodb/init-mongo.js:/docker-entrypoint-initdb.d/init-mongo.js:ro
networks:
- mozdit-network
restart: unless-stopped
# MongoDB Express (Web UI)
mongo-express:
image: mongo-express:1.0.2
container_name: mozdit-mongo-express-dev
ports:
- "127.0.0.1:8081:8081"
environment:
- ME_CONFIG_MONGODB_ADMINUSERNAME=admin
- ME_CONFIG_MONGODB_ADMINPASSWORD=password123
- ME_CONFIG_MONGODB_URL=mongodb://admin:password123@mongodb:27017/
- ME_CONFIG_BASICAUTH=false
depends_on:
- mongodb
networks:
- mozdit-network
restart: unless-stopped
# Loki for Logging
loki:
image: grafana/loki:2.9.0
container_name: mozdit-loki-dev
ports:
- "127.0.0.1:3100:3100"
command: -config.file=/etc/loki/local-config.yaml
volumes:
- loki_data:/loki
networks:
- mozdit-network
restart: unless-stopped
# Grafana for Monitoring
grafana:
image: grafana/grafana:10.2.0
container_name: mozdit-grafana-dev
ports:
- "127.0.0.1:3001:3000"
environment:
- GF_SECURITY_ADMIN_PASSWORD=admin123
volumes:
- grafana_data:/var/lib/grafana
- ./docker/grafana/provisioning:/etc/grafana/provisioning
depends_on:
- loki
networks:
- mozdit-network
restart: unless-stopped
volumes:
mongodb_data:
driver: local
loki_data:
driver: local
grafana_data:
driver: local
networks:
mozdit-network:
driver: bridge