Stamp the tag or short commit in a plain docker build (closes #112) #113

Merged
clawbot merged 1 commits from issue-112-docker-version into next 2026-10-02 08:53:35 +02:00
Collaborator

Closes #112.

A plain docker build . of a clone now stamps the tag or short commit into mfer version and mfer --version, which showed only 0.1.0 before.

  • .dockerignore is the canonical copy plus this repo's *.tmp and *.dockerimage: it sends .git but not .git/config, which can hold a credential and which git describe does not need.
  • The build stage stamps main.Gitrev from the VERSION build argument when one is given, otherwise from git describe --tags --always, and fails if .git is present and no version comes out. git there trusts /src whoever owns it: a context sent as a tar archive, as upaas sends it, keeps its files' owners.
  • script/docker is the canonical copy, which passes VERSION (with --dirty) and builds with --no-cache.
  • bin/gitrev.sh, which the Makefile stamps with, passes --tags too.

Things the diff does not show:

  • The value goes into main.Gitrev: mfer version prints the mfer.Version constant, then the revision. Nothing reads main.Version.
  • The image's binary cannot run, already so on next: it is dynamically linked and the final stage is scratch. Read its version by copying it out of the image. Not fixed here.
  • script/cibuild passes no VERSION, so CI stamps what the build derives.
  • The Makefile's .dockerimage target passes a GITREV build argument the Dockerfile never declared; left as is.

Disclosure: no test added; the defect is in the Docker build, not in Go code.

Model: opus-5-5

Closes https://git.eeqj.de/sneak/mfer/issues/112. A plain `docker build .` of a clone now stamps the tag or short commit into `mfer version` and `mfer --version`, which showed only `0.1.0` before. - `.dockerignore` is the canonical copy plus this repo's `*.tmp` and `*.dockerimage`: it sends `.git` but not `.git/config`, which can hold a credential and which `git describe` does not need. - The build stage stamps `main.Gitrev` from the `VERSION` build argument when one is given, otherwise from `git describe --tags --always`, and fails if `.git` is present and no version comes out. git there trusts `/src` whoever owns it: a context sent as a tar archive, as upaas sends it, keeps its files' owners. - `script/docker` is the canonical copy, which passes `VERSION` (with `--dirty`) and builds with `--no-cache`. - `bin/gitrev.sh`, which the Makefile stamps with, passes `--tags` too. Things the diff does not show: - The value goes into `main.Gitrev`: `mfer version` prints the `mfer.Version` constant, then the revision. Nothing reads `main.Version`. - The image's binary cannot run, already so on `next`: it is dynamically linked and the final stage is `scratch`. Read its version by copying it out of the image. Not fixed here. - `script/cibuild` passes no `VERSION`, so CI stamps what the build derives. - The Makefile's `.dockerimage` target passes a `GITREV` build argument the `Dockerfile` never declared; left as is. Disclosure: no test added; the defect is in the Docker build, not in Go code. Model: opus-5-5
clawbot added the needs-review label 2026-10-02 07:52:04 +02:00
clawbot self-assigned this 2026-10-02 07:52:04 +02:00
clawbot added 1 commit 2026-10-02 07:52:04 +02:00
.dockerignore now sends .git but not .git/config, which can hold a
credential and which git describe does not need. The build stage stamps
main.Gitrev from the VERSION build argument when one is given, otherwise
from git describe --tags --always, and fails if .git is present and no
version comes out. git there trusts /src whoever owns it, since a
context sent as a tar archive keeps its files' owners. script/docker is
replaced by the canonical copy, which passes VERSION; bin/gitrev.sh uses
--tags too, so every entrypoint stamps the same value for a clean
commit.

Model: opus-5-5
Author
Collaborator

Review passed.

Model: opus-5-5

Review passed. Model: opus-5-5
clawbot merged commit c3b5fe651a into next 2026-10-02 08:53:35 +02:00
clawbot deleted branch issue-112-docker-version 2026-10-02 08:53:35 +02:00
Sign in to join this conversation.