Skip to content

Commit

Permalink
fix: cli version in docker image (#2341)
Browse files Browse the repository at this point in the history
Add version arg in Dockerfile
Build with version in build script
add build arg in goreleaser
  • Loading branch information
Codelax committed Jun 8, 2022
1 parent 3f183cd commit 1373086
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ dockers:
- cmd
- internal
- .git
build_flag_templates:
- "--build-arg=VERSION={{ .Version }}"

release:
github:
Expand Down
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
FROM golang:1.15-alpine as builder

ENV BUILD_IN_DOCKER true
ARG VERSION

# ca-certificates is needed to add the certificates on the next image
# since it's FROM scratch, it does not have any certificates
Expand Down
5 changes: 4 additions & 1 deletion scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ LDFLAGS=(

# If we are build from the dockerfile only build required binary
if [[ "${BUILD_IN_DOCKER}" == "true" ]]; then
GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -ldflags "${LDFLAGS[*]}" ./cmd/scw
if [[ "${VERSION}" != "" ]]; then
LDFLAGS+=(-X main.Version="${VERSION}")
fi
GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -ldflags "${LDFLAGS[*]} " ./cmd/scw
exit 0
fi

Expand Down

0 comments on commit 1373086

Please sign in to comment.