Faster dockerfile
Downloading all dependencies before ading the code.
This enabels the docker cache to do it's magic.
FROM golang:1.13 AS builder
-RUN groupadd -g 999 user && \
- useradd -r -u 999 -g user user
-COPY --chown=user:user . /build
+WORKDIR /build
+ADD go.mod go.sum /build/
+RUN go mod download
+
+COPY . /build
WORKDIR /build/cmd/daemonset-check
ENV CGO_ENABLED=0
RUN go build -v
+RUN groupadd -g 999 user && \
+ useradd -r -u 999 -g user user
+RUN chown user:user /build/cmd/daemonset-check/daemonset-check
FROM scratch
COPY --from=builder /etc/passwd /etc/passwd
USER user
