Skip to content

ci: inject VERSION build-arg into docker image build#387

Merged
viniciusdc merged 3 commits into
mainfrom
fix/docker-version-buildarg
Jun 5, 2026
Merged

ci: inject VERSION build-arg into docker image build#387
viniciusdc merged 3 commits into
mainfrom
fix/docker-version-buildarg

Conversation

@aktech

@aktech aktech commented Jun 5, 2026

Copy link
Copy Markdown
Member

Published nebi images report their version as dev, so the web UI shows vdev.

Root cause

The runtime chain is correct: -X main.Version -> serve.go -> server.Config.Version -> handlers.Version -> /version. The Dockerfile already accepts ARG VERSION and bakes it via ldflags.

The break is in CI: the Build and maybe push step in docker.yml never passed a VERSION build-arg, so ARG VERSION=dev (the Dockerfile default) was used. The container ships no .git, so the handler's runtime git describe fallback also fails, leaving version: "dev".

Fix

  • Compute the version with git describe --tags --always --dirty (the exact format internal/api/handlers/version.go parses, and what the Makefile already uses).
  • Pass it as build-args: VERSION=... to docker/build-push-action.
  • Add a smoke-test guard that fails the build if /version reports dev.

Verification

Built the image locally with the build-arg and ran the smoke test:

{ "version": "0.12-rc3.dev+e8f6759", "commit": "e8f6759", ... }

Previously this returned "version": "dev".

Screenshot 2026-06-05 at 13 41 55

The Dockerfile accepts ARG VERSION and bakes it into the binary via
-X main.Version, which flows to the /version handler. The workflow never
passed the build-arg, so published images defaulted to VERSION=dev and the
runtime git fallback found no .git in the container, leaving the UI showing
"vdev".

Compute the version with git describe (same format the version handler parses,
matching the Makefile) and pass it as a build-arg. Add a smoke-test guard that
fails the build if the image reports version "dev".
@netlify

netlify Bot commented Jun 5, 2026

Copy link
Copy Markdown

Deploy Preview for nebi-docs canceled.

Name Link
🔨 Latest commit 19ccfda
🔍 Latest deploy log https://app.netlify.com/projects/nebi-docs/deploys/6a22c45ece82490008263644

@viniciusdc viniciusdc left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, the test addition trough the api request was a clever idea

@viniciusdc viniciusdc merged commit f4b23ca into main Jun 5, 2026
14 checks passed
@viniciusdc viniciusdc deleted the fix/docker-version-buildarg branch June 5, 2026 12:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants