0020: The store builds unpublished apps with the host's own Docker builder
Status: Accepted (owner, 2026-11-24), as amended on 2026-11-21 (the host's own builder, no cap; the title once said "the buildx CLI and a capped builder"). Proposed (my call, 2026-11-16); partly superseded by ADR 0030 (apps come from a signed store repo; this builder stays for apps that may not be published); the capped builder and the OCI layout are superseded by the amendment of 2026-11-21 below
Context
M7's store installs an app from the TV, so the runner has to make the app's image on the host. Options: Docker's classic builder API (POST /build, per-step memory caps; tested on the host and the cap held, but our Dockerfiles use BuildKit syntax, the classic builder is deprecated and it cannot read the base from an OCI layout); the buildx CLI with a capped docker-container builder (the path stack/images/README.md already documents and the host has used since M5); pulling prebuilt images from a registry (fastest, but needs publishing, and Plex and Steam may not be redistributed).
Decision
The runner image carries the Debian docker-cli and docker-buildx packages and drives its own builder, couchdogs-installer (memory=INSTALL_MEM, default 4g, memory-swap equal to it so the builder never pushes the host into swap, cpu-shares=256), one install at a time. The base is built to an OCI layout in the runner's state volume and each app takes it as the named context couchdogs-base:local; the base is exported into a fresh folder and renamed into place, so an old base's blobs are not kept. An image is labelled couchdogs.source=<hash of its build folder and the base>; a label that differs from the repo's hash offers Update. Installed means the image is present; Remove deletes the image only, and is offered whenever the image is (installed, update, failed). A build is refused when Docker's disk has less than twice the app's size plus 5 GB free, because the build holds its own copy and the loaded image at once.
Consequences
Dockerfiles stay as they are and the builder's cache makes the next build fast. The runner image grows by the docker CLI and buildx, and its memory cap goes to 384 MB because the buildx client streams the loaded image through itself. The runner already holds the Docker socket, so this adds no power; it gets read-only mounts of the images folder and Docker's data root (for the free-space check). Nothing accumulates on the host's Docker disk, which every other service shares: a successful update removes the image the tag left behind, the builder's cache is pruned to INSTALL_CACHE (default 10g) after every install, and a rebuild of the base swaps in a fresh layout. A runner restart ends a running install. A registry stays open for the owner.
Amendment 2026-11-21: the host's own builder, uncapped
Installs missed the goal that they feel quick from the TV, and the price was the builder. Measured on the host: a Plex install took 169 s, of which 138 s was buildx packing the 3.4 GB result into a tarball and Docker unpacking it again (--load); an uncompressed OCI export was no faster (148 s). The same build with --builder default (the docker driver) took 84 s in total, that run without a dnf cache, with "exporting to image" at 14.6 s, because its layers go straight into Docker's image store. Peak memory rose about 1.6 GB, which is the downloads, not heavy compute.
So the runner builds with --builder default, no --load and no --output, and the base is an ordinary local image, couchdogs-installer-base:local, labelled couchdogs.source=<hash of the base folder>. That label says the base is current, and it is also what keeps the household's nightly prune of unlabelled images from deleting it. The app takes it as couchdogs-base:local=docker-image://couchdogs-installer-base:local: the default builder sees local images, so the OCI layout in the runner's cache is gone, and with it the base-export code. couchdogs-installer is removed once by the first install (best effort, logged), which frees its cache.
The docker driver cannot cap one build's memory, so INSTALL_MEM, memory-swap and cpu-shares are gone: a build now runs under the host's own limits. That is acceptable because installs are still one at a time, the peak is downloads rather than compute, and the per-build cap this ADR wanted could not be kept without paying 138 s per install. A good base rebuild removes the base it replaced, which keeps its label once untagged and so would outlive the nightly prune. The cache is still trimmed to INSTALL_CACHE (default 10g) after every install, but it is now Docker's own build cache, shared with any other docker build on the host, so the trim and any host-wide build-cache prune act on both. Everything else stands: the label and hash, Update detection, the previous image removed, the old image kept on a failed build, the disk refusal and BUILD_COPIES=2, because the build still holds its own copies.