Skip to content

sandbox: dynamic directory mount & snapshot - Go#243

Open
ehdr wants to merge 3 commits intoehdr/sb-command-router-gofrom
ehdr/sb-image-mount
Open

sandbox: dynamic directory mount & snapshot - Go#243
ehdr wants to merge 3 commits intoehdr/sb-command-router-gofrom
ehdr/sb-image-mount

Conversation

@ehdr
Copy link
Contributor

@ehdr ehdr commented Dec 23, 2025

Port of a2d11ac and thus modal-labs/modal-client#3791.


Note

Adds experimental sandbox directory mount/snapshot in Go

  • Introduces Sandbox.ExperimentalMountImage(path, image) and Sandbox.ExperimentalSnapshotDirectory(path) in modal-go/sandbox.go, wired through the command router
  • New Go example examples/sandbox-image-mount demonstrating mounting a repo dir, cloning, snapshotting, and remounting
  • Updates JS example sandbox-image-mount.ts to install git in base image and show mount/snapshot usage
  • Adds tests covering empty mount, mount with snapshot image, directory snapshot, and error on unbuilt image
  • Updates CHANGELOG.md to note experimental support for single-directory snapshot and image mount

Written by Cursor Bugbot for commit 4337fc6. This will update automatically on new commits. Configure here.

Copy link
Contributor

@thomasjpfan thomasjpfan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor nits, otherwise LGTM

Comment on lines 833 to 841

if image != nil && image.ImageID == "" {
return InvalidError{Exception: "Image must be built before mounting. Call `image.Build(app)` first."}
}

imageID := ""
if image != nil {
imageID = image.ImageID
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit:

imageId := ""
if image != nil {
    if image.ImageID == "" {
         return InvalidError{...}
    }
    imageId = image.ImageID
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed!

_, err = echoProc.Wait(ctx)
g.Expect(err).ShouldNot(gomega.HaveOccurred())

mountImage, err := sb1.SnapshotFilesystem(ctx, 55*time.Second)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we going to advertise that you can snapshot the whole filesystem and then mounting it into /mnt/data in another sandbox?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I think it's alright? Used it mostly as a convenient way to make an image not from a directory snapshot. But this test perhaps doesn't add much in addition to the next one, so could skip it entirely I suppose.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's okay to test as long as this is a supported feature.

@ehdr ehdr force-pushed the ehdr/sb-command-router-go branch 3 times, most recently from edbb15d to ac41d27 Compare December 26, 2025 12:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants