Skip to content

Commit

Permalink
use ldflags
Browse files Browse the repository at this point in the history
  • Loading branch information
k15r committed Oct 25, 2024
1 parent 49f42ed commit 2e1532f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ WORKDIR /telemetry-manager-workspace
# Copy the Go Modules manifests
COPY go.mod go.mod
COPY go.sum go.sum
COPY .git .git
# cache deps before building and copying source so that we don't need to re-download as much
# and so that source changes don't invalidate our downloaded layer
RUN go mod download
Expand All @@ -16,8 +17,10 @@ COPY controllers/ controllers/
COPY internal/ internal/
COPY webhook/ webhook/

RUN apk add git

# Clean up unused (test) dependencies and build
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go mod tidy && go build -a -o manager main.go
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go mod tidy && go build -ldflags="-X main.version=$(git rev-parse --short HEAD)" -a -o manager main.go

FROM scratch

Expand Down

0 comments on commit 2e1532f

Please sign in to comment.