- staging/prod: postgres:16-alpine per the llmdev Docker spec (healthcheck, log and memory limits, no host port); the app builds DATABASE_URI from POSTGRES_PASSWORD and waits for a healthy database; MongoDB kept for one release (rollback path, transfer source) - dev: PostgreSQL replaces MongoDB and Mongo Express (host port 5433, checked and registered); integration test rewritten with pg - deploy.sh: pg_dump (and, during the switch, mongodump) before the build - pg/@types/pg pinned to the adapter's 8.20.0 (one copy, no type clash) - docs: CLAUDE.md, architecture/testing steering, deploy workflow, DOCKER.md; staging switch runbook in the design Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
109 lines
3.7 KiB
YAML
109 lines
3.7 KiB
YAML
services:
|
|
# Next.js Application (Production Mode)
|
|
app:
|
|
build:
|
|
context: ./proto
|
|
dockerfile: Dockerfile
|
|
target: runner # Use runner stage for production (smaller size, no dev dependencies)
|
|
args:
|
|
- NEXT_PUBLIC_SITE_URL=${NEXT_PUBLIC_SITE_URL:-https://mozdit.hu}
|
|
- DEPLOY_VERSION=${DEPLOY_VERSION:-unversioned}
|
|
container_name: mozdit-app-prod
|
|
ports:
|
|
- "127.0.0.1:8080:3000" # Belső port — csak nginx reverse proxy-n keresztül elérhető
|
|
environment:
|
|
- NODE_ENV=production
|
|
# MITHOME-136: PostgreSQL (the site's own database on the shared server).
|
|
# Built from POSTGRES_PASSWORD so the secret lives in one place; no
|
|
# fallback — a missing password must fail the deploy loudly. Use a
|
|
# URL-safe password (e.g. `openssl rand -hex 32`).
|
|
- DATABASE_URI=postgresql://${POSTGRES_USER:-mozdit_web}:${POSTGRES_PASSWORD:?POSTGRES_PASSWORD is required}@postgres:5432/mozdit_web
|
|
# No fallback either (MITHOME-97): Payload refuses to start without a real
|
|
# secret ("missing secret key"), which is exactly what we want here.
|
|
- PAYLOAD_SECRET=${PAYLOAD_SECRET}
|
|
- NEXT_PUBLIC_SITE_URL=${NEXT_PUBLIC_SITE_URL:-https://mozdit.hu}
|
|
- NEXT_PUBLIC_COMPANY_NAME=${NEXT_PUBLIC_COMPANY_NAME:-mozdIT Bt.}
|
|
- NEXT_PUBLIC_CONTACT_EMAIL=${NEXT_PUBLIC_CONTACT_EMAIL:-info@mozdit.hu}
|
|
volumes:
|
|
# Payload helyi upload storage — lásd docker-compose.staging.yml azonos
|
|
# kommentjét (MITHOME-97).
|
|
- media_data_prod:/app/media
|
|
depends_on:
|
|
postgres:
|
|
condition: service_healthy
|
|
healthcheck:
|
|
test: ["CMD", "wget", "-qO-", "http://127.0.0.1:3000/api/health"]
|
|
interval: 30s
|
|
timeout: 10s
|
|
retries: 3
|
|
start_period: 60s
|
|
networks:
|
|
- mozdit-network
|
|
restart: always
|
|
logging:
|
|
driver: "json-file"
|
|
options:
|
|
max-size: "10m"
|
|
max-file: "3"
|
|
|
|
# PostgreSQL (MITHOME-136) — llmdev Docker spec: healthcheck, log limit,
|
|
# memory limit, no host port (the app reaches it on the project network).
|
|
postgres:
|
|
image: postgres:16-alpine
|
|
container_name: mozdit-postgres-prod
|
|
environment:
|
|
- POSTGRES_DB=mozdit_web
|
|
- POSTGRES_USER=${POSTGRES_USER:-mozdit_web}
|
|
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD:?POSTGRES_PASSWORD is required}
|
|
volumes:
|
|
- postgres_data_prod:/var/lib/postgresql/data
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-mozdit_web} -d mozdit_web"]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 5
|
|
start_period: 20s
|
|
deploy:
|
|
resources:
|
|
limits:
|
|
memory: 1G
|
|
logging:
|
|
driver: "json-file"
|
|
options:
|
|
max-size: "100m"
|
|
max-file: "3"
|
|
networks:
|
|
- mozdit-network
|
|
restart: unless-stopped
|
|
|
|
# MongoDB — MITHOME-136: no longer used by the app. Kept for one release as
|
|
# the rollback path and the source of the one-off content transfer
|
|
# (proto/scripts/transfer-content.ts); remove afterwards (tasks 4.3).
|
|
mongodb:
|
|
image: mongo:7.0
|
|
container_name: mozdit-mongodb-prod
|
|
ports:
|
|
- "127.0.0.1:27018:27017" # Belső port, nem publikus az internet felé
|
|
environment:
|
|
- MONGO_INITDB_ROOT_USERNAME=${MONGO_ROOT_USER:-admin}
|
|
# No weak default password: a missing value must fail the container loudly.
|
|
- MONGO_INITDB_ROOT_PASSWORD=${MONGO_ROOT_PASSWORD}
|
|
- MONGO_INITDB_DATABASE=mozdit
|
|
volumes:
|
|
- mongodb_data_prod:/data/db
|
|
networks:
|
|
- mozdit-network
|
|
restart: always
|
|
|
|
volumes:
|
|
postgres_data_prod:
|
|
driver: local
|
|
mongodb_data_prod:
|
|
driver: local
|
|
media_data_prod:
|
|
driver: local
|
|
|
|
networks:
|
|
mozdit-network:
|
|
driver: bridge
|