Repository navigation
Description
Summary
GET /api/version shows version: "unknown" on the dev instance (and any prod-compose deploy). It's two independent delivery bugs in the build/CI path, plus an opportunity to make the version string self-describing from git.
Root causes
1. version field — VERSION file never reaches the prod image.
docker/backend/DockerfileneverCOPYsVERSION.docker-compose.yml(dev) bind-mounts./VERSION:/app/VERSION:ro, which masks the bug locally.docker-compose.prod.yml(used by the dev instance) has no such mount.- Fallback
Path(__file__).parent.parent.parent / "VERSION"resolves to/VERSION(since__file__=/app/main.py), which doesn't exist →version = "unknown".
2. Git provenance fields (git_commit, git_branch, build_date) — build args stripped by sudo.
deploy-dev.ymlpasses them assudo GIT_COMMIT=… docker compose build.- Under default Ubuntu sudoers (
env_reseton,setenvoff), command-lineVAR=valassignments don't reliably reach the command's environment, sodocker composeinterpolation falls back to${VAR:-unknown}. scripts/deploy/start.shworks because it runsdocker composewithout sudo.
Decision
Make the version string dynamic from git (Option B): curated semver from the VERSION file + git short-sha suffix, e.g. 0.9.0+g4c640b6e (.dirty when the tree is dirty). git_commit_short continues to carry the bare commit separately in the payload.
Pure git describe (Option A) was rejected because the last platform tag (v0.5.0) lags the curated file (0.9.0), and cli-v* tags pollute describe — it would regress the displayed version.
Changes
docker/backend/Dockerfile— addARG VERSION=unknown+ENV VERSION=${VERSION}in the existing provenance block.docker-compose.yml+docker-compose.prod.yml— addVERSION: ${VERSION:-unknown}tobackend.build.args.src/backend/main.py_build_version_payload— preferos.getenv("VERSION"), fall back to the VERSION file, then"unknown".scripts/deploy/start.sh— computeVERSION="$(cat VERSION)+g$(git rev-parse --short=8 HEAD)[.dirty]"and export it..github/workflows/deploy-dev.yml— compute the sameVERSION, and switch the build invocation tosudo env VAR=val … docker compose buildso VERSION and the existing git fields actually reach the build.
Acceptance criteria
-
GET /api/versionon a prod-compose deploy returns a realversion(e.g.0.9.0+g<sha>), notunknown. -
git_commit/git_branch/build_datepopulated on the dev deploy (no longerunknown). - Dev and prod compose report the same
versionfor the same commit. - No reliance on the
/app/VERSIONbind-mount for correctness.
Out of scope
- Moving the image build into CI + registry (stateless dev VM) — tracked separately in devops agent: fleet control-panel buildout (tracks devops#9-13) #942.
- Release-tagging discipline / adopting
git describe(Option A).
Activity
fix(version): derive /api/version from git, fix unknown on prod/dev (#…
fix(frontend): strip semver build metadata from displayed version to …
fix(version): report the code that is running, not the image it was b…