fix(build): inject version number in Makefile and Dockerfile builds#376
Open
cx-ori-bendet wants to merge 1 commit intomasterfrom
Open
fix(build): inject version number in Makefile and Dockerfile builds#376cx-ori-bendet wants to merge 1 commit intomasterfrom
cx-ori-bendet wants to merge 1 commit intomasterfrom
Conversation
Local and Docker builds were missing the -X linker flag that injects the version at compile time, causing `2ms --version` to always report 0.0.0 on Linux and in containers. - Makefile build-local: use `git describe --tags` to derive the version from the current git tag automatically, falling back to "dev" - Dockerfile: add a VERSION build arg (default "dev") and pass it via -X so `docker build --build-arg VERSION=x.y.z .` produces a correctly versioned image Fixes #360 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Great job! No new security vulnerabilities introduced in this pull request |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.








Summary
make build-localanddocker buildwere missing the-Xlinker flag that injects the version at compile time2ms --versionalways reported0.0.0on Linux and in Docker containers, while macOS Homebrew installs showed the correct versionbuild-local: added-X github.com/checkmarx/2ms/v5/cmd.Version=$(git describe --tags)so local builds automatically pick up the version from the current git tag (falls back todevif no tag is present)ARG VERSION=devand the same-Xflag sodocker build --build-arg VERSION=x.y.z .produces a correctly versioned image; defaults todevwhen no arg is suppliedFixes #360
Test plan
make build-localon a tagged commit and verify./2ms --versionprints the correct tagmake build-localwithout a tag and verify it printsdev(or the short commit hash)docker build --build-arg VERSION=1.2.3 -t 2ms-test .and verifydocker run 2ms-test --versionprints2ms version 1.2.3docker build -t 2ms-test .(no arg) and verify it prints2ms version devI submit this contribution under the Apache-2.0 license.
🤖 Generated with Claude Code