Postgres on the VPS: a database per preview, or a schema per preview on a shared server? #347
Labels
No labels
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
spec
wayfinder:grilling
wayfinder:map
wayfinder:prototype
wayfinder:research
wayfinder:task
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Blocks
#348 What a finished Game keeps, and which guest identity owns it
amaurycoudr/chess-project
Reference
amaurycoudr/chess-project#347
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Parent
#346
Question
Production and up to five PR previews run as Docker Compose stacks on one VPS (ADR 0029). Each stack needs Postgres. What are the options — a Postgres container per stack, one shared Postgres with a database or schema per stack, a managed service — and their cost in VPS memory, backup story for production, migration flow in CI (drizzle-kit), and teardown when a preview closes? Surface the facts the decision needs; the decision follows in grilling.
Research notes: https://github.com/amaurycoudr/chess-project/blob/research/postgres-on-vps/docs/research/postgres-on-vps.md
postgres:18container uses about 25 MiB (measured locally), so six cost about 150 MiB. Each can grow to its own 128 MBshared_buffers, which a-cflag can cap on previews.down.sh --volumesandverify-gone.shalready remove a preview's data. A shared server needsDROP DATABASE … WITH (FORCE)and an admin credential instead. Point-in-time recovery restores only a whole server, so production backups stay simpler on a server of its own.--prodand copies onlydist, so migrating on boot with drizzle-orm'smigrate()means also shipping the migrations folder.drizzle-kit migratewould need the database reachable from the runner./var/lib/postgresql, and a scheduledpg_dumpof production copied off the VPS.Resolution
deploy/down.sh --volumes, and production has a server of its own, which keeps backups simple.127.0.0.1only and reached through an SSH tunnel. No public route.drizzle-kit studiostays available for local dev.pg_dumpof production copied off the VPS; migrations on API boot vs from the runner; secrets delivery when Compose runs on the runner against the VPS daemon; the Gateway's current licence terms.Research: docs/research/postgres-on-vps.md on research/postgres-on-vps
mentioned in issue #348
mentioned in issue #346
marked this issue as related to #346
marked this issue as related to #348