-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Matthias Bertschy <matthias.bertschy@gmail.com>
- Loading branch information
Showing
1 changed file
with
19 additions
and
10 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,20 @@ | ||
FROM golang:1.19 | ||
FROM --platform=$BUILDPLATFORM golang:1.20-bullseye as builder | ||
ARG BUILD_VERSION | ||
WORKDIR /app/ | ||
COPY . ./ | ||
ENV CGO_ENABLED=0 | ||
RUN go get ./... | ||
RUN go build -o kube-host-sensor --ldflags "-w -s -X main.BuildVersion=$BUILD_VERSION" | ||
|
||
FROM alpine | ||
COPY --from=0 /app/kube-host-sensor /. | ||
ENTRYPOINT [ "./kube-host-sensor" ] | ||
ENV GO111MODULE=on CGO_ENABLED=0 | ||
WORKDIR /work | ||
ARG TARGETOS TARGETARCH | ||
|
||
RUN --mount=target=. \ | ||
--mount=type=cache,target=/root/.cache/go-build \ | ||
--mount=type=cache,target=/go/pkg \ | ||
GOOS=$TARGETOS GOARCH=$TARGETARCH go build -o /out/kube-host-sensor --ldflags "-w -s -X main.BuildVersion=$BUILD_VERSION" . | ||
|
||
FROM gcr.io/distroless/static-debian11:latest | ||
|
||
COPY --from=builder /out/kube-host-sensor /usr/bin/kube-host-sensor | ||
|
||
ARG image_version | ||
ENV RELEASE=$image_version | ||
|
||
WORKDIR /root | ||
ENTRYPOINT ["kube-host-sensor"] |