outrig build
outrig build builds (or cache-hits) the image for one or more image-configs, without
starting an agent session. It’s useful for:
- Verifying your
Dockerfilebuilds cleanly before you start an agent. - Pre-warming the image so the first
outrig runis fast. - CI: ensuring the agent’s environment still builds after a dependency bump.
Synopsis
outrig build [--image <name>]
[--config <path>]
[--no-cache]
[--all]
--image <name>(default:default-image): build a specific named image-config. This also reaches outrig’s built-in default by name. It has three parts and one invocation warms one of them, so warming the set is three commands:outrig build --image outrig-default(pulls the primary), then--image outrig-default-fs(pulls the filesystem server), then--image outrig-default-shell(builds the shell server, the only part that is built rather than pulled).--all(default: off): build every image-config defined in the config file. The built-in default is deliberately not among them –--allmeans the image-configs you declared, and pulling and building outrig’s fallback in every repo would be a surprise.--config <path>(default: walks up from cwd): read the repo config from this file instead. See Reference -> CLI for how its paths resolve.--no-cache(default: off): force rebuild even on cache hit. Passes--no-cachetobuildah.
What it does
- Loads
.agents/outrig/config.tomland validates every image-config in the merged config. Agent/model wiring is not required for image builds. - For each selected image-config:
- Computes the cache key (blake3 over Dockerfile content, resolved build-args,
the OutRig labels derived from
[images.<name>.mcp], and the context content hash). - If a tag matching that key exists and
--no-cacheis not set, printsimage ready (cache hit)and skips. - Otherwise runs a buildah build to a temporary tag:
A literal build-arg is passed asbuildah build --tag <image-config-name>:outrig-tmp-... \ --file <dockerfile> \ [--build-arg KEY=value | --build-arg KEY ...] \ <context>KEY=value. A${VAR}one is passed as a bareKEY, with the value in buildah’s environment rather than on its command line, and outrig’s errors and logs show it asKEY=${VAR}– see the value syntax. In a repo config a${VAR}build-arg may name only a variable the global config lists in[repo]env-allow; any other is refused when the config loads, before buildah runs. Then it reads any inherited/Dockerfileorg.outrig.mcplabel, overlays[images.<name>.mcp], and commits the final<image-config-name>:<hash>image with the mergedorg.outrig.mcplabel. A label it cannot decode fails the build here, before anything is committed, with an error naming the image-config; see Concepts -> MCP Servers. The temporary tag is then removed, whether or not the build succeeded. If buildah refuses the removal, outrig warns and reissues it in the background rather than leaving the tag behind; the build’s own result stands either way. When the label-stamping working container could not be removed either, the tag is removed after it, since buildah refuses to remove an image a container was made from. The repository is the[images.<name>]block key, so the built image is self-describing inpodman images; the<hash>is the content-addressed cache key.
- Computes the cache key (blake3 over Dockerfile content, resolved build-args,
the OutRig labels derived from
Examples
Build the default:
$ outrig build
[outrig] image-config: coding
[outrig] dockerfile: .agents/outrig/images/coding/Dockerfile
[outrig] context: .agents/outrig/images/coding
[outrig] image tag: coding:8c2a4f7e91d6b5a3
[buildah] STEP 1/6: FROM docker.io/library/node:24-bookworm-slim
...
[outrig] image ready: coding:8c2a4f7e91d6b5a3
Cache hit on the second run:
$ outrig build
[outrig] image ready (cache hit: coding:8c2a4f7e91d6b5a3)
Build a specific image-config:
$ outrig build --image planning
[outrig] image-config: planning
...
[outrig] image ready: planning:b91e3a6d217f4c08
Build every image-config in one go:
$ outrig build --all
[outrig] image-config: coding -> coding:8c2a4f7e91d6b5a3 (cache hit)
[outrig] image-config: planning -> planning:b91e3a6d217f4c08 (built in 27s)
[outrig] all images ready
Force a rebuild without changing files:
$ outrig build --no-cache
Cancelling a build
Ctrl-C, a timeout, or an abandoned MCP call stops a build in flight. outrig asks buildah to stop rather than killing it outright, and waits a bounded grace before escalating, because a buildah that unwinds removes the per-stage working containers it created and a killed one does not. Those are the one engine resource outrig cannot name for itself: buildah derives their names from the base image and offers no way to label them, so the only process that can prove which belong to this build is buildah.
What a cancelled build leaves:
- The temporary
outrig-tmp-*tag is removed. It carries this build’s pid and a nonce, so nothing else on the machine can be what the removal names. - The stage working containers are removed by buildah, if the stop landed while a
RUNwas executing. - The final
<name>:<hash>tag was never created; the commit is the last step.
The gap is the second row’s condition. buildah installs its signal handler only while a RUN’s
command is running, so a build stopped during a pull, a COPY, the commit, or the seam between
two RUNs still ends where it stands and can leave a working container behind. Collect those
with outrig clean --build-containers.
Exit codes
0– every selected image is built or cache-hit.- non-zero – at least one image failed to build. The buildah stderr is reproduced with the
[buildah]prefix, ending with the exact failing step.
See also
- Concepts -> Containers – Dockerfile conventions.
- Concepts -> Workspace – runtime UID/GID mapping (no build-time user setup needed).
- outrig run – what gets run after the image is ready.
- Reference -> CLI – every flag.