-
Notifications
You must be signed in to change notification settings - Fork 20
feat: export SOURCE_DATE_EPOCH for build commands
#284
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
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
c3aadae to
f1ae422
Compare
43ff444 to
49eefd6
Compare
49eefd6 to
6754212
Compare
leodido
added a commit
that referenced
this pull request
Nov 19, 2025
Pass SOURCE_DATE_EPOCH as a Docker build arg to make the timestamp value available inside Dockerfiles for custom build logic. This allows Dockerfiles to use: ARG SOURCE_DATE_EPOCH RUN go build -ldflags "-X main.BuildTime=$SOURCE_DATE_EPOCH" -o app Use cases: - Embedding build timestamps in binaries - Creating build metadata files - Custom reproducible build logic inside Dockerfiles Note: Image metadata determinism (layer timestamps, history, OCI annotations) is already handled by PR #284 through the environment variable. This only adds Dockerfile-level access to the value. Co-authored-by: Ona <no-reply@ona.com>
6754212 to
994b111
Compare
leodido
added a commit
that referenced
this pull request
Nov 19, 2025
…mages Pass SOURCE_DATE_EPOCH as a Docker build arg to enable deterministic Docker image timestamps. Dockerfiles MUST declare ARG SOURCE_DATE_EPOCH for BuildKit to use the timestamp for image metadata: FROM alpine:3.18 ARG SOURCE_DATE_EPOCH Without this ARG declaration, images will have non-deterministic timestamps even though the environment variable is set (from PR #284). With the ARG, BuildKit uses SOURCE_DATE_EPOCH for: - Image metadata timestamps (created field) - History timestamps - OCI annotations The ARG is also available in RUN commands for custom build logic: RUN go build -ldflags "-X main.BuildTime=$SOURCE_DATE_EPOCH" -o app Co-authored-by: Ona <no-reply@ona.com>
994b111 to
be57173
Compare
leodido
added a commit
that referenced
this pull request
Nov 19, 2025
…mages Pass SOURCE_DATE_EPOCH as a Docker build arg to enable deterministic Docker image timestamps. Dockerfiles MUST declare ARG SOURCE_DATE_EPOCH for BuildKit to use the timestamp for image metadata: FROM alpine:3.18 ARG SOURCE_DATE_EPOCH Without this ARG declaration, images will have non-deterministic timestamps even though the environment variable is set (from PR #284). With the ARG, BuildKit uses SOURCE_DATE_EPOCH for: - Image metadata timestamps (created field) - History timestamps - OCI annotations The ARG is also available in RUN commands for custom build logic: RUN go build -ldflags "-X main.BuildTime=$SOURCE_DATE_EPOCH" -o app Co-authored-by: Ona <no-reply@ona.com>
leodido
added a commit
that referenced
this pull request
Nov 19, 2025
…mages Pass SOURCE_DATE_EPOCH as a Docker build arg to enable deterministic Docker image timestamps. Dockerfiles MUST declare ARG SOURCE_DATE_EPOCH for BuildKit to use the timestamp for image metadata: FROM alpine:3.18 ARG SOURCE_DATE_EPOCH Without this ARG declaration, images will have non-deterministic timestamps even though the environment variable is set (from PR #284). With the ARG, BuildKit uses SOURCE_DATE_EPOCH for: - Image metadata timestamps (created field) - History timestamps - OCI annotations The ARG is also available in RUN commands for custom build logic: RUN go build -ldflags "-X main.BuildTime=$SOURCE_DATE_EPOCH" -o app Co-authored-by: Ona <no-reply@ona.com>
leodido
added a commit
that referenced
this pull request
Nov 19, 2025
…mages Pass SOURCE_DATE_EPOCH as a Docker build arg to enable deterministic Docker image timestamps. Dockerfiles MUST declare ARG SOURCE_DATE_EPOCH for BuildKit to use the timestamp for image metadata: FROM alpine:3.18 ARG SOURCE_DATE_EPOCH Without this ARG declaration, images will have non-deterministic timestamps even though the environment variable is set (from PR #284). With the ARG, BuildKit uses SOURCE_DATE_EPOCH for: - Image metadata timestamps (created field) - History timestamps - OCI annotations The ARG is also available in RUN commands for custom build logic: RUN go build -ldflags "-X main.BuildTime=$SOURCE_DATE_EPOCH" -o app Co-authored-by: Ona <no-reply@ona.com>
leodido
added a commit
that referenced
this pull request
Nov 19, 2025
…mages Pass SOURCE_DATE_EPOCH as a Docker build arg to enable deterministic Docker image timestamps. Dockerfiles MUST declare ARG SOURCE_DATE_EPOCH for BuildKit to use the timestamp for image metadata: FROM alpine:3.18 ARG SOURCE_DATE_EPOCH Without this ARG declaration, images will have non-deterministic timestamps even though the environment variable is set (from PR #284). With the ARG, BuildKit uses SOURCE_DATE_EPOCH for: - Image metadata timestamps (created field) - History timestamps - OCI annotations The ARG is also available in RUN commands for custom build logic: RUN go build -ldflags "-X main.BuildTime=$SOURCE_DATE_EPOCH" -o app Co-authored-by: Ona <no-reply@ona.com>
geropl
approved these changes
Nov 20, 2025
Member
geropl
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM ✔️
Export SOURCE_DATE_EPOCH environment variable for all build commands to enable reproducible builds without requiring .git directory. Build commands can use SOURCE_DATE_EPOCH directly for deterministic timestamps. Benefits: - Works in CI environments without full .git history - Standard approach (reproducible-builds.org) - Same timestamp used for tar archives and Docker images - No dependency on git being available Co-authored-by: Ona <no-reply@ona.com>
be57173 to
015b47f
Compare
leodido
added a commit
that referenced
this pull request
Nov 20, 2025
…mages Pass SOURCE_DATE_EPOCH as a Docker build arg to enable deterministic Docker image timestamps. Dockerfiles MUST declare ARG SOURCE_DATE_EPOCH for BuildKit to use the timestamp for image metadata: FROM alpine:3.18 ARG SOURCE_DATE_EPOCH Without this ARG declaration, images will have non-deterministic timestamps even though the environment variable is set (from PR #284). With the ARG, BuildKit uses SOURCE_DATE_EPOCH for: - Image metadata timestamps (created field) - History timestamps - OCI annotations The ARG is also available in RUN commands for custom build logic: RUN go build -ldflags "-X main.BuildTime=$SOURCE_DATE_EPOCH" -o app Co-authored-by: Ona <no-reply@ona.com>
leodido
added a commit
that referenced
this pull request
Nov 20, 2025
…mages Pass SOURCE_DATE_EPOCH as a Docker build arg to enable deterministic Docker image timestamps. Dockerfiles MUST declare ARG SOURCE_DATE_EPOCH for BuildKit to use the timestamp for image metadata: FROM alpine:3.18 ARG SOURCE_DATE_EPOCH Without this ARG declaration, images will have non-deterministic timestamps even though the environment variable is set (from PR #284). With the ARG, BuildKit uses SOURCE_DATE_EPOCH for: - Image metadata timestamps (created field) - History timestamps - OCI annotations The ARG is also available in RUN commands for custom build logic: RUN go build -ldflags "-X main.BuildTime=$SOURCE_DATE_EPOCH" -o app Co-authored-by: Ona <no-reply@ona.com>
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.
Description
Export
SOURCE_DATE_EPOCHenvironment variable for all build commands to enable reproducible builds without requiring .git directory.Fixes https://linear.app/ona-team/issue/CLC-2097/improve-builds-determinism
Problem
Build commands that want deterministic timestamps currently need to call git directly:
COMMIT_TIME=$(git show -s --format=%cI ${__git_commit})This fails in CI environments with:
git clone --depth=1)Solution
Export
SOURCE_DATE_EPOCHenvironment variable for all build commands.Build commands can now use:
BUILD_TIME=$SOURCE_DATE_EPOCHWhy This Makes Sense
Leeway computes a deterministic timestamp once (from git commit or external
SOURCE_DATE_EPOCHif set), then exports it for build commands to use. This creates a one-way flow:Scenario 1: Git Available (Normal Case)
Scenario 2: No Git, External SOURCE_DATE_EPOCH Set
Scenario 3: No Git, No SOURCE_DATE_EPOCH
The flow is: External Environment → Leeway → Build Commands (one-way, not circular).
The Benefit
Before this change:
After this change:
Benefits
Implementation
Uses existing
getDeterministicMtime()function which:This timestamp is now exported to the environment for all build commands.
Testing
Documentation
README.md has been updated with:
SOURCE_DATE_EPOCHenvironment variableCo-authored-by: Ona no-reply@ona.com