Skip to content

Conversation

@deitch
Copy link
Collaborator

@deitch deitch commented Jul 27, 2025

…kit never gets them over the network

- What I did
When you run lkt pkg build, it an image from a FROM line in the Dockerfile already is in the cache, then lkt points buildkit to the local copy, rather than having it pull from the remote. This has existed for a long time, to serve two purposes:

  1. The ability to chain builds locally. E.g. I build one image, and then use it for another, when the first has not been pushed to a remote registry.
  2. Saving remote pulls if you repeatedly build a local image.

In addition, you always could do lkt cache pull to pull an image, if you wanted. If you did that before pkg build, then a referenced image would be read from local cache.

This PR combines those two.

When lkt pkg build parses a Dockerfile right before passing it to buildkit, if it finds a reference that is not in the local cache, and the new --pre-cache-images option is set, then lkt will pull down the image to local cache. This means a larger cache, but more importantly, it means that buildkit always will read images just from local cache.

This can have an impact on network and registry usage. But it also lets you configure mirrors and such (see #4148) through the lkt client, without needing to configure buildkit specially.

- How I did it

  • added a CLI flag to pkg build
  • added cache pulling when needed

- How to verify it
CI

- Description for the changelog

support for pre-caching images before pkg build

…it never gets them over the network

Signed-off-by: Avi Deitcher <[email protected]>
@deitch deitch merged commit 1d3a823 into linuxkit:master Jul 27, 2025
22 checks passed
@deitch deitch deleted the pkg-build-precache branch July 27, 2025 16:07
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

Successfully merging this pull request may close these issues.

1 participant