feat(infra): PostgreSQL in the compose stacks, automatic pre-deploy backups (MITHOME-136)
- 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>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
a68fb94b61
commit
0ec5714676
+48
-6
@@ -13,10 +13,11 @@ services:
|
||||
- "127.0.0.1:8080:3000" # Belső port — csak nginx reverse proxy-n keresztül elérhető
|
||||
environment:
|
||||
- NODE_ENV=production
|
||||
# No fallback for MONGODB_URI: with root auth enabled on the Mongo container an
|
||||
# unauthenticated default URI would silently break the app — fail loudly instead.
|
||||
- MONGODB_URI=${MONGODB_URI}
|
||||
- MONGODB_DB=${MONGODB_DB:-mozdit}
|
||||
# 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}
|
||||
@@ -28,7 +29,14 @@ services:
|
||||
# kommentjét (MITHOME-97).
|
||||
- media_data_prod:/app/media
|
||||
depends_on:
|
||||
- mongodb
|
||||
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
|
||||
@@ -38,7 +46,39 @@ services:
|
||||
max-size: "10m"
|
||||
max-file: "3"
|
||||
|
||||
# MongoDB Database
|
||||
# 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
|
||||
@@ -56,6 +96,8 @@ services:
|
||||
restart: always
|
||||
|
||||
volumes:
|
||||
postgres_data_prod:
|
||||
driver: local
|
||||
mongodb_data_prod:
|
||||
driver: local
|
||||
media_data_prod:
|
||||
|
||||
Reference in New Issue
Block a user