feat: implement reproducible build and get cached image#213
Conversation
This commit enables pushing the final image to the given cache repo.a As part of #185, the goal is to allow for faster startup when the image has already been built.
42b6121 to
d54ca81
Compare
| RunStderr: stderrWriter, | ||
| Destinations: []string{"local"}, | ||
| Destinations: destinations, | ||
| NoPush: !options.PushImage || len(destinations) == 0, |
There was a problem hiding this comment.
I'm assuming the reason for the logical disjuction here is that Kaniko will push all intermediate cache layers to destinations, while specifying options.PushImage signifies to push only the final result?
| }) | ||
|
|
||
| // For cached image utilization, produce reproducible builds. | ||
| Reproducible: options.PushImage, |
There was a problem hiding this comment.
Where is this getting used?
|
I'd love to try this in dogfood asap with our devcontainer! |
|
And since we added support for sysbox, this might just work! |
Samesies! Do you think we'd want a registry on each dogfood host or just one shared registry? |
|
I think we try using the Docker Registry to see what the performance looks like with a remote! |
| if options.CacheRepo == "" && options.PushImage { | ||
| return fmt.Errorf("--cache-repo must be set when using --push-image!") | ||
| } |
There was a problem hiding this comment.
review: I don't see any good reason to not do this. It prevents potential head-scratching if someone sets ENVBUILDER_PUSH_IMAGE without specifying ENVBUILDER_CACHE_REPO.
|
@dannykopping @BrunoQuaresma @mtojek I have updated this branch with integration tests. It's worth noting that |
mtojek
left a comment
There was a problem hiding this comment.
We agreed on DoCacheProbe in kaniko's PR, so this round is fairly quick. Approved 👍
| if options.CacheRepo == "" && options.PushImage { | ||
| return fmt.Errorf("--cache-repo must be set when using --push-image!") | ||
| } |
dannykopping
left a comment
There was a problem hiding this comment.
Only nits, great work!
| }) | ||
|
|
||
| t.Run("CacheAndPushMultistage", func(t *testing.T) { | ||
| // Currently fails with: |
There was a problem hiding this comment.
Is there a way we can make this fail more gracefully? This output is rather difficult to reason about.
There was a problem hiding this comment.
There probably is, but I'd say we should handle it as part of #230
Co-authored-by: Danny Kopping <dannykopping@gmail.com>
This PR is a PoC, it builds upon #197 and coder/kaniko#12 and shows how build cache + pushed image can be utilized.
Example get-cached-image:
Now, do build:
Try get-cached-image again:
And finally:
Closes #186.