Sandbox.create({ template: 'my-alias' }).
TemplateBase
TemplateBase is a fluent class for defining template contents. Chain methods to build the definition, then pass it to Template.build().
.fromBaseImage(image?)
Set the base Docker image.
string
default:"'ubuntu:22.04'"
Docker image tag.
this
.aptInstall(...packages)
Install apt packages.
string[]
required
One or more package names to install via
apt-get install.this
.runCmd(cmds)
Add a build-time command (equivalent to a Dockerfile RUN).
string[]
required
Command as an array of strings (executable + arguments).
this
.copy(src, dst, mode?)
Copy a local file into the image at build time.
string
required
Local path to the file.
string
required
Destination path inside the image.
number
Unix file permission bits (e.g.
0o755 for executable).this
.setEnvs(envs)
Set environment variables baked into the image.
Record<string, string>
required
Key-value pairs to set as environment variables.
this
.setStartCmd(cmd)
Set a command to run when the sandbox boots.
string
required
Shell command to execute on sandbox start.
this
.toJSON()
Serialize the template to a JSON-friendly object for the API.
Returns Record<string, any>
Template
Template is a static class for submitting and querying template builds. All methods are async.
Template.build()
Submit a template build and wait for completion.
TemplateBase
required
The template definition to build.
string
required
Human-readable name used as
template in Sandbox.create().TemplateBuildOpts
Optional build options.
TemplateBuildOpts
number
Number of CPUs for the build worker.
number
Memory in MB for the build worker.
(log: string) => void
Callback invoked for each log line during the build.
string
API key override.
string
Domain override.
number
Per-request HTTP timeout in milliseconds.
Promise<BuildInfo>
Template.buildInBackground()
Submit a template build and return immediately without waiting.
Template.build() except onBuildLogs is excluded.
Returns Promise<BuildInfo>
Template.getBuildStatus()
Poll the status of a background build.
string
required
Build ID from a previous
build() or buildInBackground() call. Must be
alphanumeric with hyphens/underscores.GetBuildStatusOpts
Optional:
apiKey, domain, requestTimeout.Promise<TemplateBuildStatus>