# PIHA-specific overrides for ollama-piha (KB module 5, phase 4 — embed fallback).
#
# RESOURCE CONTEXT: PIHA is the RAM-bound 8 GB box shared with Home Assistant.
# bge-m3 is ~1.2 GB on disk, estimated 1.5–2 GB resident during an embed burst
# (plan §2 decision 2). OLLAMA_KEEP_ALIVE=0 (base compose) makes that a short
# per-call spike, not a resident cost — but the spike lands exactly when other
# SOLARIA-fallback consumers (e.g. paperless fallback OCR) may also be awake,
# so it gets a hard ceiling.
services:
  ollama-piha:
    # Plan §2 D2 starting value — the cgroup OOM killer restarts this container
    # on breach instead of the host OOM killer picking a victim (which could be
    # Home Assistant). Confirmed by live calibration 2026-07-27 (plan §5 step 4,
    # docs/sessions/2026-07-27-kb-f4-fallback.md §4): peak ~983 MiB during an
    # embed burst at a normal-load hour, ~66 MiB idle — comfortably inside this
    # ceiling, verdict GO. Same container config as measured (image,
    # OLLAMA_KEEP_ALIVE=0, this limit), so the number carries over.
    mem_limit: 2560m
    # Deliberately no mem_reservation: the working set is a transient spike and
    # the idle daemon is ~100 MB — soft-reserving gigabytes would permanently
    # take them from HA for a backend that mostly sleeps.
