Repository navigation
Description
Every published ghcr.io/scttfrdmn/substrate image reports "version":"dev" regardless of the tag, so a consumer cannot tell which build they are talking to.
Reproduce
$ podman run -d -p 4566:4566 ghcr.io/scttfrdmn/substrate:0.76.0
$ curl -s localhost:4566/health
{"status":"ok","version":"dev"}Confirmed on 0.76.0, 0.75.0, and 0.70.0 — systemic across releases, not a one-off bad build.
Root cause
Dockerfile:10 injects the version into the root module path, which contains no Go files:
-X github.com/scttfrdmn/substrate.Version=${VERSION}
But the variable actually served by /health and /_localstack/{health,info} lives in the emulator package — emulator/doc.go:131:
var Version = "dev"emulator/server.go:424 (handleHealth) and :325 (handleLocalStackHealth) both read that Version. -X on a package with no Go files is silently ignored by the linker — no warning, no build failure — so emulator.Version keeps its "dev" default.
Makefile:4 has the correct path, which is why locally-built binaries report the right version and container images do not:
LDFLAGS := -ldflags "-X main.version=$(VERSION) -X github.com/scttfrdmn/substrate/emulator.Version=$(VERSION)"Note .github/workflows/docker.yml:44 does correctly pass build-args: VERSION=${{ github.ref_name }}, so the build wiring is fine — only the target symbol path is wrong.
Proof
Two binaries from the same tree at fa7684b (v0.76.0), differing only in the -X path:
$ go build -ldflags "-X main.version=0.76.0 -X github.com/scttfrdmn/substrate.Version=0.76.0" -o /tmp/sub-dockerfile ./cmd/substrate
$ go build -ldflags "-X main.version=0.76.0 -X github.com/scttfrdmn/substrate/emulator.Version=0.76.0" -o /tmp/sub-fixed ./cmd/substrate
$ curl -s localhost:4578/health # Dockerfile path
{"status":"ok","version":"dev"}
$ curl -s localhost:4577/health # emulator path
{"status":"ok","version":"0.76.0"}Both builds succeeded — the bad -X produced no diagnostic.
Fix
Dockerfile:10 — add the /emulator path segment:
- -ldflags "-X main.version=${VERSION} -X github.com/scttfrdmn/substrate.Version=${VERSION}" \
+ -ldflags "-X main.version=${VERSION} -X github.com/scttfrdmn/substrate/emulator.Version=${VERSION}" \Two things worth doing alongside it, since the class of bug is "a typo in an ldflags path fails silently":
.github/workflows/ci.yml:68omitsemulator.Versionentirely (-X main.version=...only). That binary is not published, so it is cosmetic, but it will drift from the Makefile the same way.- Guard it in CI. A smoke step that asserts the built image reports the expected version would have caught this at the first release. Something like
test "$(curl -s localhost:4566/health | jq -r .version)" = "${GITHUB_REF_NAME}"indocker.ymlafter the build. Alternatively, haveemulator.Versionfall back toruntime/debug.ReadBuildInfo()so a VCS-stamped binary reports something real even when ldflags are wrong.
Impact
Downstream projects that pin a substrate image tag for reproducible CI cannot verify at runtime which version answered. In parsl-ephemeral-aws we are pinning ghcr.io/scttfrdmn/substrate:0.76.0 in both docker-compose.substrate.yml and the CI service container, and the health endpoint gives us no way to confirm the pin took effect — so a silently-wrong tag or a stale cached image would go unnoticed.
Activity
scttfrdmn commentedon Aug 1, 2026
Fixed in #433, merged to
main. Your diagnosis was exact — including that-Xagainst the root module path links with no diagnostic — so the production change is the one-line one you wrote.Reproduced from a real image build before and after, since the flag path is easy to reason about wrongly:
Both of your follow-ups are in:
.github/workflows/ci.ymlstamped onlymain.version; it now stampsemulator.Versiontoo.The CI guard, as
scripts/check-version-stamping.sh/make version-checkand a newVersion Stampingjob. It builds with the Dockerfile's own-ldflags— extracted from the file rather than restated, so the two cannot drift — and asserts the running server reports that version on/health,/_localstack/healthand/_localstack/info. Two cheaper checks name the culprit when it fails: the Dockerfile and Makefile must stamp the same symbols, and every-Xtarget must resolve viago doc. I verified the guard is load-bearing by reverting the Dockerfile: all three layers fire and it reproduces"version":"dev".Your
docker.ymlsuggestion is there as well, close to what you proposed — it smoke-tests the image it just pushed againstgithub.ref_name. That's the layer CI can't reach, since theVERSIONbuild-arg wiring only exists in a real image build.One thing I did not take: the
runtime/debug.ReadBuildInfo()fallback. It would make a wrong-Xinvisible again by papering over it, which is the failure mode that cost you this bug. It's a good idea on its own merits forgo install-ed binaries though — worth its own issue if you want that, distinct from release-image stamping.Note this ships in the next release, not retroactively: published tags are immutable (a moved tag breaks
go.sumverification for every consumer), so0.76.0and every existing image will keep reporting"dev". Once the next tag is cut,curl .../health | jq -r .versionbecomes a real pin check forparsl-ephemeral-aws. Until then,substrate --versioninside the container is accurate —docker run --rm --entrypoint /usr/local/bin/substrate ghcr.io/scttfrdmn/substrate:0.76.0 --version— if you want to verify a pinned image today.Also worth flagging while you're pinning images: no GitHub Release objects exist for v0.80.0 or v0.81.0 (the tags and images are published; only the Release pages are missing), so
gh release listunder-reports the latest version. Tracking that separately.