Pin images by digest; add update, smoke-test and status scripts

Goal: at every session start, run exactly the application the repo says — and be able
to move to a new upstream release deliberately, with a way back.

The old setup (v1-latest + pull_policy: always) was unreliable in both directions.
`docker compose up -d` silently pulled a new application, including an irreversible
SurrealDB schema migration, while a reboot (restart: always) or `docker compose start`
kept running the old image without pulling anything. The running version was effectively
unpredictable.

Note v1-latest tracks releases, not main: the current image (v1.10.0, 2026-06-18) IS the
latest release — the repo being "ahead" is unreleased code, which is explicitly not
wanted here. So this is about guaranteeing and detecting, not catching up.

- docker-compose.yml: both images pinned by digest, pull_policy: missing.
- scripts/check_updates.sh: reports running version/digest vs the latest release and
  registry digest. Changes nothing; meant for the session-start ritual.
- scripts/update_stack.sh: resolve new digest -> stop -> back up surreal_data,
  notebook_data and docker-compose.yml -> repin -> start -> smoke test -> roll back data
  AND compose file if the smoke test fails. The data backup is the point: the app migrates
  the DB on startup and an older app cannot read a migrated DB, so a bad update would
  otherwise be a one-way door. tar runs inside a container because the data dirs are
  root-owned and the host user cannot restore over them.
- scripts/smoke_test.sh: checks what actually breaks here, not just "does it start".
  Every local adaptation leans on upstream internals and can break silently: the
  prompts/podcast directory mount masks the image's directory (a new template upstream
  would be invisible), config/content_core.yaml freezes content-core's defaults (because
  CCORE_CONFIG_PATH replaces rather than merges), and the env-var workarounds depend on
  current content-core/esperanto/podcast_creator behaviour. So it verifies those
  assumptions explicitly, plus API, TTS audio, STT and a real YouTube transcript.

Both scripts read the digest from the lfnovo/open_notebook line specifically. A naive
"first sha256 in the file" grep matches surrealdb (listed first) — caught while testing:
check_updates.sh falsely reported an update, and update_stack.sh would have rewritten the
database image instead of the application.

Verified: smoke test green against the current stack, and red (exit 1) when failures are
injected (dead TTS port, removed template variable). Backup/restore mechanics exercised
separately: 44 MB in 3.3s, restore yields 13 DB files and 91 notebook files. The update
path itself cannot be exercised end to end until a newer image exists.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Dieter Schlüter 2026-07-11 14:12:31 +02:00
commit 4805fe75ed
7 changed files with 434 additions and 7 deletions

View file

@ -183,6 +183,10 @@ journalctl --user -u open-notebook-tts -f # TTS-Logs
./scripts/prune_podcast_data.py --yes # ... und löschen
./scripts/add_video_source.py <url> # Video als Quelle (auch ohne Untertitel)
./scripts/check_updates.sh # gibt es ein neues Release? (ändert nichts)
./scripts/update_stack.sh # Update mit Backup, Rauchtest und Rollback
./scripts/smoke_test.sh # tut der Stack noch, worauf wir uns verlassen?
```
TTS/STT starten nach einem Reboot von selbst — `start_services.sh` ist nur für die
@ -190,6 +194,35 @@ Ersteinrichtung bzw. nach Änderungen an den Unit-Dateien nötig.
---
## 3a. Updates
Die Images sind **auf einen Digest gepinnt** — es läuft immer genau der Stand, der im Repo steht.
Weder ein `docker compose up -d` noch ein Reboot tauscht die Anwendung unbemerkt aus.
Beim Sitzungsstart (oder wann immer Sie mögen):
```bash
./scripts/check_updates.sh # zeigt nur: läuft X, verfügbar ist Y
```
Wenn ein neues Release da ist:
```bash
./scripts/update_stack.sh # Backup -> Update -> Rauchtest -> bei Fehler Rollback
```
Warum nicht automatisch das Neueste bei jedem Start? Ein Update **migriert die Datenbank**, und
eine ältere Anwendung kann eine migrierte Datenbank in der Regel nicht mehr lesen — ein
misslungenes Update ohne Backup wäre eine Einbahnstraße. Zudem hängen die lokalen Anpassungen
dieses Projekts (Podcast-Vorlagen, content-core-Config, Env-Variablen) an Interna der Anwendung
und können still brechen. Genau das prüft der Rauchtest; schlägt er fehl, rollt das Skript
Daten und Compose-Datei automatisch zurück.
Hinweis: `v1-latest` folgt den **Releases**, nicht dem `main`-Branch — der Repository-Stand ist
typischerweise Wochen voraus, aber unveröffentlicht. Wer den will, müsste selbst bauen.
---
## 4. Verzeichnisstruktur
```
@ -207,10 +240,15 @@ open-notebook/
│ ├── systemd/ # Unit-Dateien für die beiden Wrapper
│ ├── voices/ # Referenz-WAVs fürs Voice-Cloning (gitignored)
│ └── logs/ # (gitignored, Altlast der früheren nohup-Variante)
├── backups/ # Sicherungen vor Image-Updates (gitignored)
├── scripts/
│ ├── setup_models.sh # Provider/Modelle einrichten (idempotent)
│ ├── start_services.sh # TTS/STT als systemd-User-Dienste installieren+starten
│ └── prune_podcast_data.py # verwaiste Podcast-Ordner + Zwischenclips aufräumen
│ ├── prune_podcast_data.py # verwaiste Podcast-Ordner + Zwischenclips aufräumen
│ ├── add_video_source.py # Video als Quelle (Untertitel oder Tonspur+Whisper)
│ ├── check_updates.sh # neues Release verfügbar? (ändert nichts)
│ ├── update_stack.sh # Update mit Backup/Rauchtest/Rollback
│ └── smoke_test.sh # prüft die Annahmen, auf denen die Anpassungen beruhen
├── README.md # diese Datei
├── BEDIENUNGSANLEITUNG.md # ausführliche Bedienungsanleitung (Deutsch)
└── CLAUDE.md # technische Architektur-Doku für Weiterentwicklung