mirror of
https://github.com/moby/buildkit.git
synced 2026-06-30 19:57:39 +00:00
dockerfile: support SOURCE_DATE_EPOCH=context
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>
This commit is contained in:
@@ -51,6 +51,13 @@ ARG SOURCE_DATE_EPOCH=1704067200
|
||||
FROM alpine
|
||||
```
|
||||
|
||||
The Dockerfile frontend also supports the special value `SOURCE_DATE_EPOCH=context`.
|
||||
This resolves the main build context to a numeric Unix timestamp before the build:
|
||||
|
||||
- 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
|
||||
|
||||
```console
|
||||
buildctl build --frontend dockerfile.v0 --opt build-arg:SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct) ...
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user