From 3fc194ee72ce4db3f9e43d6f0c296a8aa7f26d35 Mon Sep 17 00:00:00 2001 From: Ian Roberts Date: Mon, 29 Mar 2021 19:08:40 +0100 Subject: [PATCH] Minor change to the Dockerfile to improve build speed (#1139) "go mod download" does not depend on the VERSION env var, so moving the ARG directive after the RUN will allow better use of the Docker build cache - subsequent builds on the same machine need only re-run the "go mod download" if go.mod or go.sum has changed, rather than re-running it any time the VERSION value passed from the Makefile has changed Co-authored-by: Joel Speed --- Dockerfile | 3 ++- Dockerfile.arm64 | 3 ++- Dockerfile.armv6 | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index ba8b3224..bf5fbb95 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,4 @@ FROM golang:1.16-buster AS builder -ARG VERSION # Copy sources WORKDIR $GOPATH/src/github.com/oauth2-proxy/oauth2-proxy @@ -11,6 +10,8 @@ RUN GO111MODULE=on go mod download # Now pull in our code COPY . . +ARG VERSION + # Build binary and make sure there is at least an empty key file. # This is useful for GCP App Engine custom runtime builds, because # you cannot use multiline variables in their app.yaml, so you have to diff --git a/Dockerfile.arm64 b/Dockerfile.arm64 index 3c60b107..d4c00d5d 100644 --- a/Dockerfile.arm64 +++ b/Dockerfile.arm64 @@ -1,5 +1,4 @@ FROM golang:1.16-buster AS builder -ARG VERSION # Copy sources WORKDIR $GOPATH/src/github.com/oauth2-proxy/oauth2-proxy @@ -11,6 +10,8 @@ RUN GO111MODULE=on go mod download # Now pull in our code COPY . . +ARG VERSION + # Build binary and make sure there is at least an empty key file. # This is useful for GCP App Engine custom runtime builds, because # you cannot use multiline variables in their app.yaml, so you have to diff --git a/Dockerfile.armv6 b/Dockerfile.armv6 index 435394e1..f413b155 100644 --- a/Dockerfile.armv6 +++ b/Dockerfile.armv6 @@ -1,5 +1,4 @@ FROM golang:1.16-buster AS builder -ARG VERSION # Copy sources WORKDIR $GOPATH/src/github.com/oauth2-proxy/oauth2-proxy @@ -11,6 +10,8 @@ RUN GO111MODULE=on go mod download # Now pull in our code COPY . . +ARG VERSION + # Build binary and make sure there is at least an empty key file. # This is useful for GCP App Engine custom runtime builds, because # you cannot use multiline variables in their app.yaml, so you have to