Skip to content

Part 4: Update the Image

Install pnpm into the warm image:

src/Sandbox.ts
export const Warm = Modal.Image("Warm", {
app: Coder,
from: Node,
run: ["git clone --depth 1 https://github.com/sindresorhus/is /work"],
run: ["git clone --depth 1 https://github.com/sindresorhus/is /work", "npm install -g pnpm"],
});
Terminal window
pnpm alchemy deploy

run changed, so Modal builds a new image: it runs the commands again in a fresh sandbox and saves the result. The Worker is unchanged and isn’t redeployed.

Terminal window
curl -X POST "$URL/users/ada/run" -d 'pnpm --version'

A sandbox that’s already running keeps the image it booted from, until its command exits. Every sandbox started after the deploy boots from the new Warm, and mounts the same user volume, so Ada’s notes are still there, now next to pnpm.

Part 5 tests it.