Skip to main content
Fluent, immutable builder for declarative sandbox images. Each method returns a new Image instance.

Image.base()

Start from the default OpenSandbox environment (Ubuntu 22.04, Python, Node.js, build tools).
from opencomputer import Image

image = (
    Image.base()
    .apt_install(["curl", "jq"])
    .pip_install(["requests", "pandas"])
    .env({"PROJECT_ROOT": "/workspace"})
    .workdir("/workspace")
)
Returns: Image

Builder Methods

image.apt_install(packages)

packages
list[str]
required
System packages to install via apt-get
Returns: Image

image.pip_install(packages)

packages
list[str]
required
Python packages to install via pip
Returns: Image

image.run_commands(*cmds)

cmds
str (variadic)
required
Shell commands to run during build
Returns: Image

image.env(vars)

vars
dict[str, str]
required
Environment variables to set
Returns: Image

image.workdir(path)

path
str
required
Default working directory
Returns: Image

image.add_file(remote_path, content)

remote_path
str
required
Destination path in the image
content
str
required
File content
Returns: Image

image.add_local_file(local_path, remote_path)

local_path
str
required
Path to the local file
remote_path
str
required
Destination path in the image
Returns: Image

image.add_local_dir(local_path, remote_path)

local_path
str
required
Path to the local directory
remote_path
str
required
Destination path in the image
Returns: Image

Utility Methods

image.to_dict()

Returns the image manifest as a plain dict. Returns: dict

image.cache_key()

Computes a deterministic SHA-256 hash of the manifest for cache lookups. Returns: str