teqo-backup/docker-compose.yml
Francisco Ignácio Fontoura Solla 4f0f997c32 Isolate local/dev and tests from the production database
Local dev and the test suite previously defaulted to the live production
Neon database, and running the tests mutated prod data. Add guardrails plus
a proper local Postgres + migrations workflow so production can't be hit by
mistake:

- docker-compose: local Postgres 17 (matches prod) + auto-created teqo_test
- dev guard refuses a non-local DATABASE_URL; tests refuse non-_test databases
- .env.test isolates the suite; vitest/playwright load it and fail closed
- Payload migrations set up (push disabled); build runs `payload migrate`,
  so deploys apply pending migrations to prod automatically
- baseline `initial` migration + idempotent consent.text varchar->jsonb fix
- `pnpm db:pull` copies prod content locally, excluding supporter PII
- docs (README, AGENTS.md) + agent skills for the local-db/migration workflow
2026-07-15 13:52:30 -03:00

28 lines
1,015 B
YAML

services:
# Local development database. This is the ONLY database local dev and the
# test suite should ever touch — never point DATABASE_URL at the production
# Neon instance for local work (see the guard in scripts/guard-dev-db.mjs).
postgres:
# Pinned to match the production Neon major version (17), so pg_dump/restore
# from prod (see `pnpm db:pull`) works without version mismatches.
image: postgres:17-alpine
restart: unless-stopped
environment:
POSTGRES_USER: teqo
POSTGRES_PASSWORD: teqo
POSTGRES_DB: teqo
ports:
- '5432:5432'
volumes:
- pgdata:/var/lib/postgresql/data
# Runs only on first initialization of the volume. Creates the dedicated
# teqo_test database so automated tests never share state with dev data.
- ./docker/postgres/init:/docker-entrypoint-initdb.d:ro
healthcheck:
test: ['CMD-SHELL', 'pg_isready -U teqo -d teqo']
interval: 5s
timeout: 5s
retries: 10
volumes:
pgdata: