diff --git a/docker-compose.postgres.yml b/docker-compose.postgres.yml index c677c6f4c..df2aef166 100644 --- a/docker-compose.postgres.yml +++ b/docker-compose.postgres.yml @@ -1,6 +1,10 @@ # TREK on a Postgres database instead of the SQLite file. See the wiki page # Database-Postgres for what this changes, the requirements and the backups. # +# Needs Docker Compose 2.23.1 or newer, which reads the inline config +# (configs.trek-db-role below). An older Compose, as some NAS bundles ship, +# refuses the whole file with "Additional property content is not allowed". +# # Set two passwords in a .env file beside this file (or in the shell) before # the first start: # POSTGRES_ADMIN_PASSWORD= the database's superuser, postgres diff --git a/wiki/Database-Postgres.md b/wiki/Database-Postgres.md index 118474bb1..655e3f9d1 100644 --- a/wiki/Database-Postgres.md +++ b/wiki/Database-Postgres.md @@ -67,6 +67,8 @@ The password is passed to the tools in the `PGPASSWORD` environment variable of [`docker-compose.postgres.yml`](https://github.com/liketrek/TREK/blob/main/docker-compose.postgres.yml) runs a `postgres:18` service beside TREK, on a named volume, with the TREK container waiting for the database to pass its health check. Set two passwords in a `.env` file beside it before the first start: `POSTGRES_ADMIN_PASSWORD` for the database's superuser `postgres`, and `POSTGRES_PASSWORD` for the role `trek` that TREK connects as. On the database's first start, the superuser creates the role `trek`, which owns TREK's database and is not a superuser. See [Install: Docker Compose](Install-Docker-Compose#running-on-postgres). +The file needs Docker Compose 2.23.1 or newer: it creates that role from an inline config, which an older Compose refuses with `Additional property content is not allowed` before anything starts. Some NAS bundles ship an older Compose; check with `docker compose version`. + If that first start fails because a password is missing, the database is already created but without the role `trek`, and a restart does not create it any more. Set the password and start again on a new volume: `docker compose -f docker-compose.postgres.yml down -v` removes the database volume with it, so run it only while that database is still empty. #### Postgres versions and the volume path diff --git a/wiki/Install-Docker-Compose.md b/wiki/Install-Docker-Compose.md index 8811d0c8e..c48d7b96b 100644 --- a/wiki/Install-Docker-Compose.md +++ b/wiki/Install-Docker-Compose.md @@ -118,7 +118,7 @@ See [Reverse-Proxy](Reverse-Proxy) for complete proxy configuration examples. ## Running on Postgres -[`docker-compose.postgres.yml`](https://github.com/liketrek/TREK/blob/main/docker-compose.postgres.yml) runs TREK beside a `postgres:18` service instead of the SQLite file. Its `db` service keeps the database in a named volume and publishes no port, and the `app` service (container `trek`) waits for the database's health check before it starts. The `app` service sets only a few environment variables; add the others you need (`APP_URL`, `FORCE_HTTPS`, OIDC, SMTP and so on) as in `docker-compose.yml`. +[`docker-compose.postgres.yml`](https://github.com/liketrek/TREK/blob/main/docker-compose.postgres.yml) runs TREK beside a `postgres:18` service instead of the SQLite file. Its `db` service keeps the database in a named volume and publishes no port, and the `app` service (container `trek`) waits for the database's health check before it starts. The `app` service sets only a few environment variables; add the others you need (`APP_URL`, `FORCE_HTTPS`, OIDC, SMTP and so on) as in `docker-compose.yml`. It needs Docker Compose 2.23.1 or newer (`docker compose version`); an older one refuses the file with `Additional property content is not allowed`. The volume path depends on the Postgres major version: `postgres:18` keeps its data under `/var/lib/postgresql`, the images for 14 to 17 under `/var/lib/postgresql/data`. Change the image tag and the volume path together, and only for a new database. A database stays on the major it was created with, so when you update the compose file later, keep your image tag and volume path; moving to another major needs `pg_upgrade` or a backup and restore, never just a new tag. See [Database: Postgres](Database-Postgres#postgres-versions-and-the-volume-path).