Skip to content
This repository has been archived by the owner on Jun 13, 2021. It is now read-only.

Remove build time in binary #787

Merged
merged 1 commit into from
Jan 7, 2020
Merged

Conversation

ulyssessouza
Copy link
Contributor

- What I did
Replace build time in binary with commit time

- How I did it
By changing the date by the git commiter date in the Makefile

- How to verify it

$ docker app --version

- Description for the changelog
Replace build time in binary with commit time

- A picture of a cute animal (not mandatory)
save-the-date-goat

Copy link
Contributor

@silvin-lubecki silvin-lubecki left a comment

Choose a reason for hiding this comment

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

LGTM

Makefile Outdated
ifeq ($(BUILDTIME),)
BUILDTIME := $(shell date -u +"%Y-%m-%dT%H:%M:%SZ" 2> /dev/null)
ifeq ($(COMMIT_TIME),)
COMMIT_TIME := $(shell git show -s --format="%cd" --date=format:"%Y-%m-%dT%H:%M:%SZ" 2> /dev/null)
Copy link
Member

Choose a reason for hiding this comment

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

Do we need/want the date to be in UTC?

(I recall having to go through date to get that, but it's been a while, and it's dirty. Perhaps there's an easier way docker/docker-ce-packaging#125)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually this is just an input format. According to https://github.com/docker/app/blob/master/internal/version.go#L24 this will just be used as input to the function that will return in the final format in https://github.com/docker/app/blob/master/internal/version.go#L32.

Here I had a look at the FIXME comment on line 31, but since the file does not exist in the cli, I didn't do the suggested change.

@ndeloof
Copy link
Contributor

ndeloof commented Dec 24, 2019

Why do we need such date?
Commit Sha is enough to track code matching binary. IMHO binary from commit should be fully reproducible.

@ulyssessouza
Copy link
Contributor Author

@ndeloof I see this more as a user feature to know from when is the commit of the current binary and not a dev/debug information. Maybe we need to confirm with @chris-crone before merging.

@ndeloof ndeloof closed this Dec 24, 2019
@ulyssessouza ulyssessouza reopened this Dec 24, 2019
@codecov
Copy link

codecov bot commented Dec 24, 2019

Codecov Report

Merging #787 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@          Coverage Diff           @@
##           master    #787   +/-   ##
======================================
  Coverage    70.4%   70.4%           
======================================
  Files          67      67           
  Lines        3740    3740           
======================================
  Hits         2633    2633           
  Misses        760     760           
  Partials      347     347

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 31e76df...36e84c0. Read the comment docs.

@chris-crone
Copy link
Member

The only real use of the build time is when you're testing your local build between commits and want to make sure you're using the latest version. We can:

  1. Remove the build time completely
  2. Only store the build time when building with uncommitted changes (i.e.: git describe --always shows <sha>-dirty)

I'm happy with either of the above solutions.

@thaJeztah
Copy link
Member

Was having a chat with @chris-crone (not related to this PR) Just recalled there's a "standard" env-var to use for commit-time; SOURCE_DATE_EPOCH (see https://reproducible-builds.org/specs/source-date-epoch/). Same variable was added in the "engine" in moby/moby#34176

Signed-off-by: Ulysses Souza <ulyssessouza@gmail.com>
@ulyssessouza
Copy link
Contributor Author

I've chosen approach 1, removing build time.

@ulyssessouza ulyssessouza changed the title Replace build time in binary with commit time Remove build time in binary Jan 6, 2020
Copy link
Contributor

@silvin-lubecki silvin-lubecki left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

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

SGTM

@thaJeztah
Copy link
Member

Windows CI is failing (not clear what on though)

@ulyssessouza
Copy link
Contributor Author

@thaJeztah I just rerun the tests in the CI. Windows machines are a bit unstable

@thaJeztah
Copy link
Member

All green now; @chris-crone PTAL

@ndeloof ndeloof merged commit df1c57e into docker:master Jan 7, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants