From e3ca393d9e0219af0de3c0eba3cfba99de2fc41e Mon Sep 17 00:00:00 2001 From: Ian Howell Date: Mon, 18 Nov 2019 15:55:02 -0600 Subject: [PATCH] Utilize Docker caching to speed up image building This rearranges the Dockerfile to COPY over the go module files for downloading prior to building, linting, and testing. This will allow developers to more quickly test their code via Docker given that their dependencies change infrequently. Change-Id: I3650fbd9ca18d453921d25a536e8b4cf60ce1b5e --- Dockerfile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index bcaaf44e1..13c8ac7a0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,11 +3,13 @@ ARG RELEASE_IMAGE=scratch FROM ${GO_IMAGE} as builder SHELL [ "/bin/bash", "-cex" ] -ADD . /usr/src/airshipctl WORKDIR /usr/src/airshipctl -RUN make get-modules +# Take advantage of caching for dependency acquisition +COPY go.mod go.sum /usr/src/airshipctl/ +RUN go mod download +COPY . /usr/src/airshipctl/ ARG MAKE_TARGET=build RUN make ${MAKE_TARGET}