Skip to content

Recommended host setup

Couchdogs never changes the host (ADR 0004). These are settings we recommend you apply yourself, with the reason for each. The stack runs without them; they make a bad night less bad.

The app store

The store is a public companion repo whose CI builds and signs each app image and one signed index (ADR 0030). It needs no account and no token. Couchdogs never installs anything it has not checked.

  • STORE_INDEX in .env names the index image; setup writes the official one, ghcr.io/citizenjc/couchdogs-store-index. A fork with its own store puts its index here. Empty means no store: the Store says Store not set up.
  • ./couchdogs store-token is only for a private store (a fork's): when its registry refuses an anonymous fetch the Store says Store needs a token. It asks for a GitHub token with only read:packages and saves it in DATA_DIR/runner/store-token (600). Type it at the prompt (a terminal reads it without echoing, a pipe reads one line); never put it on the command line, in .env or in a shell history. The runner uses a newly saved token within seconds, no restart needed.
  • The runner checks the store's signature against its public key, stack/runner/store.pub, built into the runner image. A fork with its own store repo puts its own cosign.pub there (and in that repo's ci/store.pub) and rebuilds the runner; a key that does not match makes the Store say Store signature check failed and stay empty.
  • A new index is fetched at startup, on its own thread, then every ten minutes; a failed fetch is retried after a minute and again every ten. The TV never waits for it, and a failed fetch keeps the last good list. A lower serial than the last one accepted is refused, even if the cache folder was deleted.

Kill runaway apps before the host freezes

Emulators and browsers can eat all memory faster than the kernel's OOM killer reacts, and on a shared host that freezes everything else too. Every Couchdogs container has a memory cap, but a userspace OOM killer is a second line. With earlyoom (Debian: apt install earlyoom), in /etc/default/earlyoom:

EARLYOOM_ARGS="-m 8 -s 15 -r 3600 --prefer ^(firefox|couchdogs-kiosk|dolphin-emu|chdman|es-de|ES-DE)$ --avoid ^(dockerd|containerd|containerd-shim|sshd|qemu-ga|systemd|systemd-journal|init)$"

Acts when free RAM is under 8 % and free swap under 15 %, kills game and browser processes first, and never the container runtime, SSH or init.

If Docker runs in a VM

  • Start the VM first and give it time to stop (Proxmox: startup: order=1,down=60), so a host reboot does not hang on a frozen VM.
  • Pass the GPU wired to the TV through to the VM; ./couchdogs setup finds it.

NVIDIA GPUs

Untested on real NVIDIA hardware so far (ADR 0023). On a host whose TV card is NVIDIA's:

  • Install NVIDIA's proprietary driver (nouveau has no encoder). FFmpeg's NVENC refuses a driver older than the NVENC API its headers were built for; which driver the server image's FFmpeg needs is not checked yet. From driver 560 the next step is usually on by default.
  • Set the kernel parameter nvidia-drm.modeset=1, so Gamescope can drive the TV output over DRM. ./couchdogs setup warns when /sys/module/nvidia_drm/parameters/modeset is not Y.
  • Install the NVIDIA Container Toolkit and register it with Docker (nvidia-ctk runtime configure --runtime=docker). Containers get the host's matching driver libraries from it, so none are baked into our images. Setup cannot check this.
  • ./couchdogs setup writes GPU_VENDOR=nvidia and COMPOSE_FILE=compose.yml:compose.nvidia.yml to .env; nothing else to set. With several NVIDIA cards every container sees all of them and NVENC uses the first, which may not be the TV's card.

The server converts colour on the CPU (a part of a core per 1080p60 stream) and hands NV12 to NVENC.

A host with no TV

Nothing extra is needed. ./couchdogs setup finds no connected output and asks once whether to set the install up without a TV (ADR 0032): it then writes TV=off, leaves screen-tv and the TV's shell out of the stack, and still picks the GPU by its render node, because every device screen and the encoder use it. Nothing is displayed on the host, so a server in a cupboard works; every home is a Moonlight device's own. Two consequences worth knowing: a controller plugged into the host itself does nothing (there is no TV screen to play on), and the Home Assistant button below has no TV screen to restart, so the control API is not started. Turn a TV on later by connecting it and running ./couchdogs setup again.

Container monitors

The runner starts one container per open app and per device screen (couchdogs-<screen>-<app id>, couchdogs-screen-<device>) and stops them when the app is closed or the screen idles out (screens are stopped, never removed). A monitor that alerts on stopped containers should ignore those names, or it raises "container down" whenever someone closes an app.

A Home Assistant button for the TV

The TV can be restarted on request; the runner serves this (ADR 0013), with a token of at least 16 characters. Set TV_CONTROL_TOKEN in .env to a long random value (openssl rand -hex 24), then docker compose up -d. In Home Assistant's configuration.yaml, with the token in secrets.yaml:

rest_command:
  couchdogs_tv_restart:
    url: http://<docker host>:8960/restart
    method: POST
    headers:
      Authorization: !secret couchdogs_tv_auth   # "Bearer <token>"

Call rest_command.couchdogs_tv_restart from a button or script. GET /status with the same header returns the state. The runner also takes POST /home (home screen in front) and POST /stop-front (stop the app in front); docs/architecture.md lists its API. The port is open to the LAN, guarded only by the token.