From ca00f8899da718433fa084f801ebad23894a2660 Mon Sep 17 00:00:00 2001 From: ginnoir Date: Sun, 18 Oct 2026 02:38:31 -0500 Subject: [PATCH] feat(media): add books stack (chaptarr, CWA, audiobookshelf, storyteller) Chaptarr grabs ebooks into the CWA ingest folder and audiobooks into the ABS library; Storyteller reads both read-only for read-along alignment. All four are internal_only; chaptarr/CWA/storyteller use forward_auth, ABS uses native OIDC. Adds STORYTELLER_SECRET_KEY to stack.env and a BOOKS.md runbook (host prep, Authentik, post-deploy checklist). Co-Authored-By: Claude Opus 5.5 --- Caddyfile | 55 +++++++++++++++++++++++ bookmarks-domains.html | 4 ++ bookmarks-ports.html | 4 ++ stacks/media/BOOKS.md | 61 ++++++++++++++++++++++++++ stacks/media/docker-compose.yml | 78 +++++++++++++++++++++++++++++++++ stacks/media/stack.env | 3 ++ 6 files changed, 205 insertions(+) create mode 100644 stacks/media/BOOKS.md diff --git a/Caddyfile b/Caddyfile index dff5295..bee4f77 100644 --- a/Caddyfile +++ b/Caddyfile @@ -275,6 +275,61 @@ stash.ginnoir.com { } } +# BOOKS — chaptarr / CWA / storyteller behind forward_auth; ABS uses native OIDC +# (forward_auth would break the mobile app). All internal_only — remote access +# is via the tailnet (100.64.0.0/10 is already allowed by internal_only). +chaptarr.ginnoir.com { + import internal_only + route { + import authentik_outpost + handle /api/* { + reverse_proxy chaptarr:8789 + } + handle { + import authentik_forward_auth + reverse_proxy chaptarr:8789 + } + } +} + +books.ginnoir.com { + import internal_only + route { + import authentik_outpost + # OPDS + Kobo sync clients authenticate with CWA's own credentials. + handle /opds* { + reverse_proxy calibre-web-automated:8083 + } + handle /kobo/* { + reverse_proxy calibre-web-automated:8083 + } + handle { + import authentik_forward_auth + reverse_proxy calibre-web-automated:8083 + } + } +} + +audiobooks.ginnoir.com { + import internal_only + reverse_proxy audiobookshelf:80 +} + +storyteller.ginnoir.com { + import internal_only + route { + import authentik_outpost + # Storyteller Reader app talks to the API with its own tokens. + handle /api/* { + reverse_proxy storyteller:8001 + } + handle { + import authentik_forward_auth + reverse_proxy storyteller:8001 + } + } +} + # ============================================================= # GAMES / ROMS — internal only # External access for a trusted friend is via the `share` stack's Tailscale diff --git a/bookmarks-domains.html b/bookmarks-domains.html index 05946fa..e011b0e 100644 --- a/bookmarks-domains.html +++ b/bookmarks-domains.html @@ -50,6 +50,10 @@
nzbget
whisparr
stash +
chaptarr [internal] +
books [internal] +
audiobooks [internal] +
storyteller [internal]
roms
romhacks
jd [internal] diff --git a/bookmarks-ports.html b/bookmarks-ports.html index fc44798..b468177 100644 --- a/bookmarks-ports.html +++ b/bookmarks-ports.html @@ -49,6 +49,10 @@
qbittorrent :6881 (TCP/UDP)
whisparr
stash :6971 +
chaptarr +
calibre-web-automated +
audiobookshelf :13378 +
storyteller

Monitoring

diff --git a/stacks/media/BOOKS.md b/stacks/media/BOOKS.md new file mode 100644 index 0000000..2c9b25d --- /dev/null +++ b/stacks/media/BOOKS.md @@ -0,0 +1,61 @@ +# Books stack (chaptarr / CWA / audiobookshelf / storyteller) + +Lives in the `media` stack. Flow: + +``` +prowlarr ─► chaptarr ─► qbittorrent / nzbget ─► /storage1/complete + │ + ├─ ebooks ─► /storage1/complete/books-ingest ─► CWA ─► /storage1/Media/Books (Calibre lib) ─► Send-to-Kindle / OPDS + └─ audiobooks ─► /storage1/Media/Audiobooks ─► audiobookshelf +storyteller reads both libraries :ro ─► /storage1/labdata/storyteller (aligned EPUB 3 + media overlays) +``` + +| Service | Container:port | Host port | URL | +|---|---|---|---| +| chaptarr | `chaptarr:8789` | 8789 | https://chaptarr.ginnoir.com (forward_auth, `/api/*` bypass) | +| calibre-web-automated | `calibre-web-automated:8083` | 8083 | https://books.ginnoir.com (forward_auth, `/opds*` + `/kobo/*` bypass) | +| audiobookshelf | `audiobookshelf:80` | 13378 | https://audiobooks.ginnoir.com (native OIDC, LAN + tailnet only) | +| storyteller | `storyteller:8001` | 8001 | https://storyteller.ginnoir.com (forward_auth, `/api/*` bypass) | + +## 1. Host prep (before the first deploy) + +Docker creates missing bind dirs as `root:root`, which breaks chaptarr/CWA/ABS (PUID 1000). + +```bash +sudo mkdir -p /config/chaptarr /config/calibre-web-automated \ + /config/audiobookshelf/{config,metadata} \ + /storage1/Media/Books /storage1/Media/Audiobooks \ + /storage1/complete/books-ingest /storage1/labdata/storyteller +sudo chown -R 1000:1000 /config/chaptarr /config/calibre-web-automated /config/audiobookshelf \ + /storage1/Media/Books /storage1/Media/Audiobooks \ + /storage1/complete/books-ingest /storage1/labdata/storyteller +``` + +## 2. Authentik + +- **Audiobookshelf (Pattern A, native OIDC).** Create the provider `homelab-audiobooks` using the CLAUDE.md template, with these strict redirect URIs: + - `https://audiobooks.ginnoir.com/auth/openid/callback` + - `https://audiobooks.ginnoir.com/auth/openid/mobile-redirect` + - `audiobookshelf://oauth` (mobile app) + + Then create the application with slug `audiobooks`. In ABS, go to Settings → Authentication → OpenID Connect. Set the issuer to `https://auth.ginnoir.com/application/o/audiobooks/`, add the client ID and secret, and add `audiobookshelf://oauth` to the allowed mobile redirect URIs. +- **chaptarr / books / storyteller (Pattern B).** Add a proxy provider (forward auth, single application) for each host. Attach each one to the embedded outpost. The Caddy blocks are already in place. +- **CWA single sign-on (optional).** In Admin → Edit Basic Configuration → Feature Configuration, turn on *Allow Reverse Proxy Authentication* and set the header to `X-Authentik-Username`. The CWA usernames must match the Authentik usernames. + +## 3. Post-deploy checklist + +- [ ] **chaptarr:** set the admin login on first launch. Add root folders `/ebooks` (ebook) and `/audiobooks` (audiobook). +- [ ] **chaptarr:** turn on *Unmonitor Deleted Books* (Media Management). CWA deletes files from `/ebooks` after ingest, and without this setting chaptarr will try to grab them again. +- [ ] **Prowlarr → chaptarr app sync:** in Prowlarr, go to Settings → Apps → add Chaptarr (or Readarr if Chaptarr isn't listed yet). Use `http://prowlarr:9696` and `http://chaptarr:8789`, plus the chaptarr API key. Sync, then confirm the indexers show up in chaptarr. +- [ ] **Download clients in chaptarr:** add `qbittorrent:3232` with category `books`, and `nzbget:6789` with category `books`. Both write under `/downloads` on the same `/storage1/complete` mount, so no remote path mapping is needed. Check that the `books` categories exist in both clients. +- [ ] **CWA:** log in as `admin` / `admin123` and change the password right away. The library path is `/calibre-library`. Drop a test EPUB into `/storage1/complete/books-ingest` and confirm it shows up in the library and leaves the ingest folder. +- [ ] **CWA SMTP / Send-to-Kindle:** Admin → Edit Email Server Settings. Add the sender address to Amazon → *Manage Your Content and Devices* → *Personal Document Settings* → *Approved Personal Document E-mail List*. Set the user's Kindle email in their profile, then send the test book. +- [ ] **audiobookshelf:** create the root user and add a library pointed at `/audiobooks`. Scan it, then sign in from the phone app over Tailscale. +- [ ] **storyteller:** create an admin and point the import at `/libraries/books` and `/libraries/audiobooks`. Run one test alignment on a short book (whisper runs on CPU, so this is slow). Open the result in the Storyteller Reader app. +- [ ] **uptime-kuma:** add monitors for the four new hosts. + +## Notes + +- `STORYTELLER_SECRET_KEY` is in `stack.env` (`secrets.token_hex(64)`). If you rotate it, every Storyteller session is logged out. +- GPU: the `deploy:` block for the P100s is commented out in compose. When you turn it on, check upstream's GPU Acceleration docs for the CUDA image tag. +- Chaptarr is young and runs on `:latest` with Watchtower. If an update breaks it, pin a tag and add `com.centurylabs.watchtower.enable=false`. diff --git a/stacks/media/docker-compose.yml b/stacks/media/docker-compose.yml index 315986f..75b3758 100644 --- a/stacks/media/docker-compose.yml +++ b/stacks/media/docker-compose.yml @@ -196,6 +196,84 @@ services: ports: - "6971:6970" + # ============================================================ BOOKS + # Prowlarr -> chaptarr -> qbittorrent/nzbget (/storage1/complete). Chaptarr + # imports ebooks into the CWA ingest folder (CWA owns the Calibre library and + # deletes ingested files) and audiobooks straight into the ABS library. + # Storyteller reads both libraries read-only and writes aligned EPUBs to its + # own /data. Readarr is retired upstream — do not add it. + chaptarr: + container_name: chaptarr + image: chaptarr/chaptarr:latest + restart: unless-stopped + networks: [media, edge] + env_file: + - stack.env + ulimits: + nofile: { soft: 65536, hard: 65536 } + environment: + - UMASK=002 + volumes: + - /config/chaptarr:/config + - /storage1/complete:/downloads + - /storage1/complete/books-ingest:/ebooks + - /storage1/Media/Audiobooks:/audiobooks + ports: + - "8789:8789" + + calibre-web-automated: + container_name: calibre-web-automated + image: crocodilestick/calibre-web-automated:latest + restart: unless-stopped + networks: [media, edge] + env_file: + - stack.env + environment: + - NETWORK_SHARE_MODE=false + volumes: + - /config/calibre-web-automated:/config + - /storage1/complete/books-ingest:/cwa-book-ingest + - /storage1/Media/Books:/calibre-library + ports: + - "8083:8083" + + audiobookshelf: + container_name: audiobookshelf + image: ghcr.io/advplyr/audiobookshelf:latest + restart: unless-stopped + networks: [media, edge] + env_file: + - stack.env + volumes: + - /config/audiobookshelf/config:/config + - /config/audiobookshelf/metadata:/metadata + - /storage1/Media/Audiobooks:/audiobooks + ports: + - "13378:80" + + storyteller: + container_name: storyteller + image: registry.gitlab.com/storyteller-platform/storyteller:latest + restart: unless-stopped + networks: [media, edge] + env_file: + - stack.env # STORYTELLER_SECRET_KEY lives here + volumes: + - /storage1/labdata/storyteller:/data + - /storage1/Media/Books:/libraries/books:ro + - /storage1/Media/Audiobooks:/libraries/audiobooks:ro + ports: + - "8001:8001" + # Whisper runs on CPU until the P100s land. Then add (and check upstream's + # GPU Acceleration docs for the CUDA image tag): + # deploy: + # resources: + # reservations: + # devices: + # - driver: nvidia + # count: 1 + # capabilities: [gpu] + networks: media: name: media diff --git a/stacks/media/stack.env b/stacks/media/stack.env index e0a5085..fc865a5 100644 --- a/stacks/media/stack.env +++ b/stacks/media/stack.env @@ -4,3 +4,6 @@ TZ=America/Chicago PUID=1000 PGID=1000 + +# storyteller — auth token signing key (secrets.token_hex(64)) +STORYTELLER_SECRET_KEY=5b41f526eb62c2fbe17527b65a0e71ff06d5927fbeb869541f52e812ba8366d28afe1ed26e9986853484995848e3a91ff2b0321ed583d9612af5d82005df22c9