-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
setting SOURCE_DATE_EPOCH
changes the created
metadata for base image layers (which are otherwise immutable 😅)
#4614
Comments
Our current logic is that timestamps for base/all layers are reset if they are newer than the epoch set by the build (as defined in As epoch works both on the exporter and frontend side, the other place for this is https://github.com/moby/buildkit/blob/master/frontend/dockerfile/dockerfile2llb/convert.go#L1874 . I'm not sure if there is possible to keep the frontend implementation if the logic would be different as once we get to buildkit/exporter/containerimage/writer.go Lines 694 to 700 in 5ac0a34
Never resetting timestamps for base image layers means that timestamps for these layers can be newer than the top layers of the image. Theoretically there can also be the case when the base image changes only in timestamp metadata and user may want to use epoch to still keep the build reproducible. I'm not sure how practical that case is though. Is this weird purely for visual inspection or does the timestamp there mess up some functional aspects as well? Thoughts? @AkihiroSuda @crazy-max @cpuguy83 |
This affects the functional ability to detect that an image has been rebuilt due to a base image update because all the timestamps are clamped to the |
(Ideally, in my |
We also have to ignore base images in buildkit/exporter/containerimage/writer.go Lines 383 to 412 in b09a9f1
|
Any thought on how to track the list of the base image blobs? |
Could we potentially have some sort of internal annotation that we could add to a descriptor when we pull it for an image in a Edit: wait, that's not going to work with cached operations 😢 |
@AkihiroSuda I noticed you added it to the milestone. Can this be assigned to you? |
Yes, but might need help for how to track the list of the base image blobs |
Two options for tracking the base image blobs:
The option 2 might be more robust but the current exporter isn't aware of the LLB graph, so the option 1 seems more straightforward. |
Simple illustration:
This surprised me because the design of container image layering is such that "base" layers are by-design immutable, but here we're mutating part of the metadata of them anyways. 😬
I originally had logic for setting
SOURCE_DATE_EPOCH
that would set it to the commit timestamp or the timestamp of the parent images, whichever is newer, but I ditched the latter half of that because it means the new layers generated in the build are potentially less reproducible than they would be otherwise (and I care a lot more about reproducible layers than I do reproducible images).See for example docker-library/golang#505 where we managed to make the "install Go" layer reproducible such that it should be identical no matter which OS / variant you download (ie, switching from
golang:alpine3.19
togolang:bookworm
orgolang:alpine3.18
shouldn't have to redownload the Go layer, or pulling a rebuilt image from a newer base image).I think this code is responsible for this behavior (specifically that it appears to loop over all of the
history
object, not just the "new" layers):buildkit/exporter/containerimage/writer.go
Lines 694 to 700 in 5ac0a34
It'd be great if this behavior could change to only touch the metadata on "new" layers instead (or at least have an option that allows for that behavior). 🙇 ❤️
The text was updated successfully, but these errors were encountered: