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

Automating the root filesystem creation #3

Open
bxffour opened this issue Jul 27, 2023 · 1 comment
Open

Automating the root filesystem creation #3

bxffour opened this issue Jul 27, 2023 · 1 comment

Comments

@bxffour
Copy link
Collaborator

bxffour commented Jul 27, 2023

So, I have started looking into how we can automate the root filesystem creation and as of now I am going through the go-containerregistry to see how we go about it. But right now, these are the features we should be looking to implement:

  1. Pulling the image layers
  2. Unpacking the image layers
  3. Caching container images just so we don't pull images unnecessarily
@bxffour
Copy link
Collaborator Author

bxffour commented Jul 27, 2023

Can you try this out to see how caching works @Joe-Degs

package main

import (
	"log"
	"strings"

	"github.com/google/go-containerregistry/pkg/crane"
	"github.com/google/go-containerregistry/pkg/v1/cache"
)

func main() {
	img, err := crane.Pull("alpine:latest")
	if err != nil {
		log.Fatal(err)
	}

	ca := cache.NewFilesystemCache("./save/")

	cimg := cache.Image(img, ca)

	digest, _ := cimg.Digest()
	ds := strings.Split(digest.String(), ":")

	if err := crane.Save(cimg, "latest", ds[1]); err != nil {
		log.Fatal(err)
	}
}

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

No branches or pull requests

1 participant