template
kind: templatename: sandboxspec: driver: smolvm image: debian:bookworm-slim net: true cpus: 4 memory: 8192 build: - apt-get update && apt-get install -y git build-essential - git clone https://github.com/acme/app /work/app refresh: - git -C /work/app pull -q --ff-only stamp: git -C /work/app rev-parse HEADA template holds what a vm holds and turns it into a pack, a copy of a prepared machine’s disk. It never runs as a machine. A vm with template: sandbox is created from the template’s current build, so it starts with the tools, checkout and build outputs the build left on the disk instead of installing them again. A template has to use a driver that can pack a machine; smolvm can.
The resource is wanted like any other, and a wanted template runs nothing by itself. A build starts with runy build.
A template takes the keys of a vm, except from, pack, template and persistent, which belong to a machine that runs. Unknown keys are rejected. It adds three:
| field | default | |
|---|---|---|
build |
shell commands run in the new builder machine of a clean build, one after the other | [] |
refresh |
shell commands run in the kept builder of a refresh build, after hooks.start |
[] |
stamp |
a command whose output is recorded with the build, such as git rev-parse HEAD |
none |
build takes the place of hooks.create here: hooks.create is neither run in the builder nor inherited by instances, so put the setup in build. hooks.start runs in the builder of a refresh build, and instances inherit it and run it on every start. Children such as a port are declared as on a vm and are cloned under each instance.
A template in another namespace than its instance may not read other resources through expressions; such a template can only be used by vms of its own namespace.
secrets are for the instances: each instance gets the template’s entries, plus its own, an instance’s entry for a secret replacing the template’s. The builder machine gets no secret, since its disk is packed and every instance starts from it, and a change of secrets never makes a build stale. A template that lists a secret waits for it like a vm does. See Secrets in machines.
branchable is for the instances too: an instance of a template with branchable: true runs as a branch source (an instance may set it itself), and the builder never does, since it is packed, never branched.
egress applies to the builder machine as well as to the instances, so a build that downloads dependencies reaches only what the policy allows; the builder has no credentials, so no credential hosts are added to its allow list. Instances inherit the policy, and an instance’s own egress replaces it whole. A changed egress.allow is applied to the kept builder of a refresh build in place, and a changed deny or block_private makes the next build clean.
Building
Section titled “Building”runy build sandbox # a refresh build, or a clean one when it has to beruny build sandbox --clean # from nothingruny build sandbox --wait # follow it; a non-zero exit when it failsruny build sandbox -n dev # the template dev/template/sandboxThe template is <name>, template/<name> or <namespace>/template/<name>. The same request is the build signal, runy signal template/sandbox build or runy signal template/sandbox '{"build":{"clean":true}}'. A template that is idle or in a disabled namespace has to be started first, and a build asked for while another runs is refused.
A build runs in the template’s builder machine, runy-build-<namespace>-<name> (runy-build-<name> at the top level), which stays stopped between builds.
- A clean build deletes any builder, creates a new one from the image, runs the
buildsteps, and packs it. - A refresh build starts the kept builder, applies the template’s changed
cpus,memory,envorvolumesto it, runshooks.startand therefreshsteps, and packs it.
After the steps runy runs stamp, records its output, packs the builder and leaves it stopped. A failing stamp fails the build. The steps are journaled in the template’s Output.
A build is clean, whatever you asked for, when:
--cleanasks for it;- the template is stale: its
image,cmd,user,smolvm.smolfile,stop_timeoutorbuildsteps changed since the current build; - there is no build yet, or the current one was adopted;
- there is no builder machine, for instance a first build, or one deleted by hand.
The journal says which applies. A failed refresh keeps the builder for the next build to retry on, and a failed clean build deletes it. A build the daemon stopped in the middle, by a restart or an upgrade, runs again once as the kind of build it was.
Status
Section titled “Status”{ "state": "built", "build": { "id": 3, "path": "/Users/me/.cache/runy/.../builds/3.smolmachine", "size": 2147483648, "created": 1794441600000, "stamp": "9b1f4c0e", "clean": false }, "builds": [ { "id": 2, "size": 2097152000, "created": 1794355200000, "stamp": "77aa01c3", "clean": true, "current": false, "instances": ["_/vm/task-1"] }, { "id": 3, "size": 2147483648, "created": 1794441600000, "stamp": "9b1f4c0e", "clean": false, "current": true, "instances": [] } ], "stale": false, "builder": { "machine": "runy-build-sandbox", "state": "stopped" }}state is the latest build’s: unbuilt, building, built or failed. build is the current build, null before the first, and stays the current one while a later build runs or after it fails. builds lists the builds whose packs are kept, with current and the ids of the instances created from each. stale is true when the template changed in a way that makes its next build clean. builder is the builder machine and its driver state while it exists, else null. error appears when the latest build failed. created is in unix milliseconds and size in bytes; build.path is the pack’s file.
A bare ${ template.sandbox } reads status.build, so needs: ["${ template.sandbox }"] waits for a first build. A vm made from the template waits on it by itself.
Builds on disk
Section titled “Builds on disk”Builds are files in the template’s folder under the daemon’s cache, builds/<n>.smolmachine, numbered per build. After every build runy deletes the builds that are neither the current one nor the source of an instance, so the disk holds the current build, the builds machines still depend on and nothing else. A build kept for an instance stays after the instance is gone until the next build; runy gc lists it and runy gc --apply prunes it through the template, as does the prune signal (runy signal template/sandbox prune).
Remove one by hand with the remove signal:
runy signal template/sandbox '{"remove":{"build":2}}'It is refused for the current build, for a build named by instances (the error lists them) and for the build running now. The console offers Remove build on a build’s page and menu.
Adopting a pack
Section titled “Adopting a pack”A pack made elsewhere becomes the template’s next and current build with the adopt signal. The path is relative to the workspace root, and stamp is optional:
runy signal template/sandbox '{"adopt":{"path":"packs/sandbox.smolmachine","stamp":"v1"}}'No machine is involved. The next build after an adopted one is clean, since the builder does not hold the adopted disk.
Instances
Section titled “Instances”runy vm run sandbox --name task-1 creates a vm from the current build, see instances of a template. Later builds never change an instance that exists; they are used by the instances created afterwards.
Lifecycle
Section titled “Lifecycle”Stopping the template, disabling its namespace or stopping the daemon cancels a running build and stops the builder, and keeps the builder and the builds. Removing the template’s document, by a file edit or runy delete, deletes the builder and every build no instance was created from; the builds instances were created from stay, and the journal names the instances.

