Skip to content

Tags and versions

A tag points to a specific build. A complete reference uses name:tag, for example python-tools:v1 or python-tools:production.

Pass one or more tags to Template.build. You can then assign and remove tags without rebuilding the template.

mjs
import { Sandbox, Template } from "@abox-dev/sdk";

const templateName = process.env.TEMPLATE_NAME ?? "versioned-template";
const template = Template().fromBaseImage().runCmd("echo versioned");

await Template.build(template, templateName, {
  tags: ["v1", "stable"],
});

await Template.assignTags(`${templateName}:v1`, "production");
await Template.removeTags(templateName, "stable");

const tags = await Template.getTags(templateName);
console.log(
  tags
    .map(({ tag }) => tag)
    .sort()
    .join(", "),
);

const sandbox = await Sandbox.create(`${templateName}:production`);
try {
  console.log(`Started ${sandbox.sandboxId}`);
} finally {
  await sandbox.kill();
}

assignTags or assign_tags moves a new tag to the selected build. removeTags or remove_tags removes only that pointer; other tags for the build keep working. getTags or get_tags returns the tag, build ID, and assignment time.

Use tags such as v1.4.0 for immutable releases and staging or production for promotion. Starting a sandbox from an explicit tag makes the selected version clear.