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).
import { Image } from "@opencomputer/sdk";

const image = Image.base()
  .aptInstall(['curl', 'jq'])
  .pipInstall(['requests', 'pandas'])
  .env({ PROJECT_ROOT: '/workspace' })
  .workdir('/workspace');
Returns: Image

Builder Methods

image.aptInstall(packages)

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

image.pipInstall(packages)

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

image.runCommands(...cmds)

cmds
string[]
required
Shell commands to run during build
Returns: Image

image.env(vars)

vars
Record<string, string>
required
Environment variables to set
Returns: Image

image.workdir(path)

path
string
required
Default working directory
Returns: Image

image.addFile(remotePath, content)

remotePath
string
required
Destination path in the image
content
string
required
File content
Returns: Image

image.addLocalFile(localPath, remotePath)

localPath
string
required
Path to the local file
remotePath
string
required
Destination path in the image
Returns: Image

image.addLocalDir(localPath, remotePath)

localPath
string
required
Path to the local directory
remotePath
string
required
Destination path in the image
Returns: Image

Utility Methods

image.toJSON()

Returns the image manifest as a plain object. Returns: ImageManifest

image.cacheKey()

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