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

Migrate off of crane for pulling and pushing OCI images #3434

Open
AustinAbro321 opened this issue Jan 24, 2025 · 2 comments
Open

Migrate off of crane for pulling and pushing OCI images #3434

AustinAbro321 opened this issue Jan 24, 2025 · 2 comments
Assignees

Comments

@AustinAbro321
Copy link
Contributor

AustinAbro321 commented Jan 24, 2025

Describe what should be investigated or refactored

Crane has been an instrumental library to Zarf. It is responsible one of the most core features of our product, pulling and pushing images. However, we've had several issues while using crane. In particular, not accepting context, concurrent pulls and caching of non container OCI images tend to cause trouble. See:

Alternatives

We should consider alternatives to fix these issues, and open ourselves up to further improvements.

  • ORAS (OCI registry as storage) is a project that has become popular in the past few years or so. It is a go library for interacting with OCI registries. We use ORAS already to publish and pull Zarf packages.
  • https://github.com/containers/image - this is the library that skopeo uses for image pulls. I have not looked deeply into the code, but it is worth looking at how another successful tool with a similar mission does pulls and pushes

Additional context

Moving off Crane will present challenges. Crane also supports the oci-dir format, which syft uses to scan images local, this is how SBOMs are created during zarf package create. The Crane CLI is embedded directly into Zarf, removing it entirely will no doubt cause a breaking change in the workflow of some users. The Crane CLI has functionality to pull images from the local Docker daemon which would need replacement as well

@AustinAbro321
Copy link
Contributor Author

AustinAbro321 commented Jan 29, 2025

Both ORAS and https://github.com/containers/image seem to be reasonable alternatives to Crane. Both accept context, and seem to have more active contributions and updates. Both seem to be faster than crane, more official benchmarks to come. ORAS and "image" supports the same OCI format that Crane and Syft use. "image" supports pulling from the docker daemon while ORAS does not.

ORAS does allow embedding itself into other CLIs with Cobra easily. I am not sure what our appetite for breaking changes are, but it seems to me that it might make sense to deprecate zarf tools Crane and replace it with zarf tools oras. Crane and ORAS share much of the same functionality.

ORAS seems to at least protect the index.json while pulling concurrently, more experiments to come.

Both seem to have a cache, but further testing on these caches is required, the ORAS cache is not exported for example - oras-project/oras-go#881

@Silvanoc
Copy link

Silvanoc commented Feb 7, 2025

I would recommend you to look at regctl.

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

2 participants