Skip to content

feat!: build reproducible images with SOURCE_DATE_EPOCH from the commit time - #88

Draft
Ilyes512 wants to merge 1 commit into
4.0/docsfrom
4.0/reproducible
Draft

Ilyes512 wants to merge 1 commit into
4.0/docsfrom
4.0/reproducible

Conversation

@Ilyes512

@Ilyes512 Ilyes512 commented Nov 9, 2026 •

Copy link
Copy Markdown
Member

Follows https://docs.docker.com/build/ci/github-actions/reproducible-builds/ and BuildKit's docs/build-repro.md.

  • plan reads SOURCE_DATE_EPOCH with git log -1 --pretty=%ct, once. Bake carries it into every target's args, so it is frozen in the definition and every platform builds with the same value. BuildKit uses it for created in the image config and its history.
  • build writes images with rewrite-timestamp=true. Without it, files created by RUN keep the build's own time and the layer digests change on every build. SOURCE_DATE_EPOCH alone isn't enough.
  • CREATED (and with it the org.opencontainers.image.created label and annotations) is now the commit time as RFC 3339, not the time of the run. This publishes differently; it's in the migration guide.

Verified locally: two clean builds of the test image gave the same digest with rewrite-timestamp=true and different digests without it. The new Reproducible job in test-bake.yml checks this on every PR. plan.sh gains two cases (20 in total).

Not covered, as the docs say: unpinned base images and packages, provenance attestations, and BuildKit's compatibility-version (not set).

Part of the 4.0.0 stack. Merge bottom to top: #82 → #83 → #84 → #85 → #86 → #88.

@Ilyes512
Ilyes512 added this pull request to stack #87 November 9, 2026 13:50
@Ilyes512 Ilyes512 changed the title Build reproducible images: SOURCE_DATE_EPOCH from the commit time feat!: build reproducible images with SOURCE_DATE_EPOCH from the commit time Nov 9, 2026
The plan job reads the commit time with git log -1 --pretty=%ct and
freezes it in the definition as the SOURCE_DATE_EPOCH build arg, so
every platform builds with the same one. BuildKit uses it for the
created timestamps in the image config and its history.

The build writes the image with rewrite-timestamp=true, which also sets
the time of every file the build created to SOURCE_DATE_EPOCH; without
it every RUN leaves the build's own time in the layers.

CREATED, and with it the org.opencontainers.image.created label and
annotations, is now that commit time instead of the time of the run, so
the same commit builds the same image.

test-bake.yml gets a Reproducible job that builds a test image twice
without cache and fails when the digests differ.
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.

1 participant