mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-28 23:50:08 +00:00
feat(db): run TREK on PostgreSQL
TREK runs on PostgreSQL when TREK_DB_URL is set, and on SQLite as before otherwise: an engine port under src/db/engine, the dialect helpers under src/db/dialect, a Postgres baseline for the migrations up to the cut, pg_dump/pg_restore backups, a probe of every repository method against a real server and a Postgres test lane in CI.
This commit is contained in:
@@ -24,7 +24,7 @@ The compose file ships with several hardening options enabled by default:
|
||||
|
||||
| Host path | Container path | Contents |
|
||||
|---|---|---|
|
||||
| `./data` | `/app/data` | SQLite database, logs, `.jwt_secret`, `.encryption_key` |
|
||||
| `./data` | `/app/data` | SQLite database (not used with `TREK_DB_URL`), logs, `.jwt_secret`, `.encryption_key`, pre-migration and pre-restore copies |
|
||||
| `./uploads` | `/app/uploads` | Uploaded files (photos, documents, covers, avatars) |
|
||||
|
||||
### Named Volumes
|
||||
@@ -116,6 +116,21 @@ This compose file is designed for deployments where a reverse proxy (nginx, Cadd
|
||||
|
||||
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:17` service instead of the SQLite file. Its `db` service keeps the database in a named volume and publishes no port, and the `trek` service waits for the database's health check before it starts.
|
||||
|
||||
Put a password in a `.env` file beside the compose file, then start it:
|
||||
|
||||
```bash
|
||||
echo 'POSTGRES_PASSWORD=<a long random value>' > .env
|
||||
docker compose -f docker-compose.postgres.yml up -d
|
||||
```
|
||||
|
||||
The password goes into `TREK_DB_URL`, so use URL-safe characters or percent-encode it. Without `POSTGRES_PASSWORD` the database does not initialize and TREK does not start. To run it against a database that already exists elsewhere, use the plain `docker-compose.yml` and set `TREK_DB_URL` yourself.
|
||||
|
||||
Read [Database: Postgres](Database-Postgres) before you use it. It covers the requirements, SSL, backups and restores, and the limits of a Postgres install.
|
||||
|
||||
## Next Steps
|
||||
|
||||
- [Environment-Variables](Environment-Variables) — full variable reference
|
||||
|
||||
Reference in New Issue
Block a user