How to safely run dynamic, untrusted, or AI-generated code against repository content?. Whether it’s an LLM suggesting a quick data-extraction script, or a user-uploaded rule that needs to analyze a document, the question is the same.
Traditionally, Docker has been the go-to answer: build a container, mount content, run the task. It works, but it’s heavy for small, short-lived executions. That’s where E2B (Engine-to-Box) comes in.
E2B provides ephemeral sandboxes: lightweight, cloud-isolated environments that spin up in seconds, execute arbitrary code securely, and shut down immediately.
They’re based on Firecracker microVMs, the same ultra-fast virtualization layer used by AWS Lambda, giving developers a way to run any code safely and with almost zero startup delay.
In practice, an E2B sandbox is:
The alfresco-e2b-minimal demo shows the concept in action. It’s a Node.js app that connects to an Alfresco repository, downloads a document, and uses E2B to analyze it without any code ever touching your host.
E2B provides also a Python SDK in addition to the JavaScript SDK used for this sample project. Additional details can be found in the E2B Documentation page. You may also want to take a look at the MCP Gateway provided by the platform.
1. Authenticate to Alfresco
Using a ticket or bearer token, the app connects to the Alfresco REST API
2. Download the target document
The file is fetched from the repository by its "nodeId"
3. Create a new E2B sandbox
Through the E2B TypeScript SDK, it requests an ephemeral Firecracker VM
4. Transfer inputs and script
The document content and a Python file ("scripts/basic_stats.py") are copied into the sandbox
5. Execute analysis inside the sandbox
The script runs remotely. It simply counts bytes, words, and lines in the file as a sample logic
6. Upload results back to Alfresco
When the Python process finishes, the host app retrieves the JSON result and creates a new node in the specified target folder, setting fields such as "cm:title", "cm:description", and "cm:author"
Once configured, you only need:
cp .env.example .env
# fill ALFRESCO_BASE_URL, TARGET_FOLDER_ID, E2B_API_KEY, NODE_ID
docker compose up --build
Expected output:
✓ Analysis uploaded.
Source node: 3d0014d0-6232-4af1-8014-d062327af1c5
Result node: f6b01cfb-492c-4576-b01c-fb492c1576b1
In Alfresco, a JSON file appears alongside your document, containing:
{
"bytes": 13452,
"words": 2164,
"lines": 238
}
Every execution happens within a fresh E2B sandbox, fully isolated, disposable, and never carrying Alfresco credentials.
You can replace "scripts/basic_stats.py" with any Python logic:
All that’s required is to read from "INPUT_PATH" and write JSON to "OUTPUT_PATH"
E2B isolates dependencies and execution, while the host app remains responsible for repository access and metadata updates
The Alfresco-E2B minimal project demonstrates how ephemeral compute can extend your content platform securely.
Instead of asking "can I trust this code?", you can now run it: safely, in isolation, and automatically cleaned up.
Docker provides your stable foundation, while E2B adds a disposable, serverless-like execution layer ideal for experimentation, automation, and AI-driven extensions.
Because sometimes the safest code execution is the one that disappears right after it runs
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.