Commit 16af59ba authored by Geoff Simmons's avatar Geoff Simmons

Controller image: download Go modules in separate layer, before build.

When go.mod & go.sum are unchanged in the layer, no downloads are
necessary. This greatly saves time for the image builds.
parent 3c6746a2
......@@ -3,10 +3,16 @@ RUN go get -u golang.org/x/vgo
RUN go get -d -v github.com/slimhazard/gogitversion && \
cd /go/src/github.com/slimhazard/gogitversion && \
make install
COPY . /go/src/code.uplex.de/uplex-varnish/k8s-ingress
RUN mkdir -p /go/src/code.uplex.de/uplex-varnish/k8s-ingress/cmd
WORKDIR /go/src/code.uplex.de/uplex-varnish/k8s-ingress/cmd
RUN vgo generate && \
CGO_ENABLED=0 GOOS=linux vgo build -o k8s-ingress *.go
COPY ./cmd/go.mod .
COPY ./cmd/go.sum .
RUN vgo mod download
COPY . /go/src/code.uplex.de/uplex-varnish/k8s-ingress
RUN vgo generate && CGO_ENABLED=0 GOOS=linux vgo build -o k8s-ingress *.go
FROM alpine:3.8
COPY --from=builder /go/src/code.uplex.de/uplex-varnish/k8s-ingress/cmd/k8s-ingress /k8s-ingress
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment