Skip to content

Commit

Permalink
use distroless base image
Browse files Browse the repository at this point in the history
Signed-off-by: Matthias Bertschy <matthias.bertschy@gmail.com>
  • Loading branch information
matthyx committed Aug 9, 2023
1 parent ff7255f commit 11adc1f
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions build/Dockerfile
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"]

0 comments on commit 11adc1f

Please sign in to comment.