From 1fe99698fb037ecf10fa991a4e785b6360fc9571 Mon Sep 17 00:00:00 2001 From: "Dev (Paperclip)" Date: Thu, 26 Nov 2026 11:33:28 +0000 Subject: [PATCH 1/4] docs(dockerhub): englische Repo-Beschreibung und Workflow zum Publizieren (#32) Co-Authored-By: Claude Sonnet 5.5 --- .gitea/workflows/dockerhub-description.yml | 62 ++++++++++ FORK.md | 1 + docs/dockerhub/README.md | 130 +++++++++++++++++++++ 3 files changed, 193 insertions(+) create mode 100644 .gitea/workflows/dockerhub-description.yml create mode 100644 docs/dockerhub/README.md diff --git a/.gitea/workflows/dockerhub-description.yml b/.gitea/workflows/dockerhub-description.yml new file mode 100644 index 00000000..3f1e1642 --- /dev/null +++ b/.gitea/workflows/dockerhub-description.yml @@ -0,0 +1,62 @@ +# Docker Hub: Repo-Beschreibung (Overview + Short description) aus docs/dockerhub/README.md setzen (FLW-263). +# Auslöser: Release-Tag vX.Y.Z (wie der Docker-Hub-Pfad in image.yml), Änderungen an der Datei auf main, manuell. +# Secrets: DOCKER_HUB_USER, DOCKER_HUB_TOKEN (Access Token mit Read, Write, Delete). +# Fehlen sie, wird mit Warnung übersprungen. Das Token wird nie ausgegeben. +name: Docker Hub Description + +on: + push: + branches: [main] + paths: + - docs/dockerhub/README.md + - .gitea/workflows/dockerhub-description.yml + tags: ["v*"] + workflow_dispatch: + +permissions: + contents: read + +concurrency: + group: dockerhub-description + cancel-in-progress: false + +jobs: + description: + name: Beschreibung nach Docker Hub schreiben + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - name: Prüfen + id: check + env: + REF: ${{ github.ref }} + REF_NAME: ${{ github.ref_name }} + HUB_USER: ${{ secrets.DOCKER_HUB_USER }} + HUB_TOKEN: ${{ secrets.DOCKER_HUB_TOKEN }} + run: | + run=true + if [[ "$REF" == refs/tags/* ]] && ! [[ "$REF_NAME" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo "Kein Release-Tag (${REF_NAME}), übersprungen."; run=false + elif [ -z "$HUB_USER" ] || [ -z "$HUB_TOKEN" ]; then + echo "::warning::DOCKER_HUB_USER/DOCKER_HUB_TOKEN fehlen, Docker-Hub-Beschreibung wird übersprungen."; run=false + fi + echo "run=${run}" >> "$GITHUB_OUTPUT" + + - uses: actions/checkout@v7 + if: steps.check.outputs.run == 'true' + + - name: Größe prüfen (Docker-Hub-Limit 25.000 Bytes) + if: steps.check.outputs.run == 'true' + run: | + size=$(wc -c < docs/dockerhub/README.md) + echo "README: ${size} Bytes" + [ "$size" -lt 25000 ] || { echo "::error::docs/dockerhub/README.md ist zu groß für Docker Hub."; exit 1; } + + - uses: peter-evans/dockerhub-description@v5 + if: steps.check.outputs.run == 'true' + with: + username: ${{ secrets.DOCKER_HUB_USER }} + password: ${{ secrets.DOCKER_HUB_TOKEN }} + repository: ${{ secrets.DOCKER_HUB_USER }}/homebrewery-oidc + readme-filepath: docs/dockerhub/README.md + short-description: "Homebrewery fork: OIDC login, PostgreSQL 18, Git backend, image upload." diff --git a/FORK.md b/FORK.md index 98dee73e..5f6bfb22 100644 --- a/FORK.md +++ b/FORK.md @@ -79,6 +79,7 @@ merges remain conflict-free. | `ci.yml` | pull requests, push to `main` | `npm ci` (includes the Vite build via `postinstall`), `npm run lint:dry`, `npm run stylelint:dry`, `npm test`. Upstream currently has ESLint warnings but no errors; warnings do not fail the job. The tests need no MongoDB. | | `image.yml` | push to `main`, tags `v*`, manual | builds `docker/Dockerfile` (same as Compose) and pushes `git.morlana.online/f.weber/homebrewery-oidc`; release tags `vX.Y.Z` additionally go to Docker Hub (`/homebrewery-oidc`) | | `dockerhub-sync.yml` | manual (input `version`) | copies an already built `vX.Y.Z` image from Gitea to Docker Hub without rebuilding (same digest); sets `latest` only if the version is the highest release | +| `dockerhub-description.yml` | release tag `vX.Y.Z`, push to `main` touching `docs/dockerhub/README.md`, manual | sets the Docker Hub overview from `docs/dockerhub/README.md` (English, < 25,000 bytes, absolute links only) plus a short description (≤ 100 characters), using `peter-evans/dockerhub-description`; skipped with a warning if `DOCKER_HUB_USER`/`DOCKER_HUB_TOKEN` are missing (the token needs Read, Write and Delete) | The authoritative image definition is `docker/Dockerfile` with `docker/Dockerfile.dockerignore` (BuildKit picks it up automatically for `context: .`). diff --git a/docs/dockerhub/README.md b/docs/dockerhub/README.md new file mode 100644 index 00000000..0c74425e --- /dev/null +++ b/docs/dockerhub/README.md @@ -0,0 +1,130 @@ +# 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=/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 `/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@` | 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 `/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 -- 2.54.1 From 75548d39f33726e1d450de2f78620d280e4ffff4 Mon Sep 17 00:00:00 2001 From: "Dev (Paperclip)" Date: Thu, 26 Nov 2026 11:40:05 +0000 Subject: [PATCH 2/4] fix(assets): leeres HB_ASSET_TYPES als nicht gesetzt behandeln (#32) Die Compose-Vorlage setzt HB_ASSET_TYPES="", was den Start abbrechen liess. Co-Authored-By: Claude Sonnet 5.5 --- server/fork/assets/assets.unit.spec.js | 4 ++++ server/fork/assets/config.js | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/server/fork/assets/assets.unit.spec.js b/server/fork/assets/assets.unit.spec.js index a834a607..19490b9c 100644 --- a/server/fork/assets/assets.unit.spec.js +++ b/server/fork/assets/assets.unit.spec.js @@ -41,6 +41,10 @@ describe('Konfiguration', ()=>{ expect(readAssetsConfig({ HB_ASSET_MAX_BYTES: '1000', HB_ASSET_MAX_BYTES_PER_BREW: '5000', HB_ASSET_TYPES: 'png, jpg,jpeg' })) .toMatchObject({ maxBytes: 1000, maxBytesPerBrew: 5000, types: ['png', 'jpeg'] }); }); + test('Leeres HB_ASSET_TYPES (Compose-Vorlage setzt "") gilt als nicht gesetzt', ()=>{ + expect(readAssetsConfig({ HB_ASSET_TYPES: '' }).types).toEqual(['png', 'jpeg', 'gif', 'webp']); + expect(readAssetsConfig({ HB_ASSET_TYPES: ' ' }).types).toEqual(['png', 'jpeg', 'gif', 'webp']); + }); test('SVG und Unsinn sind Startfehler', ()=>{ expect(()=>readAssetsConfig({ HB_ASSET_TYPES: 'png,svg' })).toThrow(/svg/i); expect(()=>readAssetsConfig({ HB_ASSET_TYPES: ',' })).toThrow(/leer/); diff --git a/server/fork/assets/config.js b/server/fork/assets/config.js index abf8d19a..54717080 100644 --- a/server/fork/assets/config.js +++ b/server/fork/assets/config.js @@ -32,7 +32,8 @@ export const readAssetsConfig = (env = process.env, { gitEnabled = true, driver if(driver === 'mongo' && maxBytes > MONGO_MAX_ASSET_BYTES) throw new Error('HB_ASSET_MAX_BYTES darf mit MongoDB höchstens 15 MiB (15728640) betragen (Dokumentlimit 16 MiB).'); - const names = String(env.HB_ASSET_TYPES ?? 'png,jpeg,gif,webp').split(',').map((s)=>s.trim().toLowerCase().replace(/^jpg$/, 'jpeg')).filter(Boolean); + const rawTypes = String(env.HB_ASSET_TYPES ?? '').trim() || 'png,jpeg,gif,webp'; + const names = rawTypes.split(',').map((s)=>s.trim().toLowerCase().replace(/^jpg$/, 'jpeg')).filter(Boolean); const unknown = names.filter((n)=>!KNOWN_TYPES[n]); if(unknown.length) throw new Error(`HB_ASSET_TYPES enthält nicht unterstützte Typen: ${unknown.join(', ')} (erlaubt: ${Object.keys(KNOWN_TYPES).join(', ')}; SVG ist ausgeschlossen)`); if(!names.length) throw new Error('HB_ASSET_TYPES darf nicht leer sein'); -- 2.54.1 From 18f26b7fd6051891595d7c289f900cb78386e329 Mon Sep 17 00:00:00 2001 From: "Dev (Paperclip)" Date: Thu, 26 Nov 2026 11:40:24 +0000 Subject: [PATCH 3/4] docs(dockerhub): Review-Punkte 1, 3-10 umgesetzt (#32) raw-URLs, OIDC-Discovery-Formulierung, Platzhalter per sed im Workflow, Markdown-Links, Fehlercodes, HB_AUTH_PROVIDERS-Default, exec -T, wc-c-Hinweis, FORK.md-Hinweis. Co-Authored-By: Claude Sonnet 5.5 --- .gitea/workflows/dockerhub-description.yml | 6 +++++ FORK.md | 2 +- docs/dockerhub/README.md | 28 +++++++++++----------- docs/git/README.md | 2 +- 4 files changed, 22 insertions(+), 16 deletions(-) diff --git a/.gitea/workflows/dockerhub-description.yml b/.gitea/workflows/dockerhub-description.yml index 3f1e1642..4752b28a 100644 --- a/.gitea/workflows/dockerhub-description.yml +++ b/.gitea/workflows/dockerhub-description.yml @@ -45,6 +45,12 @@ jobs: - uses: actions/checkout@v7 if: steps.check.outputs.run == 'true' + - name: Platzhalter ersetzen (nur in der ausgecheckten Kopie) + if: steps.check.outputs.run == 'true' + env: + HUB_USER: ${{ secrets.DOCKER_HUB_USER }} + run: sed -i "s##${HUB_USER}#g" docs/dockerhub/README.md + - name: Größe prüfen (Docker-Hub-Limit 25.000 Bytes) if: steps.check.outputs.run == 'true' run: | diff --git a/FORK.md b/FORK.md index 5f6bfb22..66dca9bd 100644 --- a/FORK.md +++ b/FORK.md @@ -79,7 +79,7 @@ merges remain conflict-free. | `ci.yml` | pull requests, push to `main` | `npm ci` (includes the Vite build via `postinstall`), `npm run lint:dry`, `npm run stylelint:dry`, `npm test`. Upstream currently has ESLint warnings but no errors; warnings do not fail the job. The tests need no MongoDB. | | `image.yml` | push to `main`, tags `v*`, manual | builds `docker/Dockerfile` (same as Compose) and pushes `git.morlana.online/f.weber/homebrewery-oidc`; release tags `vX.Y.Z` additionally go to Docker Hub (`/homebrewery-oidc`) | | `dockerhub-sync.yml` | manual (input `version`) | copies an already built `vX.Y.Z` image from Gitea to Docker Hub without rebuilding (same digest); sets `latest` only if the version is the highest release | -| `dockerhub-description.yml` | release tag `vX.Y.Z`, push to `main` touching `docs/dockerhub/README.md`, manual | sets the Docker Hub overview from `docs/dockerhub/README.md` (English, < 25,000 bytes, absolute links only) plus a short description (≤ 100 characters), using `peter-evans/dockerhub-description`; skipped with a warning if `DOCKER_HUB_USER`/`DOCKER_HUB_TOKEN` are missing (the token needs Read, Write and Delete) | +| `dockerhub-description.yml` | release tag `vX.Y.Z`, push to `main` touching `docs/dockerhub/README.md`, manual | sets the Docker Hub overview from `docs/dockerhub/README.md` (English, < 25,000 bytes, absolute links only) plus a short description (≤ 100 characters), using `peter-evans/dockerhub-description`; skipped with a warning if `DOCKER_HUB_USER`/`DOCKER_HUB_TOKEN` are missing (the token needs Read, Write and Delete); `` in the file is replaced by the secret at publish time. A maintenance tag on an older commit overwrites the description with that older text; the first run needs the Hub repository to exist (created by `image.yml`) | The authoritative image definition is `docker/Dockerfile` with `docker/Dockerfile.dockerignore` (BuildKit picks it up automatically for `context: .`). diff --git a/docs/dockerhub/README.md b/docs/dockerhub/README.md index 0c74425e..2be63645 100644 --- a/docs/dockerhub/README.md +++ b/docs/dockerhub/README.md @@ -2,9 +2,9 @@ [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). +- Source, issues, docs: [repository](https://git.morlana.online/f.weber/homebrewery-oidc), [README](https://git.morlana.online/f.weber/homebrewery-oidc/src/branch/main/README.md) +- Fork overview and CI/tag details: [FORK.md](https://git.morlana.online/f.weber/homebrewery-oidc/src/branch/main/FORK.md) +- Upstream: [naturalcrit/homebrewery](https://github.com/naturalcrit/homebrewery). License: MIT (see the [license file](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**. @@ -23,14 +23,14 @@ The same images are also published to the Gitea registry `git.morlana.online/f.w ```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 + curl -fsSLO https://git.morlana.online/f.weber/homebrewery-oidc/raw/branch/main/docs/deploy/compose.yaml + curl -fsSL https://git.morlana.online/f.weber/homebrewery-oidc/raw/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.) + (Both files are also linked from the [deployment guide](https://git.morlana.online/f.weber/homebrewery-oidc/src/branch/main/docs/deploy/README.md); that guide 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=/homebrewery-oidc:v1.0.0`. Without it the template uses the Gitea registry image `:latest`. + Set `HB_IMAGE` to pin a release, e.g. `HB_IMAGE=/homebrewery-oidc:v1.0.0` (`docker pull /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 `/auth/oidc/callback` at your identity provider (confidential client, `client_secret_basic`). @@ -44,7 +44,7 @@ The same images are also published to the Gitea registry `git.morlana.online/f.w 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. +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 checks that the required OIDC values are present and well-formed and connects to PostgreSQL (version 18 or newer is required, otherwise it aborts with a clear message). The identity provider itself (OIDC discovery) is only contacted at the first login; if it is unreachable, login answers with 502 but the app keeps running. 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`. @@ -54,7 +54,7 @@ Set `HB_DB_DRIVER=mongo` (the default when unset) and `MONGODB_URI=mongodb://mon ## 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). +All settings are environment variables. Full reference (German): [login](https://git.morlana.online/f.weber/homebrewery-oidc/src/branch/main/docs/auth/README.md), [database](https://git.morlana.online/f.weber/homebrewery-oidc/src/branch/main/docs/storage/README.md), [Git backend and image upload](https://git.morlana.online/f.weber/homebrewery-oidc/src/branch/main/docs/git/README.md). ### Storage @@ -69,7 +69,7 @@ All settings are environment variables. Full reference: https://git.morlana.onli | Variable | Required | Default | Description | | --- | --- | --- | --- | -| `HB_AUTH_PROVIDERS` | no | see docs | `oidc`, `naturalcrit` (comma separated). Use `oidc` for OIDC only | +| `HB_AUTH_PROVIDERS` | no | `oidc,naturalcrit` if `HB_OIDC_ISSUER` is set, otherwise `naturalcrit` | `oidc`, `naturalcrit` (comma separated). Use `oidc` for OIDC only. With your own Compose file, set `HB_AUTH_PROVIDERS=oidc`: otherwise the app refuses to start while `SECRET` has its default value | | `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` | – | | @@ -114,17 +114,17 @@ Lets OIDC users link brews to their own Git repositories (HTTPS + personal acces ## 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. +- **Backup:** back up the database (`docker compose exec -T 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. +- **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 is unusable or required OIDC values are missing or malformed (IdP reachability is only checked at the first login), 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`. +- **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`, `1` (empty value) 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 `/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 +More error codes: Git backend `G01`-`G10` in the [Git guide](https://git.morlana.online/f.weber/homebrewery-oidc/src/branch/main/docs/git/README.md#fehlercodes), image upload `A04`-`A07` in the [upload section of the same guide](https://git.morlana.online/f.weber/homebrewery-oidc/src/branch/main/docs/git/README.md), rename `A01`-`A03` in the [auth guide](https://git.morlana.online/f.weber/homebrewery-oidc/src/branch/main/docs/auth/README.md) (guides are in German). diff --git a/docs/git/README.md b/docs/git/README.md index d1238f49..b7a0f212 100644 --- a/docs/git/README.md +++ b/docs/git/README.md @@ -42,7 +42,7 @@ Mit Docker Compose gilt: Nach einer Änderung der Umgebung `docker compose up -d Prüfen, in dieser Reihenfolge: -1. **Kommt der Schlüssel im Container an?** `docker compose exec printenv HB_GIT_TOKEN_KEY | wc -c`: `0` oder +1. **Kommt der Schlüssel im Container an?** `docker compose exec printenv HB_GIT_TOKEN_KEY | wc -c`: `0`, `1` (Variable gesetzt, aber leer) oder Fehler = nicht gesetzt; ein gültiger Schlüssel (32 Byte, base64) hat 45 Zeichen (44 + Zeilenumbruch). 2. **Startlog** (`docker compose logs `): `Git-Backend aktiv (kid=…, alte Schlüssel: n, Host-Allowlist: ja (n)|nein)` = an; `Git-Backend deaktiviert: HB_GIT_TOKEN_KEY ist nicht gesetzt` = aus. Der Log enthält nie den Schlüssel. -- 2.54.1 From a1d7e1b51b72adb08a3dbce28330992a1868b870 Mon Sep 17 00:00:00 2001 From: "Dev (Paperclip)" Date: Thu, 26 Nov 2026 11:43:12 +0000 Subject: [PATCH 4/4] docs(dockerhub): Upload-Fehlercodes A01-A07 korrigieren, Rename-Codes abgrenzen Co-Authored-By: Claude Sonnet 5.5 --- docs/dockerhub/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/dockerhub/README.md b/docs/dockerhub/README.md index 2be63645..c0584d6d 100644 --- a/docs/dockerhub/README.md +++ b/docs/dockerhub/README.md @@ -127,4 +127,4 @@ Lets OIDC users link brews to their own Git repositories (HTTPS + personal acces - **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 `/auth/oidc/callback`. -More error codes: Git backend `G01`-`G10` in the [Git guide](https://git.morlana.online/f.weber/homebrewery-oidc/src/branch/main/docs/git/README.md#fehlercodes), image upload `A04`-`A07` in the [upload section of the same guide](https://git.morlana.online/f.weber/homebrewery-oidc/src/branch/main/docs/git/README.md), rename `A01`-`A03` in the [auth guide](https://git.morlana.online/f.weber/homebrewery-oidc/src/branch/main/docs/auth/README.md) (guides are in German). +More error codes: Git backend `G01`-`G10` in the [Git guide](https://git.morlana.online/f.weber/homebrewery-oidc/src/branch/main/docs/git/README.md#fehlercodes), image upload `A01`-`A07` in its [upload section](https://git.morlana.online/f.weber/homebrewery-oidc/src/branch/main/docs/git/README.md#bild-upload-adr-0004). Note: the account rename endpoint reuses `A01`-`A03` with a different meaning, see the [auth guide](https://git.morlana.online/f.weber/homebrewery-oidc/src/branch/main/docs/auth/README.md) (guides are in German). -- 2.54.1