When to use this recipe
- A personal cloud dev environment for prototyping, demos, or pair work.
- A coding playground backend where each user gets a persistent workspace tied to their account.
- A shared environment a team can attach to in rotation, taking turns with the same files.
- An always-available CI-like environment without the cost of always-on compute.
Prerequisites
- A Brimble account with sandbox access (paid plan).
- The SDK installed and
BRIMBLE_SANDBOX_KEYset. - Persistent volumes available on your plan (10 to 50 GB depending on tier).
Recipe
The pattern has three phases: first run (create the volume + sandbox together), pause (when you step away), and resume (pick back up later). The volume is the source of truth; sandboxes come and go in front of it.Phase 1: first run
withVolume provisions the volume and the sandbox in one call. Save the IDs locally (a config file, an env var, a row in your database) so you can find them later.
Phase 2: pause when you step away
Use the cached handle from your script (or fetch it viaclient.sandboxes.use(savedSandboxId)). Pause stops the container, releases CPU and memory billing, and keeps the volume attached.
Phase 3: resume later
Resume kicks off a fresh container backed by the same volume. Your files are right where you left them.If the sandbox is gone but the volume isn’t
If the sandbox hit max-lifetime and was destroyed, the volume is still there, detached, not deleted. Spin up a new sandbox and attach the same volume:What’s happening
withVolumeon first run. One call, one round-trip, creates both the volume and the sandbox. Atomic on the platform side.autoDestroy: false. We’re explicit: don’t terminate this sandbox on a timer. The whole point is a long-lived environment.- Pause when idle.
handle.pause()stops the container but keeps the volume attached. Billing for CPU and memory stops; you only pay for the volume’s storage. - Resume into a fresh container.
getReadyreturns a hot handle. The container is new but the volume is the same, so your files are intact. - Volume outlives the sandbox. If the platform terminates the sandbox for any reason (max-lifetime, host failure, manual destroy), the volume is detached but not deleted. Look it up by name and reattach to a new sandbox.
Variations
- Daily automatic snapshots. Pass
snapshotMode: "automatic"andsnapshotFrequency: "0 4 * * *"(daily at 4am) when creating the sandbox. If the volume is ever unrecoverable, restore from the most recent snapshot. - Shared team workspace. Multiple users can attach the same volume in turn (one at a time). When you’re done, destroy the sandbox; a teammate creates a fresh sandbox with the same
volumeIdand picks up exactly where you left off. - Per-user playgrounds. In a multi-tenant product, give each user their own named volume. Look it up on demand and attach a fresh sandbox; users get instant access to their environment without you maintaining always-on compute.
- Schedule auto-pause. No first-class idle pause yet. Run a cron-like job that calls
pauseafter N minutes of no activity, andresumewhen the user reconnects. - Multiple sandboxes off one volume over time. Detach, reattach, repeat. The volume is the long-lived artifact; sandboxes are the cheap, ephemeral wrapper.
Next steps
- Volumes, the full attach model and limits.
- Snapshots, snapshot the volume’s contents for backups or hand-offs.
- Sandboxes overview, lifecycle, sizing, billing.