Skip to content

Conversation

@ghostwriternr
Copy link
Member

@ghostwriternr ghostwriternr commented Dec 5, 2025

Compiles sandbox-container to a self-contained binary at /container-server/sandbox that can be copied into any Docker image.

Fixes #269

Usage:

FROM your-image:tag

COPY --from=cloudflare/sandbox:VERSION /container-server/sandbox /sandbox
ENTRYPOINT ["/sandbox"]

# Optional: run your own startup command
CMD ["/your-entrypoint.sh"]

Alternative binary access:

# From GitHub release
curl -fsSL https://github.com/cloudflare/sandbox-sdk/releases/download/%40cloudflare%2Fsandbox%40VERSION/sandbox-linux-x64 -o sandbox

# From Docker image
docker run --rm cloudflare/sandbox:VERSION cat /container-server/sandbox > sandbox && chmod +x sandbox

# From PR artifact (for testing)
gh run download <run-id> -n sandbox-binary

Changes:

  • Build standalone binary via bun build --compile
  • Refactor entrypoint to support CMD passthrough with signal forwarding
  • Add backwards compatibility for existing startup scripts
  • Upload binary to GitHub releases and PR artifacts
  • Enhanced PR preview comments with binary access instructions

Compiles sandbox-container to a self-contained binary at /sandbox that
can be copied into any Docker image. Includes backwards compatibility
for existing startup scripts via legacy JS bundle.
@changeset-bot
Copy link

changeset-bot bot commented Dec 5, 2025

🦋 Changeset detected

Latest commit: ef9e2ac

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@cloudflare/sandbox Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

agents-git-bot bot pushed a commit to cloudflare/cloudflare-docs that referenced this pull request Dec 5, 2025
Documents the new standalone binary feature that allows users to add
sandbox capabilities to any Docker image by copying the /sandbox binary.

Updates include:
- New section on using standalone binary with arbitrary base images
- Examples for Python, Node.js, and Go base images
- Explanation of how the binary works with signal forwarding
- Mark existing startup script pattern as legacy for backwards compatibility
- Update multiple services example to work with new binary

Related to cloudflare/sandbox-sdk#280

🤖 Generated with Claude Code

Co-Authored-By: Claude <[email protected]>
@pkg-pr-new
Copy link

pkg-pr-new bot commented Dec 5, 2025

Open in StackBlitz

npm i https://pkg.pr.new/cloudflare/sandbox-sdk/@cloudflare/sandbox@280

commit: ef9e2ac

@github-actions
Copy link
Contributor

github-actions bot commented Dec 5, 2025

🐳 Docker Images Published

Default:

FROM cloudflare/sandbox:0.0.0-pr-280-916fff2

With Python:

FROM cloudflare/sandbox:0.0.0-pr-280-916fff2-python

With OpenCode:

FROM cloudflare/sandbox:0.0.0-pr-280-916fff2-opencode

Version: 0.0.0-pr-280-916fff2

Use the -python variant if you need Python code execution, or -opencode for the variant with OpenCode AI coding agent pre-installed.


📦 Standalone Binary

For arbitrary Dockerfiles:

COPY --from=cloudflare/sandbox:0.0.0-pr-280-916fff2 /container-server/sandbox /sandbox
ENTRYPOINT ["/sandbox"]

Download via GitHub CLI:

gh run download 20118882350 -n sandbox-binary

Extract from Docker:

docker run --rm cloudflare/sandbox:0.0.0-pr-280-916fff2 cat /container-server/sandbox > sandbox && chmod +x sandbox

claude[bot]

This comment was marked as outdated.

claude[bot]

This comment was marked as outdated.

agents-git-bot bot pushed a commit to cloudflare/cloudflare-docs that referenced this pull request Dec 10, 2025
Documents the new /sandbox binary that enables adding sandbox capabilities
to any Docker image without extending the Cloudflare base image. Includes:

- Basic usage with COPY --from pattern
- CMD passthrough with signal forwarding
- Three methods to access the binary (Docker COPY, GitHub releases, docker extract)
- Guidance on when to use standalone binary vs base image
- Updated custom startup scripts to use new recommended approach
- Backwards compatibility notes for existing users

Updates websocket-connections guide to use new CMD-based startup approach
instead of legacy exec bun pattern.

Related to cloudflare/sandbox-sdk#280

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Signal handlers are now registered before spawning the child process
to close a race window. Exit codes use os.constants.signals for correct
Unix convention mapping. Server cleanup is returned from startServer()
rather than relying on module-level state, making the dependency between
server startup and shutdown handlers explicit.
The standalone binary compiled on glibc won't run on Alpine (musl).
Using node:20-slim and oven/bun:1 ensures the binary works on
standard Linux distributions like Debian, Ubuntu, and RHEL.
Tests that the sandbox binary works when copied into arbitrary Docker
images. Validates command execution, file operations with MIME type
detection, and CMD passthrough to user startup scripts.
Documents how to add sandbox capabilities to arbitrary Docker images
by copying the /sandbox binary. Lists required dependencies (file,
git) and what works without extra packages.
claude[bot]

This comment was marked as outdated.

Document the supervisor lifecycle model for standalone binary users.
Add SHA256 checksum generation for binary releases.
claude[bot]

This comment was marked as outdated.

@ghostwriternr ghostwriternr merged commit 5d87b35 into main Dec 11, 2025
16 checks passed
@ghostwriternr ghostwriternr deleted the base-image branch December 11, 2025 01:47
@github-actions github-actions bot mentioned this pull request Dec 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support bundling our control plane into any docker image, instead of needing to extend our base

1 participant