Files
homebrewery-oidc/docs/dockerhub/README.md
T
dev-bot BotandClaude Sonnet 5.5 1fe99698fb
CI / App (npm ci + Build, ESLint, Stylelint, Jest) (pull_request) Canceled after 35s
CI / Storage (mongo) (pull_request) Canceled after 0s
CI / Storage (postgres) (pull_request) Canceled after 0s
docs(dockerhub): englische Repo-Beschreibung und Workflow zum Publizieren (#32)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-26 11:33:28 +00:00

131 lines
9.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# homebrewery-oidc
[Homebrewery](https://github.com/naturalcrit/homebrewery) fork for self-hosting: **OIDC login** (Keycloak, authentik, any OpenID Connect provider), **PostgreSQL 18** (or MongoDB) storage, a **Git backend** (brews live in your own Git repositories) and **image upload** into those repositories.
- Source, issues, docs: https://git.morlana.online/f.weber/homebrewery-oidc/src/branch/main/README.md (repository: https://git.morlana.online/f.weber/homebrewery-oidc)
- Fork overview and CI/tag details: https://git.morlana.online/f.weber/homebrewery-oidc/src/branch/main/FORK.md
- Upstream: https://github.com/naturalcrit/homebrewery. License: MIT (see https://git.morlana.online/f.weber/homebrewery-oidc/src/branch/main/license).
The image contains no configuration or secrets. Everything is configured with environment variables at runtime. The app listens on port **8000**.
## Tags
| Tag | Meaning |
| --- | --- |
| `vX.Y.Z` | Release, e.g. `v1.0.0`. Pin this in production. |
| `latest` | Newest release (never a pre-release or a development build). |
The same images are also published to the Gitea registry `git.morlana.online/f.weber/homebrewery-oidc` (additionally with `main` and `sha-<7>` development tags).
## Quick start (Docker Compose, PostgreSQL 18)
1. Create a directory and download the two template files:
```bash
mkdir homebrewery && cd homebrewery
curl -fsSLO https://git.morlana.online/f.weber/homebrewery-oidc/src/branch/main/docs/deploy/compose.yaml
curl -fsSL https://git.morlana.online/f.weber/homebrewery-oidc/src/branch/main/docs/deploy/env.example -o .env
```
(The files are also linked in https://git.morlana.online/f.weber/homebrewery-oidc/src/branch/main/docs/deploy/README.md; the guide there is in German, this page is the English summary.)
2. Edit `.env`. Required: `POSTGRES_PASSWORD`, `HB_PUBLIC_URL`, `HB_SESSION_SECRET`, `HB_OIDC_ISSUER`, `HB_OIDC_CLIENT_ID`, `HB_OIDC_CLIENT_SECRET`.
Set `HB_IMAGE` to pin a release, e.g. `HB_IMAGE=<DOCKER_HUB_USER>/homebrewery-oidc:v1.0.0`. Without it the template uses the Gitea registry image `:latest`.
Generate secrets with `openssl rand -base64 48` (session secret) and `openssl rand -hex 24` (database password: only URL-safe characters, it ends up in the Postgres URL).
3. Register the redirect URI `<HB_PUBLIC_URL>/auth/oidc/callback` at your identity provider (confidential client, `client_secret_basic`).
4. Start:
```bash
docker compose config -q # validates syntax and required variables
docker compose up -d
docker compose logs homebrewery | head
curl -I http://localhost:8000/ # HTTP 200 once started
```
TLS and a reverse proxy (nginx, Traefik, Caddy in front of port 8000) are not part of the template. `HB_PUBLIC_URL` must be the externally reachable `https://` URL, without a trailing slash. On startup the app contacts the identity provider (OIDC discovery) and PostgreSQL (version 18 or newer is required, otherwise it aborts with a clear message). Database migrations run automatically.
**Important:** the container only sees variables listed under `environment:` (or loaded via `env_file:`). An entry in `.env` alone only fills the `${...}` placeholders of the Compose file. If you write your own Compose file, pass every `HB_*` variable explicitly, especially `HB_GIT_TOKEN_KEY`.
### MongoDB instead of PostgreSQL
Set `HB_DB_DRIVER=mongo` (the default when unset) and `MONGODB_URI=mongodb://mongodb:27017/homebrewery`, add a `mongo` service, and drop `HB_POSTGRES_URL`. Exactly one backend is active per instance; there is no data migration between them (single brews: download/import). Note that MongoDB 5+ needs a CPU with AVX.
## Configuration
All settings are environment variables. Full reference: https://git.morlana.online/f.weber/homebrewery-oidc/src/branch/main/docs/auth/README.md (login), https://git.morlana.online/f.weber/homebrewery-oidc/src/branch/main/docs/storage/README.md (database), https://git.morlana.online/f.weber/homebrewery-oidc/src/branch/main/docs/git/README.md (Git backend, image upload).
### Storage
| Variable | Required | Default | Description |
| --- | --- | --- | --- |
| `HB_DB_DRIVER` | no | `mongo` | `mongo` or `postgres` |
| `HB_POSTGRES_URL` | with `postgres` | – | e.g. `postgres://user:pw@postgres:5432/homebrewery` |
| `HB_POSTGRES_POOL_MAX` | no | `10` | connection pool size |
| `MONGODB_URI` | with `mongo` | – | as upstream |
### Login (OIDC)
| Variable | Required | Default | Description |
| --- | --- | --- | --- |
| `HB_AUTH_PROVIDERS` | no | see docs | `oidc`, `naturalcrit` (comma separated). Use `oidc` for OIDC only |
| `HB_PUBLIC_URL` | with `oidc` | – | external URL, e.g. `https://brew.example.org` |
| `HB_OIDC_ISSUER` | with `oidc` | – | issuer URL (discovery via `/.well-known/openid-configuration`) |
| `HB_OIDC_CLIENT_ID` | with `oidc` | – | |
| `HB_OIDC_CLIENT_SECRET` | with `oidc` | – | |
| `HB_SESSION_SECRET` | with `oidc` | – | at least 32 bytes |
| `HB_SESSION_TTL` | no | `7d` | fixed session lifetime (`7d`, `12h`, `3600`) |
| `HB_OIDC_SCOPES` | no | `openid profile email` | |
| `HB_OIDC_USERNAME_CLAIM` | no | `preferred_username` | source of the username on first login |
| `HB_OIDC_LINK_BY_EMAIL` | no | `false` | bind a pre-created user to the verified IdP e-mail |
| `HB_OIDC_END_SESSION` | no | `false` | also sign out at the IdP on logout |
| `HB_OIDC_LABEL` | no | `Anmelden` | login button text |
The app refuses to start if `oidc` is active and a required value is missing.
### Git backend (optional)
Lets OIDC users link brews to their own Git repositories (HTTPS + personal access token). Disabled while `HB_GIT_TOKEN_KEY` is empty.
| Variable | Required | Default | Description |
| --- | --- | --- | --- |
| `HB_GIT_TOKEN_KEY` | to enable | – | 32 bytes, base64 (`openssl rand -base64 32`). **Back it up**: without it, stored tokens are unusable |
| `HB_GIT_TOKEN_KEYS_OLD` | no | – | old keys (comma separated), decrypt only, for key rotation |
| `HB_GIT_ALLOWED_HOSTS` | no | – | host allowlist, e.g. `git.example.org,*.example.org`. Recommended in production |
| `HB_GIT_ALLOW_PRIVATE` | no | `false` | allow private/loopback targets (e.g. Gitea in the same Compose network) |
| `HB_GIT_ALLOW_HTTP` | no | `false` | allow `http://`, local development only |
| `HB_GIT_WORKDIR` | no | `os.tmpdir()/hb-git` | temporary bare repos, deleted after each operation |
| `HB_GIT_TIMEOUT_MS` | no | `20000` | per `git` call |
| `HB_GIT_OPEN_TIMEOUT_MS` | no | `4000` | sync budget when opening the editor |
| `HB_GIT_MAX_FILE_BYTES` | no | `5242880` | largest brew file |
| `HB_GIT_MAX_CONCURRENCY` | no | `2` | concurrent Git operations per process |
| `HB_GIT_COMMITTER_NAME` / `HB_GIT_COMMITTER_EMAIL` | no | `Homebrewery` / `homebrewery@<host of HB_PUBLIC_URL>` | committer (the author is the saving user) |
### Image upload (needs the Git backend)
| Variable | Required | Default | Description |
| --- | --- | --- | --- |
| `HB_ASSETS_ENABLED` | no | `true` (if Git is active) | upload on/off |
| `HB_ASSET_MAX_BYTES` | no | `5242880` | per file (MongoDB: at most 15 MiB) |
| `HB_ASSET_MAX_BYTES_PER_BREW` | no | `52428800` | total per brew |
| `HB_ASSET_TYPES` | no | `png,jpeg,gif,webp` | allowed types (SVG is never accepted) |
## Operations
- **Update / upgrade:** change the tag (or keep `latest`), then `docker compose pull && docker compose up -d`. Use `up -d`, **not** `restart`: `restart` reuses the old container with its old environment and ignores changes. Migrations run on startup; read the release notes before jumping several versions.
- **Backup:** back up the database (`docker compose exec postgres pg_dump -U homebrewery homebrewery > backup.sql`, adjust user/db to your `.env`) and keep `HB_GIT_TOKEN_KEY` (and any old keys) in your secret store. Brews linked to Git are also in your repositories, but the database holds sharing snapshots, users and stored (encrypted) tokens.
- **Key rotation:** set the new key as `HB_GIT_TOKEN_KEY`, move the previous one into `HB_GIT_TOKEN_KEYS_OLD` (comma separated), run `docker compose up -d`. Tokens are re-encrypted on next use; drop the old key only after all connections have been used.
- **Logs:** `docker compose logs -f homebrewery`. Look for `Git-Backend aktiv (kid=...)` (on) or `Git-Backend deaktiviert: HB_GIT_TOKEN_KEY ist nicht gesetzt` (off). Logs never contain keys or tokens.
- **Health:** the image has no dedicated health endpoint; `GET /` on port 8000 returning HTTP 200 means the app is up. The container exits at startup if the database or IdP configuration is invalid, so `restart: unless-stopped` shows a restart loop with the reason in the log.
## Troubleshooting
- **Git panel says "Git-Backend auf diesem Server nicht aktiviert" / API returns `503 G10`:** `HB_GIT_TOKEN_KEY` does not reach the container. Check `docker compose exec homebrewery printenv HB_GIT_TOKEN_KEY | wc -c` (a valid key prints 45; `0` or an error means it is not set), make sure it is listed under `environment:`, then `docker compose up -d`.
- **`403 G07`:** the session is not an OIDC account. Only OIDC users can link repositories.
- **Start aborts with `HB_GIT_TOKEN_KEY muss 32 Byte (base64) lang sein`:** invalid key (also checked in `HB_GIT_TOKEN_KEYS_OLD`). Generate with `openssl rand -base64 32`.
- **Start aborts about PostgreSQL:** the server must be version 18 or newer and `HB_POSTGRES_URL` must be set.
- **Login redirect mismatch:** the IdP redirect URI must be exactly `<HB_PUBLIC_URL>/auth/oidc/callback`.
More error codes (`G01`-`G10`, `A01`-`A07`): https://git.morlana.online/f.weber/homebrewery-oidc/src/branch/main/docs/git/README.md#fehlercodes