lima icon indicating copy to clipboard operation
lima copied to clipboard

Simplify syntax for selecting images, with locations and digests

Open afbjorklund opened this issue 1 year ago • 5 comments

Description

Make the usage of Lima more similar to a Vagrantfile or a Dockerfile.

Vagrant.configure("2") do |config|
  config.vm.box = "cloud-image/ubuntu-24.04"
end

https://app.vagrantup.com/cloud-image

FROM ubuntu:24.04
# or, with a fully qualified registry
FROM docker.io/library/ubuntu:24.04

https://hub.docker.com/_/ubuntu

This by separating the usage of the images with the definition of the images.

templates/ubuntu.yaml

images:
- ubuntu-24.04

images/ubuntu-24.04.yaml

images:
# Try to use release-yyyyMMdd image if available. Note that release-yyyyMMdd will be removed after several months.
- location: "https://cloud-images.ubuntu.com/releases/24.04/release-20240423/ubuntu-24.04-server-cloudimg-amd64.img"
  arch: "x86_64"
  digest: "sha256:32a9d30d18803da72f5936cf2b7b9efcb4d0bb63c67933f17e3bdfd1751de3f3"
- location: "https://cloud-images.ubuntu.com/releases/24.04/release-20240423/ubuntu-24.04-server-cloudimg-arm64.img"
  arch: "aarch64"
  digest: "sha256:c841bac00925d3e6892d979798103a867931f255f28fefd9d5e07e3e22d0ef22"
# Fallback to the latest release image.
# Hint: run `limactl prune` to invalidate the cache
- location: "https://cloud-images.ubuntu.com/releases/24.04/release/ubuntu-24.04-server-cloudimg-amd64.img"
  arch: "x86_64"
- location: "https://cloud-images.ubuntu.com/releases/24.04/release/ubuntu-24.04-server-cloudimg-arm64.img"
  arch: "aarch64"

The image can be shared with multiple templates, reducing the need for copy/paste of details.

afbjorklund avatar Jun 12 '24 18:06 afbjorklund

The new limactl validate --fill will show a preview of the actual values.

afbjorklund avatar Jun 12 '24 18:06 afbjorklund

Alternatively one could use something longer like image://ubuntu-24.04

afbjorklund avatar Jun 14 '24 09:06 afbjorklund

Added default for the default image, for when you don't care about the OS

afbjorklund avatar Jun 16 '24 12:06 afbjorklund

Also good when adding more optional fields to images - like size and cid*

* see https://docs.ipfs.tech/concepts/content-addressing/ for CID information

Example entry:

- location: "https://cloud-images.ubuntu.com/releases/24.04/release-20240423/ubuntu-24.04-server-cloudimg-amd64.img"
  size: 475004928
  arch: "x86_64"
  digest: "sha256:32a9d30d18803da72f5936cf2b7b9efcb4d0bb63c67933f17e3bdfd1751de3f3"
  cid: "bafybeig5sch22ecfox7gq724rz7uivydwvnnpuqdcnjz72iwelgtrakzui"
  • #1586
  • #2407

afbjorklund avatar Jun 23 '24 07:06 afbjorklund

More architectures now in the default template, making "images" twice as long...

afbjorklund avatar Oct 20 '24 15:10 afbjorklund

This is now possible with the base feature:

base: template://images/ubuntu-24.04

This is something we could implement right away with Lima 1.1.0, if we wanted to.

I've also written a little bit about how we could eventually have a single template per distro, and select the release via a --param setting in https://github.com/lima-vm/lima/discussions/2520#discussioncomment-10193298.

But that is still some way off and will need further discussion and refinement before we can figure out if that is a good idea or not.

jandubois avatar Apr 20 '25 20:04 jandubois