Stamp the git tag or short commit in a plain docker build (closes #46) #47

Merged
clawbot merged 1 commits from issue-46-version-from-git into next 2026-10-02 08:17:36 +02:00
Collaborator

Implements #46: a plain docker build . of a clone now stamps the commit's tag or short commit into the page footer instead of unknown.

  • .dockerignore sends .git and leaves out .git/config, which can hold a credential and which git describe does not need; the comment is the canonical one from sneak/prompts next.
  • The build stage (the Debian Go image already has git) takes the VERSION build argument when one is given, otherwise git describe --tags --always, and fails if the context carries .git and the result is empty, dev or unknown. It stamps that into version.GitRevisionShort (the footer text) and the full commit into version.GitRevision (the footer link), the two variables make build sets.
  • make build takes GitRevisionShort from git describe --tags --always instead of git rev-parse --short, so it stamps what the image does.
  • script/docker is now the current canonical copy: it builds with --no-cache and passes git describe --tags --always --dirty as VERSION.

What the diff does not show:

  • With .git and git in the build stage, go build also records VCS details in the binary; nothing reads them.
  • No buildarch in the repo.

Disclosures:

  • Judgement call: this repo's .dockerignore (#39) shares no other text with the canonical one; only its .git/config block was taken.
  • REPO_POLICIES.md still shows the old ARG VERSION=dev template; it is the synced canonical copy.
  • script/cibuild is unchanged: it passes no version, so CI builds take it from .git.

Model: opus-5-5

Implements https://git.eeqj.de/sneak/routewatch/issues/46: a plain `docker build .` of a clone now stamps the commit's tag or short commit into the page footer instead of `unknown`. - `.dockerignore` sends `.git` and leaves out `.git/config`, which can hold a credential and which `git describe` does not need; the comment is the canonical one from `sneak/prompts` `next`. - The build stage (the Debian Go image already has `git`) takes the `VERSION` build argument when one is given, otherwise `git describe --tags --always`, and fails if the context carries `.git` and the result is empty, `dev` or `unknown`. It stamps that into `version.GitRevisionShort` (the footer text) and the full commit into `version.GitRevision` (the footer link), the two variables `make build` sets. - `make build` takes `GitRevisionShort` from `git describe --tags --always` instead of `git rev-parse --short`, so it stamps what the image does. - `script/docker` is now the current canonical copy: it builds with `--no-cache` and passes `git describe --tags --always --dirty` as `VERSION`. What the diff does not show: - With `.git` and `git` in the build stage, `go build` also records VCS details in the binary; nothing reads them. - No `buildarch` in the repo. Disclosures: - Judgement call: this repo's `.dockerignore` (https://git.eeqj.de/sneak/routewatch/issues/39) shares no other text with the canonical one; only its `.git/config` block was taken. - `REPO_POLICIES.md` still shows the old `ARG VERSION=dev` template; it is the synced canonical copy. - `script/cibuild` is unchanged: it passes no version, so CI builds take it from `.git`. Model: opus-5-5
clawbot added the needs-review label 2026-10-02 07:23:27 +02:00
clawbot self-assigned this 2026-10-02 07:23:27 +02:00
clawbot added 1 commit 2026-10-02 07:23:28 +02:00
A plain `docker build .` stamped `unknown` into the page footer:
.dockerignore left out .git, and the Dockerfile built without the -X
flags. The context now carries .git without .git/config, which can hold
a credential. The build stage takes the VERSION build argument when one
is given, otherwise `git describe --tags --always`, fails the build if
.git is present and no version comes out, and stamps it together with
the full commit the footer links to. `make build` now uses
`git describe` as well, and script/docker is the current shared copy.

Model: opus-5-5
Author
Collaborator

Review passed.

Model: opus-5-5

Review passed. Model: opus-5-5
clawbot merged commit 7322f936e4 into next 2026-10-02 08:17:36 +02:00
clawbot deleted branch issue-46-version-from-git 2026-10-02 08:17:36 +02:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sneak/routewatch#47