Skip to content
Cloudflare Docs

Configuration

Configure your Sandbox SDK deployment with Wrangler, customize container images, and manage environment variables.

Wrangler configuration

Configure Durable Objects bindings, container images, and Worker settings in wrangler.jsonc.

Dockerfile reference

Customize the sandbox container image with your own packages, tools, and configurations.

Quick reference

Essential wrangler.jsonc settings

{
"name": "my-worker",
"main": "src/index.ts",
"compatibility_date": "2024-09-02",
"compatibility_flags": ["nodejs_compat"],
"durable_objects": {
"bindings": [
{
"name": "Sandbox",
"class_name": "Sandbox",
"script_name": "@cloudflare/sandbox"
}
]
},
"containers": [
{
"binding": "CONTAINER",
"image": "ghcr.io/cloudflare/sandbox-runtime:latest"
}
]
}

Common Dockerfile customizations

FROM ghcr.io/cloudflare/sandbox-runtime:latest
# Install additional Python packages
RUN pip install scikit-learn tensorflow pandas
# Install Node.js packages globally
RUN npm install -g typescript ts-node
# Install system packages
RUN apt-get update && apt-get install -y postgresql-client
# Add custom scripts
COPY ./scripts /usr/local/bin/

Environment variables

TypeScript
// Pass to sandbox at creation
const sandbox = getSandbox(env.Sandbox, 'my-sandbox');
// Configure environment for commands
await sandbox.exec('node app.js', {
env: {
NODE_ENV: 'production',
API_KEY: env.API_KEY,
DATABASE_URL: env.DATABASE_URL
}
});