Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PoC: Allow loading images by name from imagestore #2404

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

afbjorklund
Copy link
Contributor

@afbjorklund afbjorklund commented Jun 8, 2024

This allows you to have a template like:

images:
- ubuntu-24.04
mounts:
- location: "~"
- location: "/tmp/lima"
  writable: true

Loading from another document like:

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"

This makes it more similar to an OCI registry (or Vagrant), and allows for even using one (or IPFS) in the future.

Perhaps "images" isn't the best name, since unlike a vagrant box there are no images contained in the directory.

The current implementation is just using the yaml filename, rather than the "name" field in the document itself.

Closes #2418
Closes #2422

@afbjorklund
Copy link
Contributor Author

afbjorklund commented Jun 8, 2024

It would be possible to have both of them in the same yaml file, as separate documents. Like for "exporting"...

Then you would fill in the value of the current image name, with the location and digests of the current images.


image: ubuntu:24.04
mounts:
- location: "~"
- location: "/tmp/lima"
  writable: true
---
name: "ubuntu:24.04"
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"

Here the "image" and "name" are optional, since it is self-contained and only needs to be merged.

@afbjorklund afbjorklund force-pushed the imagestore branch 3 times, most recently from d8df170 to 1dca87f Compare June 8, 2024 13:25
@@ -19,6 +19,9 @@ os: null
# 🟢 Builtin default: "default" (corresponds to the host architecture)
arch: null

# Name of image to use.
image: ""
Copy link
Member

Choose a reason for hiding this comment

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

An alternative design to this PR would be to support extending YAML

e.g.

extend: "template://ubuntu"

I think there was a GitHub issue, but I can't find it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Another alternative is copy/paste, but they are both slightly more "technical"

You might also inherit more settings than just images, by including/extending?

@afbjorklund
Copy link
Contributor Author

afbjorklund commented Jun 10, 2024

The goal was to 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
FROM ubuntu:24.04

Should probably open a new ticket for discussion about that, old one was just "reuse"

EDIT: #2418

@afbjorklund afbjorklund force-pushed the imagestore branch 2 times, most recently from f8fdcf7 to 7019976 Compare June 12, 2024 18:40
@afbjorklund afbjorklund force-pushed the imagestore branch 2 times, most recently from 5cb9dbb to f2ef391 Compare June 13, 2024 07:18
@afbjorklund
Copy link
Contributor Author

afbjorklund commented Jun 16, 2024

Now allows using "default" instead of the default name (currently ubuntu-22.04)

Maybe something similar should be added for mounts, to get the default mounts?

# This template requires Lima v0.7.0 or later.
images:
- default

mounts:
- default
func defaultMounts() []Mount {
        return []Mount{
                {
                        Location: "~",
                        Writable: ptr.Of(false),
                },
                {
                        Location: "/tmp/lima",
                        Writable: ptr.Of(true),
                },
        }
}

https://github.com/lima-vm/lima/blob/master/examples/ubuntu.yaml

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants