Skip to main content

Building an environment

An environment (a sandbox template) is the container image a task's sandbox runs: the operating system, the programs the agent may use, and the agent's own runtime. The installation builds Minimal and Workstation (and, optionally, Desktop); for other tools you build an image of your own from one of them, on the engine host, and register it by its ID. This page is for whoever builds such an image. The settings pages describe the Environments page itself (Environments).

Not yet run on a real install. The commands on this page are written from the code and the guides and have not been run against an installation yet. Each block says so until it has been.

What exists, and what does not​

  • The gateway never pulls or builds. You build or pull the image on the engine host (the machine whose container engine runs the sandboxes), then register it by its image ID or registry digest. There is no upload, registry sign-in or build step in the web app or the API.
  • Only images derived from a current built-in are accepted: FROM Workstation or Minimal, keeping their layers and their agent runtime. An image from another base is refused.
  • A recipe needs no Dockerfile for the common case of adding packages: deploy/build-environment.sh builds one from a short TOML file (Build one from a recipe).
  • Capabilities are declared, not detected. You tick what the image offers. The known capabilities are shell, python, node, build, browser, data and desktop; there is none for a GPU.
  • On a microVM installation each image also needs a root filesystem built by an operator (below), which the gateway does not build.
  • A new build of the base does not rebuild your image. Rebuild it yourself to take the base's updates; until then it keeps the base it was built from.

What the base images hold​

ImageTagWhat it has
Minimaltqa-runtime:baseDebian 13 from a pinned, signed snapshot, with bash, coreutils, findutils, grep, sed, git, Python 3 (python is python3), CA certificates, procps, tini and util-linux, and the agent runtime. Capabilities shell, python
Workstationtqa-runtime:workstationMinimal, plus pip, venv and pytest; build-essential; ripgrep, fd-find, jq, curl, wget, zip and unzip, less, file, tree, sqlite3; Chromium with Playwright 1.63 for Node; Python's pandas, matplotlib and openpyxl; Node.js 24 with npm, npx and corepack; Go 1.27; fonts for Chinese, Japanese, Korean and emoji. Capabilities shell, python, node, build, browser, data

Every package of a Workstation build, with its version and licence, is listed in images/runtime/PACKAGES.md and in the image at /usr/share/tqa/PACKAGES.md. Both images run as the user 1000:1000, with /workspace as the working folder and the runtime as the entry point.

Build your image​

Start from Workstation or Minimal, switch to root for the install, and end as the runtime user again:

# Not yet run on a real install.
FROM tqa-runtime:workstation
USER 0:0
RUN apt-get update \
&& apt-get install -y --no-install-recommends pandoc python3-pandas \
&& rm -rf /var/lib/apt/lists/*
USER 1000:1000
# Not yet run on a real install.
docker build -t my-environment .
docker image inspect --format '{{.Id}}' my-environment

The image ID (sha256:…) is what you register. A tag can later point at another build, so the gateway takes an ID or a registry digest (name@sha256:…), never a tag.

The rules the gateway checks​

The gateway checks each image in the background before people can pick it. It never runs the image's code. The checks stop at the first failure, which the Environments page names with what to do:

  1. Present: the image is on the engine host, with the ID you gave.
  2. Derived: its layers begin with all the layers of a current Workstation or Minimal. Do not squash or flatten the image.
  3. A current runtime: the base's protocol label is still there and new enough for this version. An image built on an old base is refused: rebuild it FROM a current one.
  4. The image policy:
    • no VOLUME;
    • no environment key the installation's sandboxes do not set. The base images declare only PATH and HOME, so do not add ENV lines for anything else; a key missing from [sandbox.env] is refused;
    • a numeric, non-root user (end with USER 1000:1000);
    • the base's entry point, unchanged.
  5. The runtime intact: /usr/local/bin/tqa-runtime is byte for byte the base's. Do not replace or remove it.
  6. No credential files in your own layers: private keys, SSH keys, .git-credentials, .netrc with a password, AWS, Docker, npm and PyPI credentials. Keep secrets out of the build itself: a file a later step deletes is still in the earlier layer, and anyone with the image can extract it. Tasks get credentials from the gateway's secret store, never from the image (Credential files in an image).
  7. On microVM installations: a root filesystem built for this image ID (below).

Register it​

On the Environments page, choose Add environment and pick the image among your images on the host (or paste its ID under Advanced). Then tick its capabilities and give its size, or leave the size empty for the installation's defaults. The gateway checks it, and people can pick it once it is verified. Through the API, with an administrator's session or token:

# Not yet run on a real install.
curl -sS "$TQA_URL/api/v1/admin/environment-images" -H "Authorization: Bearer $TQA_TOKEN" | jq
curl -sS -X PUT "$TQA_URL/api/v1/admin/templates/docs-tools" \
-H "Authorization: Bearer $TQA_TOKEN" -H "Content-Type: application/json" -H "Idempotency-Key: $(uuidgen)" \
-d '{"display_name": "Docs tools", "image": "sha256:<the image ID>", "capabilities": ["shell", "python", "node", "build", "browser", "data"]}'
curl -sS -X POST "$TQA_URL/api/v1/admin/templates/docs-tools/check" -H "Authorization: Bearer $TQA_TOKEN"

GET /api/v1/admin/environment-images lists the images on the host that hold a runtime, with what each is based on and whether this version can run it. A template can also be seeded in gateway.toml as a [[templates]] entry, where acknowledged_secret_files (file only) accepts a credential file that is meant to be in the image. The exact fields of the PUT are in the API reference.

A change of image reaches a task at its next sandbox, once its current run has ended; a run in progress keeps the image it started with.

On a microVM installation​

Tasks in microVMs (backend = "firecracker") boot a root filesystem built from the image, an operator step on the host. It needs the VM host image (tqa-vmm) built once:

# Not yet run on a real install.
docker build -f images/vmm/Dockerfile --target vmm -t tqa-vmm .
python3 images/rootfs/build_rootfs.py --image my-environment --vmm-image tqa-vmm --out <storage.root>/images
  • What it writes: <storage.root>/images/<image ID>/ with rootfs.ext4 and its manifest, both read-only. The build is keyed by the image ID.
  • What it checks: that the runtime read back from the root filesystem equals the image's. An existing build is never replaced.
  • When the gateway refuses it: while no build exists, or one was made by an older builder, the image is refused (rootfs_missing, rootfs_outdated). After building, choose Check the image now.
  • A registry-digest pin: build the root filesystem from an image pulled or pushed under that digest; exactly one build may list it.

The details are in images/rootfs/README.md. Neither the gateway nor this page removes old images or root filesystems: that stays an operator's job.