dockerfile: support SOURCE_DATE_EPOCH=context #6602
Open
tonistiigi wants to merge 2 commits intomoby:masterfrom
Open
dockerfile: support SOURCE_DATE_EPOCH=context #6602tonistiigi wants to merge 2 commits intomoby:masterfrom
tonistiigi wants to merge 2 commits intomoby:masterfrom
Conversation
2b02a55 to
e962223
Compare
e962223 to
347b6f9
Compare
Member
Author
|
Added another commit to also support I'm not sure if we should take this into v0.29 . It's turned out to be a big PR and I don't want to force it close to the release window if anyone still wants to discuss. |
859c244 to
872bd6b
Compare
AkihiroSuda
reviewed
Mar 31, 2026
|
|
||
| - git context: commit time | ||
| - HTTP context: `Last-Modified`, or the newest archive entry mtime when building from an archive without `Last-Modified` | ||
| - local context: ignored, leaving `SOURCE_DATE_EPOCH` unset |
Member
There was a problem hiding this comment.
Any reason not to use mtime of the context dir?
Member
Author
There was a problem hiding this comment.
I don't think the local context files will ever have a stable meaningful mtime. Also question would be how many files we need to transfer to establish that? Git and HTTP are complete sources with immutable metadata, while local dirs are files pulled based on the ADD/COPY commands.
AkihiroSuda
approved these changes
Mar 31, 2026
Resolve SOURCE_DATE_EPOCH=context in the Dockerfile frontend from the main build context and pass the resolved numeric epoch through normal ARG handling and exporter metadata. Use git commit time for git contexts, HTTP Last-Modified when present, and newest archive entry mtime for HTTP archives. Leave local contexts unset. Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
Extend SOURCE_DATE_EPOCH resolution to accept a stage name
or named context in addition to numeric and "context" values.
A referenced stage must be FROM scratch with a single remote
ADD (HTTP or Git), from which the epoch timestamp is derived.
Refactor resolution logic from dockerui/context.go into a
dedicated epoch.go file. Remove buildContext fields that were
only needed for epoch resolution and expose GatewayClient()
on dockerui.Client for direct source metadata access.
Also align HTTP named context to use Filename("context"),
matching the existing DetectHTTPContext behavior.
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
872bd6b to
c126a86
Compare
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.
Resolve SOURCE_DATE_EPOCH=context in the Dockerfile frontend from the
main build context and pass the resolved numeric epoch through normal
ARG handling and exporter metadata.
Use git commit time for git contexts, HTTP Last-Modified when present,
and newest archive entry mtime for HTTP archives. Leave local contexts
unset.
depends on #6601