2022-01-18 20:57:14 +00:00
|
|
|
# Build the clusterlint binary
|
2022-10-13 15:00:38 +00:00
|
|
|
FROM golang:1.19 as builder
|
2022-01-18 20:57:14 +00:00
|
|
|
WORKDIR /workspace
|
|
|
|
# Copy the Go Modules manifests
|
|
|
|
COPY go.mod go.mod
|
|
|
|
COPY go.sum go.sum
|
|
|
|
COPY vendor/ vendor/
|
|
|
|
|
|
|
|
# Copy the go source
|
|
|
|
COPY cmd/clusterlint/main.go main.go
|
|
|
|
COPY kube/ kube/
|
|
|
|
COPY checks checks/
|
|
|
|
|
|
|
|
# Build
|
2022-10-14 15:22:49 +00:00
|
|
|
ARG version
|
2022-01-18 20:57:14 +00:00
|
|
|
RUN GOFLAGS="-mod=vendor" CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on \
|
2022-10-14 15:22:49 +00:00
|
|
|
go build -ldflags="-X main.Version=$version" -a -o clusterlint main.go
|
2022-01-18 20:57:14 +00:00
|
|
|
|
|
|
|
# Use distroless as minimal base image to package the clusterlint binary
|
|
|
|
# Refer to https://github.com/GoogleContainerTools/distroless for more details
|
|
|
|
FROM gcr.io/distroless/static:nonroot
|
|
|
|
WORKDIR /
|
|
|
|
COPY --from=builder /workspace/clusterlint .
|
|
|
|
USER nonroot:nonroot
|
|
|
|
|
|
|
|
ENTRYPOINT ["/clusterlint"]
|
|
|
|
CMD ["-h"]
|