Skip to content

Commit

Permalink
fix(build): Export version to the right ldflag path
Browse files Browse the repository at this point in the history
Go silently ignore values passed by `ldflags -X` and resulted in release
not carrying version numbers for the hardcoded values in the binary.

Maybe this way of packaging version should be revisited as it had a
bunch of issues with deployment, but maybe it's just one of those things
that are hard to get right but once it is, it becomes stable.
  • Loading branch information
pier-oliviert committed Nov 17, 2024
1 parent 8aee6be commit 627208d
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Dockerfile.controller
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
FROM golang:1.23 AS source
ARG TARGETOS
ARG TARGETARCH
ARG PROVIDER_VERSION

WORKDIR /workspace
# Copy the Go Modules manifests
Expand All @@ -19,7 +20,7 @@ COPY pkg/ pkg/
COPY internal/ internal/
COPY cmd/controller/main.go cmd/main.go

RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -ldflags="-X 'providers.ProviderVersion=${PROVIDER_VERSION}'" -a -o controller cmd/main.go
RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -ldflags="-X 'github.com/pier-oliviert/phonebook/pkg/providers.ProviderVersion=${PROVIDER_VERSION}'" -a -o controller cmd/main.go


# Use distroless as minimal base image to package the controller binary
Expand Down

0 comments on commit 627208d

Please sign in to comment.