Cloudflare
Sandboxes on Cloudflare Containers, in your own Cloudflare account.
Cloudflare has no API key that starts sandboxes: a sandbox belongs to a Worker. So you deploy Boxport's sandbox Worker to your Cloudflare account once and give Boxport its URL and a secret. Sandboxes then run and bill on your account. Containers need the Workers Paid plan.
1. Deploy the sandbox Worker#
mkdir boxport-sandbox && cd boxport-sandbox
curl -O https://boxport.dev/cloudflare/worker.ts -O https://boxport.dev/cloudflare/wrangler.jsonc
npx wrangler deploy
npx wrangler secret put BOXPORT_SECRET
For the secret, paste a long random string, such as the output of node -e "console.log(crypto.randomUUID())". Wrangler prints the Worker's URL, such as https://boxport-sandbox.you.workers.dev. The Worker is one file with no dependencies; read it before you deploy.
2. Add the key#
The key is the URL, a colon and the secret:
curl -X PUT https://boxport.dev/v1/providers/cloudflare/key -H "Authorization: Bearer $BOXPORT_KEY" \
-d '{"apiKey":"https://boxport-sandbox.you.workers.dev:YOUR_SECRET"}'
Saving it calls the Worker once to check the secret.
What a sandbox is#
- A Durable Object that starts a container from Cloudflare's Debian image with Node.js 24 (
cloudflare/debian-trixie), with Internet access. The image has nocurlorpython3; install what you need withapt-getin a template's setup. - Its size is the vCPU and memory you ask for, up to 4 vCPU and 12 GiB, with 2 GB of disk per GiB of memory (from 2 to 20 GB).
- It stops after 10 minutes with no call from Boxport. Commands still running inside don't count as calls. Each command can run for up to 5 minutes.
expose_portreturns a URL on the Worker's hostname with a token in it. Anyone with the URL can reach the port. The server gets each path without the/p/…prefix, so pages need relative links. Servers must listen on0.0.0.0.
Templates and images#
A template with setup runs it on a builder sandbox, then saves the filesystem as a container snapshot, which is in public beta at Cloudflare. Cloudflare deletes a snapshot 30 days after it was made or last used. After that a create fails with a message to build the template again.
The image of a template is default, or the name of an image you add to the Worker's wrangler.jsonc:
"images": { "python": { "dockerfile": "./python.Dockerfile" } }
Wrangler builds the Dockerfile when you deploy, which needs Docker on your machine. A template with "image":"python" then starts from it. Other image references fail the build on Cloudflare with the list of names the Worker has.
Cost#
Cloudflare bills CPU while it is busy ($0.072 per vCPU-hour) and memory and disk while the sandbox runs ($0.009 per GiB-hour and $0.000252 per GB-hour). Boxport's estimates use those rates. They leave out the usage the Workers Paid plan includes each month, the Worker's own requests and egress.
Updating#
Download the two files again and run npx wrangler deploy. A sandbox that is running keeps the version it started with until it stops.