feat(database): connect postgres via socket and read config from env _FILE secrets (#2061)

* feat(database): connect postgres via socket

* feat(config): read env var secrets from file

* docs: explain env var secrets

* refactor: generate postgres dsn
This commit is contained in:
ze0s 2025-05-05 21:15:24 +02:00 committed by GitHub
parent 24648e45f7
commit fe4f385a22
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 345 additions and 76 deletions

View file

@ -317,7 +317,7 @@ If you are not running a reverse proxy change `host` in the `config.toml` to `0.
The following environment variables can be used:
| Variable | Description | Default |
| -------------------------------------- | -------------------------------------------------------- | ---------------------------------------- |
|----------------------------------------|----------------------------------------------------------|------------------------------------------|
| `AUTOBRR__HOST` | Listen address | `127.0.0.1` |
| `AUTOBRR__PORT` | Listen port | `7474` |
| `AUTOBRR__BASE_URL` | Base URL for reverse proxy | `/` |
@ -329,12 +329,16 @@ The following environment variables can be used:
| `AUTOBRR__CUSTOM_DEFINITIONS` | Path to custom indexer definitions | - |
| `AUTOBRR__CHECK_FOR_UPDATES` | Enable update checks | `true` |
| `AUTOBRR__DATABASE_TYPE` | Database type (sqlite/postgres) | `sqlite` |
| `AUTOBRR__DATABASE_DSN` | Database connection string. Use this or individual vars | - |
| `AUTOBRR__POSTGRES_HOST` | PostgreSQL host | - |
| `AUTOBRR__POSTGRES_PORT` | PostgreSQL port | `5432` |
| `AUTOBRR__POSTGRES_DATABASE` | PostgreSQL database name | - |
| `AUTOBRR__POSTGRES_DB` | PostgreSQL database name | - |
| `AUTOBRR__POSTGRES_USER` | PostgreSQL username | - |
| `AUTOBRR__POSTGRES_PASS` | PostgreSQL password | - |
| `AUTOBRR__POSTGRES_PASSWORD` | PostgreSQL password | - |
| `AUTOBRR__POSTGRES_SSLMODE` | PostgreSQL SSL mode | `disable` |
| `AUTOBRR__POSTGRES_SOCKET` | PostgreSQL unix socket | - |
| `AUTOBRR__POSTGRES_EXTRA_PARAMS` | Additional PostgreSQL parameters | - |
| `AUTOBRR__OIDC_ENABLED` | Enable OpenID Connect authentication | `false` |
| `AUTOBRR__OIDC_ISSUER` | OIDC issuer URL | - |
@ -347,6 +351,52 @@ The following environment variables can be used:
| `AUTOBRR__METRICS_PORT` | Metrics listen port | `9074` |
| `AUTOBRR__METRICS_BASIC_AUTH_USERS` | Metrics basic auth users | - |
#### Docker secrets
All ENV vars have a `_FILE` option where it can read contents from a file, such as docker secrets. See the example below:
```yaml
services:
autobrr:
image: ghcr.io/autobrr/autobrr:latest
container_name: autobrr
volumes:
- ./config:/config
ports:
- "7474:7474"
restart: unless-stopped
environment:
- AUTOBRR__DATABASE_TYPE=postgres
- AUTOBRR__POSTGRES_HOST=postgres
- AUTOBRR__POSTGRES_PORT=5432
- AUTOBRR__POSTGRES_USER=autobrr
- AUTOBRR__POSTGRES_PASSWORD_FILE=/run/secrets/db_password
- AUTOBRR__POSTGRES_DB=autobrr
secrets:
- db_password
postgres:
image: postgres:12.10
container_name: postgres
volumes:
- postgres:/var/lib/postgresql/data
ports:
- "5432:5432"
environment:
- POSTGRES_USER=autobrr
- POSTGRES_PASSWORD_FILE=/run/secrets/db_password
- POSTGRES_DB=autobrr
secrets:
- db_password
secrets:
db_password:
file: db_password.txt
volumes:
postgres:
```
## Community
Join our friendly and welcoming community on [Discord](https://discord.gg/WQ2eUycxyT)! Connect with fellow autobrr users, get advice, and share your experiences. Whether you're seeking help, wanting to contribute, or just looking to discuss your ideas, our community is a hub of discussion and support. We're all here to help each other out, so don't hesitate to jump in!