Skip to content

Commit

Permalink
Make the main module version detectable by SBOM scanners (#114)
Browse files Browse the repository at this point in the history
  • Loading branch information
LaurentGoderre authored Oct 21, 2024
1 parent 646ffb7 commit d3a6a01
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
FROM golang:1.22-alpine3.20 AS build

ARG APIFIREWALL_NAMESPACE
ARG APIFIREWALL_VERSION
ENV APIFIREWALL_VERSION=${APIFIREWALL_VERSION}

Expand All @@ -14,7 +15,7 @@ COPY . .

RUN go mod download -x && \
go build \
-ldflags="-X main.build=${APIFIREWALL_VERSION} -s -w" \
-ldflags="-X ${APIFIREWALL_NAMESPACE}/main.version=${APIFIREWALL_VERSION} -X main.build=${APIFIREWALL_VERSION} -s -w" \
-buildvcs=false \
-o ./api-firewall \
./cmd/api-firewall
Expand Down
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
VERSION := 0.8.2
NAMESPACE := github.com/wallarm/api-firewall

.DEFAULT_GOAL := build

build:
docker build --no-cache --build-arg APIFIREWALL_VERSION=$(VERSION) --force-rm -t api-firewall .
docker build --no-cache --build-arg APIFIREWALL_NAMESPACE=$(NAMESPACE) --build-arg APIFIREWALL_VERSION=$(VERSION) --force-rm -t api-firewall .

lint:
golangci-lint -v run ./...
Expand Down

2 comments on commit d3a6a01

@LaurentGoderre
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@wallarm this change doesn't seem to be included in the latest released binary

@afr1ka
Copy link
Collaborator

@afr1ka afr1ka commented on d3a6a01 Oct 28, 2024

Choose a reason for hiding this comment

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

In order to support the changes in the code too, I have changed the final version of the flag to "-X ${APIFIREWALL_NAMESPACE}/internal/version.Version=${APIFIREWALL_VERSION} -s -w". As I checked, the Syft supports this option

Please sign in to comment.