Repository navigation
source: add git.mtime attr for commit-time mtimes - #6600
Merged
Merged
Conversation
Add git.mtime=commit option that normalizes all file, symlink, and directory mtimes in a git snapshot to the resolved commit timestamp. This enables reproducible builds from git sources. When SOURCE_DATE_EPOCH is set in the Dockerfile frontend, the git context automatically uses commit-time mtimes. The URL query parameter ?mtime=commit|checkout can override this. New LLB attr (git.mtime) and capability (source.git.mtime) are registered as experimental. Cache keys include the mtime policy so that commit-time and checkout-time snapshots are distinct. Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
jsternberg
approved these changes
Mar 25, 2026
Comment on lines
+60
to
+61
| // MTime controls file modification time policy: "checkout" (default) or "commit". | ||
| MTime string |
Collaborator
There was a problem hiding this comment.
Can you add some constants for the various states here? I think it's better if they're unexported constants but they seem to be used frequently enough that I think constants would be helpful to prevent accidental mistypes.
Member
Author
There was a problem hiding this comment.
Looked into this but it doesn't look like it would help much. This is dfgitutil and there is only one usage of it. Then there is GitIdentifier in the solver that is created from proto attributes. So they are two distinct types (with the proto attr doing the conversion) and I don't really want to make them depend on each other.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add git.mtime=commit option that normalizes all file, symlink, and directory mtimes in a git snapshot to the resolved commit timestamp. This enables reproducible builds from git sources.
When SOURCE_DATE_EPOCH is set in the Dockerfile frontend, the git context automatically uses commit-time mtimes. The URL query parameter ?mtime=commit|checkout can override this.
New LLB attr (git.mtime) and capability (source.git.mtime) are registered as experimental. Cache keys include the mtime policy so that commit-time and checkout-time snapshots are distinct.