Part 4: Update the Template
Add a tool to the image
Section titled “Add a tool to the image”Install pnpm in the template:
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,});Deploy the new base
Section titled “Deploy the new base”pnpm alchemy deploybun alchemy deploynpx alchemy deployyarn alchemy deployThe 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.
curl -X POST "$URL/run" --data 'pnpm --version'curl -X POST "$URL/run" --data 'pnpm --version'curl -X POST "$URL/run" --data 'pnpm --version'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.