docker build . stamps dev, not the git tag or short commit #67

Closed
opened 2026-10-02 02:21:46 +02:00 by clawbot · 0 comments
Collaborator

Owner's words (chat, 2026-10-02 ~00:00 UTC; the rollout across repos is sneak/project-management#21):

main.Version on sneak/api is set to "dev" instead of the git hash when being built under upaas, fix that

audit all other repos for that same bug. "docker build ." should pick up the git short rev or tag

Today: .dockerignore excludes .git, so the Makefile's git describe falls back to dev inside the image build.

This is the Docker half of #15; the --version output going to stderr stays there.

The convention (canonical text: sneak/prompts#69; working examples: sneak/upaas#242, sneak/webhooker#410):

  • .dockerignore lets .git into the build context.
  • The stage that compiles has git and takes the version from the VERSION build argument when one is given, otherwise from git describe --tags --always (a tag when the commit has one, otherwise the short commit). ARG VERSION has no default.
  • The build fails if the context carries .git and the version still comes out empty, dev or unknown.
  • Host-side scripts that already pass --build-arg VERSION=... may keep doing so.
  • Any buildarch left in the repo goes too (sneak/project-management#19): the architecture is read at run time from runtime.GOARCH.

Definition of done:

  • A fresh clone, then docker build . with no build arguments, then running the binary: the version it reports shows the commit's tag or short commit, never dev, unknown or empty.
  • docker build --build-arg VERSION=x . stamps x; a context with .git from which no version can be derived fails the build.
  • make check passes; PR to next; independent review; squash.

Model: opus-5-5

Owner's words (chat, 2026-10-02 ~00:00 UTC; the rollout across repos is https://git.eeqj.de/sneak/project-management/issues/21): > main.Version on sneak/api is set to "dev" instead of the git hash when being built under upaas, fix that > audit all other repos for that same bug. "docker build ." should pick up the git short rev or tag Today: `.dockerignore` excludes `.git`, so the Makefile's `git describe` falls back to `dev` inside the image build. This is the Docker half of https://git.eeqj.de/sneak/sfdupes/issues/15; the `--version` output going to stderr stays there. The convention (canonical text: https://git.eeqj.de/sneak/prompts/issues/69; working examples: https://git.eeqj.de/sneak/upaas/pulls/242, https://git.eeqj.de/sneak/webhooker/pulls/410): - `.dockerignore` lets `.git` into the build context. - The stage that compiles has `git` and takes the version from the `VERSION` build argument when one is given, otherwise from `git describe --tags --always` (a tag when the commit has one, otherwise the short commit). `ARG VERSION` has no default. - The build fails if the context carries `.git` and the version still comes out empty, `dev` or `unknown`. - Host-side scripts that already pass `--build-arg VERSION=...` may keep doing so. - Any `buildarch` left in the repo goes too (https://git.eeqj.de/sneak/project-management/issues/19): the architecture is read at run time from `runtime.GOARCH`. Definition of done: - A fresh clone, then `docker build .` with no build arguments, then running the binary: the version it reports shows the commit's tag or short commit, never `dev`, `unknown` or empty. - `docker build --build-arg VERSION=x .` stamps `x`; a context with `.git` from which no version can be derived fails the build. - `make check` passes; PR to `next`; independent review; squash. Model: opus-5-5
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sneak/sfdupes#67