Template builds require the microVM runtime and template build support in the
target deployment.
Setup
uv pip install "${NULLSPACE_SDK_INSTALL_SPEC:-nullspace-sdk==0.1.9}"
export NULLSPACE_API_KEY=ns_live_...
export NULLSPACE_API_URL=https://api.your-nullspace-domain
Python
from nullspace import Sandbox, Template, default_build_logger
builder = (
Template()
.from_ubuntu_image("22.04")
.apt_install(["curl"])
.run_cmd("curl --version > /tmp/curl-version.txt")
.set_runtime_envs({"APP_ENV": "demo"})
)
build = Template.build(
builder,
name="demo-curl",
tags=["stable"],
on_log_entry=default_build_logger(),
)
print(f"template built: {build.name}")
with Sandbox.create(template=build.canonical_ref, timeout=120) as sandbox:
print(sandbox.commands.run("cat /tmp/curl-version.txt", shell=True).stdout.splitlines()[0])
print(sandbox.commands.run("printenv APP_ENV", shell=True).stdout.strip())
Template.delete(build.canonical_ref)
Production note
Use tags such as:dev, :stable, and :prod to promote builds without
changing application code.
Guide: Templates.