Skip to content

build/bake: support reproducible timestamps with source-date-epoch - #338

Merged
tonistiigi merged 1 commit into
docker:mainfrom
crazy-max:source-date-epoch
Nov 17, 2026
Merged

tonistiigi merged 1 commit into
docker:mainfrom
crazy-max:source-date-epoch

Conversation

@crazy-max

Copy link
Copy Markdown
Member

fixes #307

Add an optional source-date-epoch input to both workflows to align build output and generated metadata timestamps. It accepts a non-negative Unix timestamp, including zero, or commit to use the event commit's committer time without a checkout. Image exports enable timestamp rewriting for layer contents, while local exports use BuildKit's built-in timestamp handling. Leaving the input empty preserves existing behavior.

Provenance still contains execution-specific data, so final image index digests can differ even when image contents are reproducible.

@crazy-max
crazy-max requested a review from tonistiigi November 5, 2026 13:51
@crazy-max
crazy-max requested a review from a team as a code owner November 5, 2026 13:51
@crazy-max
crazy-max force-pushed the source-date-epoch branch 2 times, most recently from b71c540 to cf3e239 Compare November 5, 2026 15:24

@tonistiigi tonistiigi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we default to commit in next major release?

Comment thread .github/workflows/build.yml Outdated

const inpSourceDateEpoch = core.getInput('source-date-epoch');
if (inpSourceDateEpoch !== '') {
core.exportVariable('SOURCE_DATE_EPOCH', inpSourceDateEpoch);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this env do, especially because we are setting BUILDX_BAKE_DISABLE_VARS_ENV_LOOKUP.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes this was an oversight after switching to local vars

file: test/source-date-epoch.Dockerfile
build-args: |
SOURCE_DATE_EPOCH=1
EXPECTED_EPOCH=${{ matrix.epoch }}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we test something that relies on rewrite-timestamps?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
@tonistiigi
tonistiigi merged commit 02ccc51 into docker:main Nov 17, 2026
456 checks passed
@crazy-max
crazy-max deleted the source-date-epoch branch November 17, 2026 18:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support reproducible builds with SOURCE_DATE_EPOCH

2 participants