homelab-codex-ws/services/kb-site/service.yaml
oskar bb3792d219 docs(kb-site): przekaz ACCESS_TOKEN generatorowi w procedurze publikacji
Poprzedni commit nauczyl gen_pages.py dopisywac token do linkow, ale nic
go nie podawalo — publikacja poszlaby stara sciezka i dalaby build
z golymi linkami, czyli stan sprzed fiksa.

kb-site nie ma skryptu deployu: generator wolany jest wylacznie recznie
z runbooka (kroki 2 i 7), wiec to tam token musi wejsc.

Zrodlo tokenu: /opt/homelab/config/kb-site/.env na wezle GENERUJACYM
(SATURN/SOLARIA), nie na PIHA. To swiadome odstepstwo od konwencji
config/<serwis>/ z CLAUDE.md — plik trzyma zwykle sekrety wezla, ktory
serwis uruchamia, a ten token jest potrzebny tam, gdzie serwis sie
generuje. Kontener nginx dalej nie ma zadnej konfiguracji ani sekretow;
odnotowane w service.yaml i env.example, zeby nikt nie szukal .env na PIHA.

Token idzie zmienna srodowiskowa (set -a; . plik; set +a), nie flaga
--access-token: argument z linii polecen laduje w historii shella i jest
widoczny w ps dla kazdego uzytkownika wezla.

Lancuch publikacji z kroku 7 dostal dwa nowe ogniwa przed scp: test -n
"$ACCESS_TOKEN" (pusty token = build nieklikalny) oraz grep -q 'key='
w index.html (token byl, ale nie dojechal do generatora). Oba zatrzymuja
publikacje tak samo jak --check.

Krok 6 weryfikuje teraz wlasciwa rzecz: wyciaga href ze spisu i pobiera
GO, zamiast recznie sklejac URL — czyli testuje to, co faktycznie bylo
zepsute. Doszedl tez negatywny test bramki (bez tokenu ma NIE byc 200).

Tabela problemow: "index sie otwiera, ale klikniecie daje 403" (build bez
tokenu) i "403 takze z tokenem" (rotacja tokenu w NPM rozjechana z plikiem
— stary build zostaje z martwym tokenem w kazdym linku).

kb/services/kb-site.md (public) — sekcja Access: token siedzi teraz
w tresci kazdej serwowanej strony, wiec jedna zapisana strona wydaje go
w calosci. Model zagrozen bez zmian (URL wejsciowy zawsze go niosl), ale
warto, zeby dokument mowil to wprost obok zdania "to obscurity, not
access control".

Test: sekwencje z krokow 2 i 7 przepuszczone na symulowanym pliku tokenu
(prod /opt/homelab nietkniety) — token obecny: Token: TAK, 4x key=
w index.html, lancuch dochodzi do tar; token pusty: staje na pierwszym
ogniwie, brak tgz; build bez tokenu przy ustawionej zmiennej: staje na
grep, brak tgz. check_okf.py exit 0, gen_pages --check exit 0,
service.yaml parsuje sie.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-05 22:26:48 +02:00

45 lines
2.1 KiB
YAML

service:
name: kb-site
owner_node: piha
role: static-html-host # public slice of the KB, rendered by scripts/kb/gen_pages.py
exposure: public # public via npm@PIHA (kb-e2a24af3.okit.pl). The container itself binds
# 8250 on the LAN; npm is the sole public entry point.
dependencies: [] # nginx serving a local volume — nothing else required at runtime
ports:
- container: 80
host: 8250
protocol: tcp
healthcheck:
type: http
endpoint: http://127.0.0.1:8250/index.html # content must be loaded first (see runbook)
interval: 30s
timeout: 10s
retries: 5
restart_policy: unless-stopped
persistence:
# Docker named volume kb-site_kb-site_content (compose project prefix), NOT a
# bind under /opt/homelab/data. The content is a pure artifact: regenerate it
# from the repo with scripts/kb/gen_pages.py, no backup job needed.
paths:
- kb-site_kb-site_content
runtime:
# The CONTAINER has no .env and no secrets — the port bind is static. The
# access token below is not a container env var: it is consumed by the
# generator on the node that builds the site, never by nginx on PIHA.
config_files: []
env_vars: []
content:
# Only kb/ documents with `visibility: public` are published; the generator
# is fail-closed (no frontmatter / no visibility field = private).
generator: scripts/kb/gen_pages.py
leak_check: scripts/kb/gen_pages.py --check # must pass before publishing
source: kb/**/*.md
# NPM enforces a ?key=<token> gate in front of this site, so every internal
# href must carry that token or a click lands on 403. The generator reads it
# from ACCESS_TOKEN; the value lives in the NPM database and in
# /opt/homelab/config/kb-site/.env ON THE GENERATING NODE (saturn/solaria) —
# never in this repository. Omitting it yields a valid preview build that
# must not be published. See kb/runbooks/kb-site-deploy.md.
access_token_env: ACCESS_TOKEN
access_token_file: /opt/homelab/config/kb-site/.env # generating node, not piha