Guides
Templates
A template is what a new sandbox starts as: a size, a route, and the commands that set it up. Write it once and every sandbox started from it arrives with the same tools installed, on any provider.
Make one
In the dashboard under Templates, or as a file named annex.yml:
name: node-dev
description: Node, pnpm and ripgrep
vcpu: 2
memory_gib: 4
route: cheapest
default: true # every new sandbox in the workspace starts from it
# always_run: true # run the set-up in every sandbox; never reuse its saved result
secret_groups: [github]
setup:
- npm install -g pnpm
- |
apt-get update
apt-get install -y ripgrepannex template apply # saves the annex.yml in this folder
annex start # in that folder: saves it, then starts from it
annex start --template node-devOver the API, POST …/templates with the same fields as JSON saves a template under its name; saving a name that exists replaces it.
From a sandbox you set up by hand
Set a sandbox up the way you want it, then turn what you did into a template. On the sandbox's page, Save as template lists the commands that were run in it: delete the ones that were only looking around, name it and save. From a terminal:
annex template from sbx_… > annex.yml # then edit it
annex template applyStart from one
curl -X POST https://annex.eversonder.com/v1/workspaces/wsp_…/sandboxes -H "Authorization: Bearer $KEY" \
-H 'Content-Type: application/json' -d '{"template": "node-dev"}'- Whatever the request says wins:
{"template": "node-dev", "vcpu": 8}starts the template with 8 vCPU. - A template marked
defaultis used by every start in the workspace that names none."template": "none"starts without it. - In the dashboard, the Start sandbox panel has a template picker with the default already chosen.
How the set-up runs
- The commands run in order in the new sandbox, as ordinary commands: each is in the sandbox's log.
- The first one that fails stops the rest. The sandbox stays up, and its
setupsays which command failed and why. - A start waits up to 45 seconds for the set-up. If it takes longer, the answer says
setup.state: "running"with how many commands are done, and it carries on; read the sandbox again to see it finish. - Until the set-up finishes the sandbox takes no other command: one sent early is
409 sandbox_setting_up, and works once it is done. Files and logs can be read meanwhile. - If Annex restarts mid-way the set-up carries on from the command it was on, which runs again from its start: write commands that are safe to run twice.
- The same commands are kept as the sandbox's recipe, so a resume from a checkpoint rebuilds the same environment.
The set-up runs once
The first sandbox started from a template runs its commands. When they finish, Annex saves the files they changed and, in the next sandbox started from the same commands, puts those files back instead of running the commands again. It uses no provider's own images, so it works the same on every provider and on your own servers. A reused set-up says so: setup.note reads "Reused the saved result of these commands".
- A saved result belongs to one workspace, one provider, one kind of machine (its processor and system) and one exact list of commands. Change a command, or start on another provider, and the commands run once there and are saved for it.
- It holds files, not running programs, and nothing under
/tmp. A set-up that starts a program which must be running should sayalways_run: true(Run the commands every time in the dashboard): its commands then run in every sandbox. - It is made again after 14 days, so what it installed doesn't go stale, and kept sealed with your workspace's own key. A set-up that writes a secret to a file puts that secret in the saved result, as it would in the sandbox.
- Where it can't work, the commands simply run in every sandbox, as before: a sandbox whose user is not root and has no
sudo, one without GNU tar (Alpine), a result over 1 GiB compressed, or one that takes longer to move than the commands take to run. - A set-up that takes under ten seconds isn't saved: running it is as quick.
Limits
50 templates a workspace, 30 commands a template, 4,096 characters a command, 30 minutes a command. Anyone in the workspace, and its API keys, may read and change templates.