1- // This example shows how to use Image mounts and directory snapshots in Sandboxes.
2- // First, we mount an empty image at a directory, clone a git repo into it, and
3- // take a snapshot. Then we create a new Sandbox and mount the snapshot, showing
4- // how you can persist and reuse directory state across Sandboxes.
1+ // This example shows how to mount Images in the Sandbox filesystem and take snapshots
2+ // of them.
3+ //
4+ // The feature is still experimental in the sense that the API is subject to change.
5+ //
6+ // High level, it allows you to:
7+ // - Mount any Modal Image at a specific directory within the Sandbox filesystem.
8+ // - Take a snapshot of that directory, which will create a new Modal Image with
9+ // the updated contents of the directory.
10+ //
11+ // You can only snapshot directories that have previously been mounted using
12+ // `Sandbox.experimentalMountImage`. If you want to mount an empty directory,
13+ // you can pass undefined as the image parameter.
14+ //
15+ // For exmaple, you can use this to mount user specific dependencies into a running
16+ // Sandbox, that is started with a base Image with shared system dependencies. This
17+ // way, you can update system dependencies and user projects independently.
518
619import { ModalClient } from "modal" ;
720
@@ -10,6 +23,7 @@ const modal = new ModalClient();
1023const app = await modal . apps . fromName ( "libmodal-example" , {
1124 createIfMissing : true ,
1225} ) ;
26+ // The base Image you use for the Sandbox must have a /usr/bin/mount binary.
1327const baseImage = modal . images . fromRegistry ( "debian:12-slim" ) ;
1428
1529const sb = await modal . sandboxes . create ( app , baseImage ) ;
0 commit comments