-
Notifications
You must be signed in to change notification settings - Fork 43
feat: implement reproducible build and get cached image #213
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
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
// Boilerplate! | ||
CustomPlatform: platforms.Format(platforms.Normalize(platforms.DefaultSpec())), | ||
SnapshotMode: "redo", | ||
RunV2: true, | ||
RunStdout: stdoutWriter, | ||
RunStderr: stderrWriter, | ||
Destinations: []string{"local"}, | ||
Destinations: destinations, | ||
NoPush: !options.PushImage || len(destinations) == 0, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep 👍🏻
}) | ||
|
||
// For cached image utilization, produce reproducible builds. | ||
Reproducible: options.PushImage, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is this getting used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See coder/kaniko#12
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! |
envbuilder.go
Outdated
if options.CacheRepo == "" && options.PushImage { | ||
return fmt.Errorf("--cache-repo must be set when using --push-image!") | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dry run maybe?
@dannykopping @BrunoQuaresma @mtojek I have updated this branch with integration tests. It's worth noting that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We agreed on DoCacheProbe
in kaniko's PR, so this round is fairly quick. Approved 👍
envbuilder.go
Outdated
if options.CacheRepo == "" && options.PushImage { | ||
return fmt.Errorf("--cache-repo must be set when using --push-image!") | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dry run maybe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only nits, great work!
}) | ||
|
||
t.Run("CacheAndPushMultistage", func(t *testing.T) { | ||
// Currently fails with: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There probably is, but I'd say we should handle it as part of #230
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.