Compose and Homebrew: connect the app to PostgreSQL without superuser rights
- github
- github/openchronology/timeline-app
- commit
- main
- github/athanclark
Compose's app, mail worker, seed and migrations connected as the image's bootstrap superuser, so a bug that reached the database could run programs or read files in the database container. A one-shot database-setup service (the postgres image, deploy/database-setup.sh) now runs as the superuser before each migration: it creates pgmp, which only a superuser may, and the openchronology_app role, which logs in with APP_DATABASE_PASSWORD, is not a superuser, and owns the database. Everything else connects as that role, so it owns the tables it migrates, as on every other package (the server disables its own triggers during purges, which needs ownership). A database from before the role existed has its tables, sequences, functions and types handed over; pgmp's own objects stay with the superuser. Compose refuses to start until APP_DATABASE_PASSWORD is set. Homebrew's setup likewise creates an openchronology role that owns the database, creates pgmp as you (the cluster's superuser), and writes a DATABASE_URL for that role. Existing installations are left as they are. The app image's files now belong to root, so the node user it runs as can no longer change them; only Next.js's cache folder is node's. Operators are told to empty ADMIN_INITIAL_PASSWORD once they have signed in and changed it. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_011fFY8eruEi1xAkkMBni13B https://github.com/openchronology/timeline-app/commit/cec3eb1d249ce07a68051686a14602c0f4e9c617
Open Compose and Homebrew: connect the app to PostgreSQL without superuser rights in the timeline