Skip to content
Source
Sign inSign up
TanStack/ai
Open History to see the last commit

Dockerfile

40 lines2.2 KB

1# Container image for the Cloudflare sandbox that the agent run executes inside.
2#
3# It extends the official @cloudflare/sandbox base image (which ships the
4# in-container control server on port 3000 — exec/files/processes/ports — that
5# the SandboxHandle in @tanstack/ai-sandbox-cloudflare drives) and adds the
6# coding-agent CLIs so any harness this example supports can run.
7#
8# All three CLIs are baked in so the `HARNESS` var (see src/agent.ts) can select
9# one at run time without rebuilding the image. The unused CLIs just sit on disk.
11# Pin the base tag to the @cloudflare/sandbox version in package.json so the
12# control-server protocol matches the SDK the Worker is built against.
13FROM docker.io/cloudflare/sandbox:0.12.1
14​
15# Claude Code CLI (HARNESS=claude-code). `node` + `npm` are already on the base
16# image. `--include=optional` is required: the CLI's native binary ships as a
17# platform-specific OPTIONAL dependency, and a plain `-g` install can skip it,
18# leaving a `claude` that errors "native binary not installed".
19RUN npm install -g @anthropic-ai/claude-code --include=optional && claude --version
20​
21# OpenAI Codex CLI (HARNESS=codex). `--include=optional` for the same reason —
22# codex's native binary is a platform-specific optional dep.
23RUN npm install -g @openai/codex --include=optional && codex --version
24​
25# Grok Build CLI (HARNESS=grok) — installed as documented at https://x.ai/cli.
26# The installer drops the binary at /root/.grok/bin/grok; symlink it onto PATH so
27# the harness adapter (which invokes `grok`) resolves it.
28RUN curl -fsSL https://x.ai/cli/install.sh | bash \
29 && ln -sf /root/.grok/bin/grok /usr/local/bin/grok \
30 && grok --version || true
31​
32# NOTE: the Cloudflare sandbox has no writable host→process stdin
33# (`capabilities.writableStdin: false`). Each harness adapter detects this and
34# feeds the prompt via a file + in-shell stdin-redirection (e.g.
35# `claude -p … < file`, `codex exec … < file`) instead of a host stdin write, so
36# every harness runs here unchanged. See
37# packages/ai-sandbox-cloudflare/src/handle.ts and the README "Limitations".
38​
39# The base image already EXPOSEs 3000 and sets the sandbox ENTRYPOINT; we only
40# layer tools on top, so no CMD/ENTRYPOINT override is needed.