Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,17 @@ runtime/agent/src/version.rs
# Python cache and compiled binaries in examples
API/examples/__pycache__/
API/examples/go/go
__pycache__/
*.pyc
.venv/
venv/
*.egg-info/

# Node.js example artifacts
node_modules/
dist/
build/
*.log

# OpenAI Agents SDK examples (runtime artifacts)
examples/openai-agents-example/__pycache__/
Expand Down
1 change: 1 addition & 0 deletions docs/guide/tutorials/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Hands-on examples demonstrating various Cube Sandbox use cases. Each example is
|---------|-------------|
| [Code Sandbox Quickstart](https://github.com/tencentcloud/CubeSandbox/tree/master/examples/code-sandbox-quickstart) | The most basic usage: create a sandbox, run Python code, execute shell commands, manage network policies, and more — all via the E2B SDK. |
| [Browser Sandbox (Playwright)](https://github.com/tencentcloud/CubeSandbox/tree/master/examples/browser-sandbox) | Run a headless Chromium inside a MicroVM and control it remotely with Playwright via CDP. |
| [Node.js Web Sandbox](https://github.com/tencentcloud/CubeSandbox/tree/master/examples/node-web-sandbox) | Build a Node.js 20 web-service template from `cubesandbox-base`, launch it through the E2B-compatible SDK, and validate both envd command execution and the exposed HTTP endpoint. |
| [OpenClaw Integration](https://github.com/tencentcloud/CubeSandbox/tree/master/examples/openclaw-integration) | Deploy Cube Sandbox and configure the OpenClaw skill so AI agents can execute code in isolated VM environments. |
| [SWE-bench with mini-swe-agent](https://github.com/tencentcloud/CubeSandbox/tree/master/examples/mini-rl-training) | Automate SWE-bench coding tasks in isolated sandboxes using cube-sandbox + mini-swe-agent, with multi-model support and RL training vision. |
| [OpenAI Agents SDK Integration](https://github.com/tencentcloud/CubeSandbox/tree/master/examples/openai-agents-example) | Wire OpenAI Agents SDK's `E2BSandboxClient` to Cube Sandbox. Ships a minimal Shell Agent with Pause/Resume and a full SWE-bench Django debugging agent with streaming + tracing. |
Expand Down
1 change: 1 addition & 0 deletions docs/zh/guide/tutorials/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
|------|------|
| [代码沙箱快速入门](https://github.com/tencentcloud/CubeSandbox/tree/master/examples/code-sandbox-quickstart) | 最基础的用法:创建沙箱、执行 Python 代码、运行 Shell 命令、管理网络策略等,全部通过 E2B SDK 完成。 |
| [浏览器沙箱(Playwright)](https://github.com/tencentcloud/CubeSandbox/tree/master/examples/browser-sandbox) | 在 MicroVM 中运行无头 Chromium,通过 CDP 协议使用 Playwright 远程控制浏览器。 |
| [Node.js Web 沙箱](https://github.com/tencentcloud/CubeSandbox/tree/master/examples/node-web-sandbox) | 基于 `cubesandbox-base` 构建 Node.js 20 Web 服务模板,通过兼容 E2B 的 SDK 拉起沙箱,并验证 envd 命令执行与暴露的 HTTP 端点。 |
| [OpenClaw 集成](https://github.com/tencentcloud/CubeSandbox/tree/master/examples/openclaw-integration) | 部署 Cube Sandbox 并配置 OpenClaw Skill,让 AI Agent 能够在隔离的虚拟机环境中执行代码。 |
| [SWE-bench + mini-swe-agent](https://github.com/tencentcloud/CubeSandbox/tree/master/examples/mini-rl-training) | 使用 cube-sandbox + mini-swe-agent 在隔离沙箱中自动化 SWE-bench 编码任务,支持多模型切换和 RL 训练愿景。 |
| [OpenAI Agents SDK 集成](https://github.com/tencentcloud/CubeSandbox/tree/master/examples/openai-agents-example) | 将 OpenAI Agents SDK 的 `E2BSandboxClient` 对接 Cube Sandbox。包含最小 Shell Agent(含 Pause/Resume 演示)以及完整的 SWE-bench Django 调试 Agent(流式输出 + 全链路追踪)。 |
Expand Down
11 changes: 11 additions & 0 deletions examples/node-web-sandbox/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
node_modules/
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.env
.env.*
__pycache__/
*.pyc
.venv/
venv/
.DS_Store
15 changes: 15 additions & 0 deletions examples/node-web-sandbox/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Cube Sandbox API endpoint.
E2B_API_URL=http://<cube-host>:3000

# Development deployments often accept the placeholder key below. Replace it
# when your CubeAPI deployment enforces authentication.
E2B_API_KEY=e2b_000000

# Fill this with the template ID returned by `cubemastercli tpl create-from-image`.
CUBE_TEMPLATE_ID=<template-id>

# Optional: path to a CubeSandbox CA bundle when your deployment uses mkcert.
# CUBE_SSL_CERT_FILE=/root/.local/share/mkcert/rootCA.pem

# Optional: public service port exposed by this example template.
NODE_WEB_PORT=3000
44 changes: 44 additions & 0 deletions examples/node-web-sandbox/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# syntax=docker/dockerfile:1.7
#
# CubeSandbox Node.js web development template example.
#
# Build locally:
# docker build -t cubesandbox-node-web:latest examples/node-web-sandbox
#
# Run locally:
# docker run --rm -p 3000:3000 -p 49983:49983 cubesandbox-node-web:latest
# curl http://127.0.0.1:3000/api/hello
# curl -o /dev/null -w "%{http_code}\n" http://127.0.0.1:49983/health

ARG CUBE_BASE_IMAGE=ghcr.io/tencentcloud/cubesandbox-base:2026.16

FROM ${CUBE_BASE_IMAGE}

ARG DEBIAN_FRONTEND=noninteractive
ARG NODE_MAJOR=20

RUN apt-get update \
&& apt-get install -y --no-install-recommends ca-certificates curl gnupg python3 \
&& curl -fsSL "https://deb.nodesource.com/setup_${NODE_MAJOR}.x" | bash - \
&& apt-get install -y --no-install-recommends nodejs \
&& rm -rf /var/lib/apt/lists/*

WORKDIR /workspace/node-web-sandbox
COPY package.json server.js smoke_test.py ./
COPY start-node-web-sandbox.sh /usr/local/bin/start-node-web-sandbox.sh
RUN chmod +x /usr/local/bin/start-node-web-sandbox.sh

ENV HOST=0.0.0.0
ENV PORT=3000
ENV ENVD_PORT=49983
ENV NODE_ENV=production

EXPOSE 3000 49983

HEALTHCHECK --interval=10s --timeout=3s --retries=5 \
CMD node -e "fetch('http://127.0.0.1:' + (process.env.PORT || 3000) + '/health').then(r => process.exit(r.ok ? 0 : 1)).catch(() => process.exit(1))"

# Start envd explicitly so the image also works when using CubeSandbox images
# that provide envd but do not define a Docker entrypoint.
ENTRYPOINT ["/usr/local/bin/start-node-web-sandbox.sh"]
CMD ["node", "server.js"]
Loading
Loading