Skip to content

How to build the Mac VM image

Rebuild the image after changing deploy/vmimage/feature/ or anything build.sh stages into it: deploy/linux's units, egress.nft, the CNI conflist, or gVisor. Every step runs on an Apple-silicon Mac as you, never as root. Mac VM image describes what the image holds; deploy/vmimage/build.sh --help and check.sh --help describe the scripts.

Steps

  1. Bump IMAGE_REVISION in deploy/vmimage/build.sh. The runner pins the image by name and sha512, so every change needs a new revision.

  2. Remove the previous revision's files from dist/vmimage/. The check and cache recipes below want exactly one image there, and a build replaces only files of its own name.

  3. Build it:

    just vm-image
    

    The image, its sums and build.log land in dist/vmimage/.

  4. Boot it in a scratch VM and check it:

    just vm-image-check
    

    The check also measures the VM's idle footprint. A change must not raise it above the bar in Mac VM image; boot a few times, since footprints vary by about 20 MB between boots.

  5. Copy it into an installed runner's cache, which also prints its sha512. Until the image is published as a release asset, this is how a runner gets it.

    just vm-image-cache
    
  6. Pin the new image in internal/vmimage/vmimage.go: File, URL, SHA512, and stagedSources, the hashes of the files the build staged. A test fails while stagedSources doesn't match the repository. If the image has grown, check maxBytes, the most the runner will download, against the new size.

  7. Roll it out: the pin is compiled into the runner, so build it with just build-darwin and upgrade each Mac runner. Each one recreates its VM from the new image.

If a build fails while its VM is still running, just vm-image keeps the scratch Lima home and prints the commands to remove it.