E2B Sandboxes
E2B provides hosted Linux sandboxes created from templates. Struo runs each uncached action in a fresh E2B sandbox and deletes it afterwards.
Struo transfers declared inputs, runs the command, retrieves declared outputs, and deletes the sandbox.
Capabilities#
| Capability | Support |
|---|---|
| Shared cache | No; use a cache provider |
| Remote execution | Hosted sandboxes from a template |
| Artifact publication | No |
| Project setup | Manual configuration |
| Authentication | E2B_API_KEY |
Prerequisites#
- An E2B account and API key.
- An E2B template containing the stable tools
shared by your actions. A Vitest template should provide Node.js, npm, and
tar. Keep repository dependencies such asnode_modulesin the action graph instead of baking them into the template.
Configuration#
Add the template name or identifier to the repository root struo.toml:
[infrastructures.remote_tests]
kind = "e2b"
template = "vitest-node-22"
[infrastructure.execution]
provider = "remote_tests"Pin the template contents so two executions with the same action identity see the same tools.
Authentication#
Set the provider access key outside the script:
export E2B_API_KEY=e2b_...STRUO_E2B_API_KEY takes precedence when both variables are present. Struo
does not forward the key to the action process.
Self-hosted or test endpoints can override the control and sandbox addresses
with STRUO_E2B_API_URL and STRUO_E2B_SANDBOX_URL.
Usage#
Run a literal command on the provider:
struo exec --remote --compute remote_tests -- node --versionOmit --compute remote_tests to use the workspace's default execution provider.
Run an annotated test script#
Save this script as scripts/test.sh:
#!/bin/sh
# struo remote "remote_tests"
# struo cwd ".."
# struo input "../node_modules"
# struo input "../package.json"
# struo input "../tests"
# struo output "../reports"
node node_modules/vitest/vitest.mjs run \
--reporter=json --outputFile=reports/vitest.jsonRun it:
struo exec --script -- sh scripts/test.shDeclare any additional source, configuration, or setup files your tests read.
Native dependencies must match the guest's Linux architecture and runtime. To
produce node_modules in a separate cacheable action, see
Remote Execution.
Limits and cleanup#
- Sandboxes have outbound network access, so an installation action can download packages. Declare downloaded dependencies as outputs so later actions receive them explicitly.
- Each sandbox has a finite lifetime and is killed when it times out.
Struo sends an explicit delete request after success, command failure, timeout, or transfer failure. The finite lifetime removes the sandbox if the client disappears first. E2B explains the difference between killed and paused sandboxes in its persistence guide.
Next steps#
- Remote Execution: split dependency installation and tests into separate cacheable actions.
- Infrastructure: pick a cache provider so other machines reuse remote results.
- Execution provider contract: see what every execution provider guarantees.