Files
mindnet/deploy/healthcheck.py
T
LarsandClaude Opus 5.5 7a225ba2b6 Prepare containerized dev/prod deployment (inactive)
Add a Docker image and separate Compose projects for development and
production, based on the stable main behaviour without the privacy
gateway. Nothing is wired into the existing systemd deploy workflow.

- One non-root image (api | ui | preflight), base image pinned by
  digest, dependencies from a hash-locked universal lock without torch
  and sentence-transformers (MiniLM is not on the runtime path)
- Preflight aborts on: VECTOR_DIM != 768 or non-nomic embedding
  profile, implicit or cross-env collection prefix, cloud keys without
  explicit egress acknowledgement, missing/empty or writable vault mount
- Vault is a read-only NAS bind mount without host-path autocreation;
  healthcheck turns unhealthy when the vault sentinel disappears
- Dev runs its own Qdrant; prod reuses the existing host instance
- API published on loopback only; read-only rootfs, cap_drop ALL,
  no-new-privileges
- Dev workflow kept as an inactive template outside .gitea/workflows
- Docs: operations guide and migration plan with release gates, test
  baseline classification, R2/R3 and privacy gateway requirements

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 14:33:18 +01:00

41 lines
1.3 KiB
Python

"""
FILE: deploy/healthcheck.py
DESCRIPTION: Docker-Healthcheck für API und UI.
API ist nur gesund, wenn /healthz antwortet UND der Vault-Sentinel
lesbar ist. Ein zur Laufzeit ausgefallenes NAS wird so als
'unhealthy' sichtbar, statt still auf einem leeren Mountpunkt zu laufen.
USAGE: healthcheck.py api | ui
"""
from __future__ import annotations
import os
import sys
import urllib.request
from pathlib import Path
URLS = {
"api": "http://127.0.0.1:8000/healthz",
"ui": "http://127.0.0.1:8501/_stcore/health",
}
def main(mode: str) -> int:
try:
with urllib.request.urlopen(URLS[mode], timeout=5) as res:
if res.status != 200:
return 1
except Exception as e:
print(f"health: {mode} nicht erreichbar ({type(e).__name__})")
return 1
if mode == "api" and os.getenv("MINDNET_VAULT_REQUIRED", "true").lower() == "true":
root = Path(os.getenv("MINDNET_VAULT_ROOT", ""))
sentinel = root / os.getenv("MINDNET_VAULT_SENTINEL", "_system/dictionary/edge_vocabulary.md")
if not sentinel.is_file():
print(f"health: Vault-Sentinel fehlt ({sentinel})")
return 1
return 0
if __name__ == "__main__":
sys.exit(main(sys.argv[1] if len(sys.argv) > 1 else "api"))