Files
uberbringer/docs/docker.md
T
57_WolveandClaude Opus 5.5 66531e7314
Security / Vulnerability check (push) Successful in 45s
Test / Lint and test (push) Successful in 2m1s
Replace ntfy.state_dir with a top-level [state] dir
The job store is to keep its database in the directory that holds the
ntfy subscriptions' state files, so the directory moves to a section
of its own: [state] dir, or UBERBRINGER_STATE_DIR, in place of
[ntfy] state_dir. For now only the subscriptions use it. It still has
no default and is still required with a subscription, and the checks
at start name state.dir in their errors.

install.sh writes [state] dir into new configs, and the Docker image
sets UBERBRINGER_STATE_DIR. ntfy.state_dir has never been in a
release, so its CHANGELOG entry changes in place and there is no
fallback: a config that still sets it fails to load with an unknown
key until the line moves to [state].

The image itself was not built, since the workstation has no Docker.

Part of stage 1b of docs/plans/job-store.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-01 12:21:29 -06:00

74 lines
2.8 KiB
Markdown

# Running in Docker
The image built from the root `Dockerfile` is a microservice for running
behind your own reverse proxy. It contains no proxy and no TLS: it serves
plain HTTP on port 8080, and the proxy terminates HTTPS.
```sh
docker build -t uberbringer .
docker run -d -p 127.0.0.1:8080:8080 -v "$PWD/config.toml:/etc/uberbringer/config.toml:ro" uberbringer
```
The examples publish the port on the host's loopback address only, for a
proxy on the host; a proxy in another container reaches it over a shared
Docker network instead, with no `-p` at all. Publish port 8080 only to the
proxy, never directly to the internet.
## The config
In the mounted `config.toml` ([configuration.md](configuration.md)):
- Set `bind_ip = "0.0.0.0"` in `[webserver]`.
- Set `trusted_proxies` to the address the proxy's requests come from: its
container network (e.g. `["172.18.0.0/16"]`), or for a proxy on the host,
the Docker bridge's gateway (usually `172.17.0.1`). Have the proxy set
`X-Real-IP` to the client's address. Otherwise every request appears to
come from the proxy, and all clients share one rate limit.
- Let the proxy pass request bodies up to `webserver.body_limit` (4 MiB by
default).
The settings can come from
[environment variables](configuration.md#environment-variables) instead. To
run without a config file, set `UBERBRINGER_CONFIG` empty and put the
variables in an env file that only you can read
(`chmod 600 uberbringer.env`), so the secret stays off the command line:
```text
UBERBRINGER_CONFIG=
UBERBRINGER_WEBSERVER_BIND_IP=0.0.0.0
UBERBRINGER_WEBSERVER_TRUSTED_PROXIES=172.18.0.0/16
UBERBRINGER_API_SECRET=<the output of uberbringer secret>
UBERBRINGER_PRINTER_ADDRESS=192.168.1.245
```
```sh
docker run -d -p 127.0.0.1:8080:8080 --env-file uberbringer.env uberbringer
```
## Health checks
For container health checks, use `GET /` to see whether the daemon is up.
`/healthz` answers `503` while the printer is unreachable, so it suits
alerting better than restarting the container.
## ntfy subscriptions
[ntfy subscriptions](ntfy.md) keep their state in `/var/lib/uberbringer`,
which the image sets as `state.dir`. Mount a volume there: without one
the state lives in the container, and a new container, after a pull or an
upgrade, forgets what was printed and what was held.
```sh
docker run -d -p 127.0.0.1:8080:8080 -v "$PWD/config.toml:/etc/uberbringer/config.toml:ro" \
-v uberbringer-state:/var/lib/uberbringer uberbringer
```
Subscriptions are set in `config.toml` only, so a container with one needs
the file. The image runs as user and group `10001`, so give a token file
to that ID, mode `600`, and mount it read-only next to the config:
```sh
sudo chown 10001:10001 ntfy.token && sudo chmod 600 ntfy.token
docker run ... -v "$PWD/ntfy.token:/etc/uberbringer/ntfy.token:ro" uberbringer
```