Decrease the time of the container image build
# Build the manager binary
FROM golang:1.16 as builder
-COPY . /go/src/github.com/jaegertracing/jaeger-operator/
WORKDIR /go/src/github.com/jaegertracing/jaeger-operator
-# 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
+# Download the dependencies. Doing this, if there are changes in the source
+# code but not in the dependencies to download, the tool to build the image will
+# use the cached dependencies
+COPY go.mod /go/src/github.com/jaegertracing/jaeger-operator/go.mod
+COPY go.sum /go/src/github.com/jaegertracing/jaeger-operator/go.sum
RUN go mod download
+COPY . /go/src/github.com/jaegertracing/jaeger-operator/
+
# Build
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -o ./uiconfig -a ./tests/assert-jobs/uiconfig/main.go
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -o ./reporter -a ./tests/assert-jobs/reporter/main.go
