ai: package llama-server for all three deployments, with idle unload

install_llama_cpp.sh builds llama-server from the SHA-pinned v0.3.0
source tarball (single source of truth: on-device upgrade, Pi image,
Live ISO, and the new docker/llm container all call it; version-marker
makes re-runs no-ops).  start_llama_server.sh refuses to start unless
ai.yaml enables AI and the active model file exists — which also covers
unmounted media.  wrolpi-llm.service is installed but deliberately
never enabled at boot: the Controller starts it on demand (registered
in managed_services; the llm compose service follows the samba
pattern), and the API's perpetual idle-unload worker asks the
Controller to stop it after the configured idle minutes.  llama-server
is localhost-only natively, internal-network-only in docker, and never
proxied by Caddy.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Roland 2026-08-25 21:36:00 -06:00
parent 256750e538
commit d9924b6b53
No known key found for this signature in database
GPG key ID: 1BA620CE6C9A4680
18 changed files with 406 additions and 4 deletions

View file

@ -42,6 +42,8 @@ services:
# Sanic 25.x wants 'spawn' but our code uses 'fork' for multiprocessing.
# This tells Sanic to accept the existing start method.
- SANIC_START_METHOD_SET=1
# llama-server runs in the llm container (native installs use 127.0.0.1).
- LLAMA_URL=http://llm:11435
volumes:
- './main.py:/opt/wrolpi/main.py'
- './wrolpi:/opt/wrolpi/wrolpi'
@ -147,6 +149,21 @@ services:
test: [ 'CMD-SHELL', 'curl http://127.0.0.1:80' ]
interval: 1m
llm: # llama-server (local AI) - started/stopped by the controller on demand; the API stops it when idle.
build:
context: .
dockerfile: docker/llm/Dockerfile
restart: "no"
depends_on:
controller:
condition: service_healthy
volumes:
- ${MEDIA_DIRECTORY:-./test}:/media/wrolpi
- './docker/llm/entrypoint.sh:/entrypoint.sh'
healthcheck:
test: [ 'CMD-SHELL', 'curl http://127.0.0.1:11435/health' ]
interval: 1m
samba: # Samba file sharing - started/stopped by the controller based on configured shares.
build:
context: .