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
@@ -59,6 +59,29 @@ if [ "$ENV" = "production" ] && grep -hsE '^[[:space:]-]*NEXT_PUBLIC_DEPLOY_ENV[
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 2b2. Adatbázis-mentés — build ELŐTT (MITHOME-111, MITHOME-136)
|
||||
# WHY: a prodMigrations induláskor sémát módosíthat; egy hibás kiadás után
|
||||
# a deploy előtti mentésből kell tudni visszaállni. Ami fut, azt mentjük:
|
||||
# PostgreSQL (pg_dump, egyedi formátum) és — az átállás idejére — MongoDB.
|
||||
CONTAINER_ENV="$ENV"
|
||||
[ "$ENV" = "production" ] && CONTAINER_ENV="prod"
|
||||
BACKUP_DIR="$HOME/backups"
|
||||
STAMP="$(date +%Y%m%d-%H%M%S)"
|
||||
mkdir -p "$BACKUP_DIR" # shared directory: only our own files get chmod 600
|
||||
if docker ps --format '{{.Names}}' | grep -qx "mozdit-postgres-${CONTAINER_ENV}"; then
|
||||
PG_BACKUP="$BACKUP_DIR/mozdit-${ENV}-${STAMP}-pre-deploy.pgdump"
|
||||
PG_USER="$(env_value POSTGRES_USER)"
|
||||
docker exec "mozdit-postgres-${CONTAINER_ENV}" pg_dump -U "${PG_USER:-mozdit_web}" -Fc mozdit_web > "$PG_BACKUP"
|
||||
chmod 600 "$PG_BACKUP"
|
||||
echo "💾 PostgreSQL-mentés: $PG_BACKUP"
|
||||
fi
|
||||
if docker ps --format '{{.Names}}' | grep -qx "mozdit-mongodb-${CONTAINER_ENV}"; then
|
||||
MONGO_BACKUP="$BACKUP_DIR/mozdit-${ENV}-${STAMP}-pre-deploy.archive"
|
||||
docker exec "mozdit-mongodb-${CONTAINER_ENV}" sh -c 'mongodump --quiet --username "$MONGO_INITDB_ROOT_USERNAME" --password "$MONGO_INITDB_ROOT_PASSWORD" --authenticationDatabase admin --db mozdit --archive' > "$MONGO_BACKUP"
|
||||
chmod 600 "$MONGO_BACKUP"
|
||||
echo "💾 MongoDB-mentés: $MONGO_BACKUP"
|
||||
fi
|
||||
|
||||
# 2c. Port-ellenőrzés — build ELŐTT, hogy egy ütközés ne egy teljes build után
|
||||
# derüljön ki. A saját projekt (újraindítandó) konténerei által foglalt port
|
||||
# rendben van; minden más foglaltság hiba. Szabály: llmdev Docker-háttér
|
||||
|
||||
Reference in New Issue
Block a user