Skip to content

Part 4: Update the Template

Install pnpm in the template:

src/Sandbox.ts
export const MyTemplate = E2B.Template("MyTemplate", {
dockerfile: Dockerfile.inline`
FROM node:22-bookworm
RUN apt-get update && apt-get install -y git
RUN npm install -g pnpm
`,
cpuCount: 2,
memoryMB: 2048,
});
Terminal window
pnpm alchemy deploy

The Dockerfile changed, so E2B builds MyTemplate again. Warm starts from MyTemplate, so Alchemy snapshots it again on the new build, and clones the repository into it. The Worker is unchanged and isn’t redeployed.

Terminal window
curl -X POST "$URL/run" --data 'pnpm --version'

Running sandboxes keep what they started with

Section titled “Running sandboxes keep what they started with”

A sandbox keeps the snapshot it booted from. Users whose sandbox is paused keep it, with their changes and without pnpm. Sandboxes started after the deploy get the new base. To move a user onto it, kill their sandbox; their next request starts a new one from Warm.

Part 5 tests it.