Sandbox.create(template="my-template") to boot sandboxes that start from a known state.
TemplateBase
TemplateBase is a fluent builder for defining the contents of a template. Build up the definition by chaining methods, then pass it to Template.build().
Methods
.from_base_image(image)
Set the base Docker image.
Docker image tag to use as the base.
TemplateBase (for chaining)
.apt_install(*packages)
Install apt packages.
One or more package names to install via
apt-get install.TemplateBase
.run_cmd(cmds)
Add a shell command to run during the build (equivalent to a Dockerfile RUN).
Command as a list of strings (the executable and its arguments).
TemplateBase
.copy(src, dst, mode)
Copy a local file into the template image at build time.
Local path to the file to copy.
Destination path inside the image.
Unix file permission bits (e.g.
0o755 for executable).TemplateBase
.set_envs(envs)
Set environment variables baked into the template.
Key-value pairs to set as environment variables.
TemplateBase
.set_start_cmd(cmd, ready_check)
Set a command to run when the sandbox boots.
Shell command to execute on sandbox start.
Optional readiness probe configuration. Reserved for future use.
TemplateBase
.to_dict()
Serialize the template definition to a dict suitable for the API.
Returns dict
Template
Template is a static class for building and querying templates via the API.
Template.build()
Submit a template build and wait for it to complete.
The template definition to build.
Human-readable name for the template. Used as the
template parameter
in Sandbox.create().Number of CPUs for the build worker.
Memory in MB for the build worker.
Callback invoked for each log line emitted during the build.
API key override.
Domain override.
Per-request HTTP timeout in seconds.
BuildInfo
Template.build_in_background()
Submit a template build and return immediately without waiting for it to finish.
Template.build() except on_build_logs is not accepted.
Returns BuildInfo
Template.get_build_status()
Poll the status of a background build.
Build ID from a previous
build() or build_in_background() call.API key override.
Domain override.
Per-request HTTP timeout in seconds.
TemplateBuildStatus
Data models
BuildInfo
TemplateBuildStatus
CopyItem
AsyncTemplate
UseAsyncTemplate for async applications. It has the same static methods as
Template but all are coroutines:
await AsyncTemplate.build(...), await AsyncTemplate.build_in_background(...), await AsyncTemplate.get_build_status(...).