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 <Joel.speed@hotmail.co.uk>
commit3fc194ee72ce4db3f9e43d6f0c296a8aa7f26d35
authorIan Roberts <i.roberts@dcs.shef.ac.uk>
dateMon 29 Mar 2021, 19:08 (6 years ago)
parent3315e5d
Dockerfile+2−1
@@ -1,5 +1,4 @@
11FROM golang:1.16-buster AS builder
2−ARG VERSION
32
43# Copy sources
54WORKDIR $GOPATH/src/github.com/oauth2-proxy/oauth2-proxy
@@ -11,6 +10,8 @@ RUN GO111MODULE=on go mod download
1110# Now pull in our code
1211COPY . .
1312
13+ARG VERSION
14+
1415# Build binary and make sure there is at least an empty key file.
1516# This is useful for GCP App Engine custom runtime builds, because
1617# you cannot use multiline variables in their app.yaml, so you have to
Dockerfile.arm64+2−1
@@ -1,5 +1,4 @@
11FROM golang:1.16-buster AS builder
2−ARG VERSION
32
43# Copy sources
54WORKDIR $GOPATH/src/github.com/oauth2-proxy/oauth2-proxy
@@ -11,6 +10,8 @@ RUN GO111MODULE=on go mod download
1110# Now pull in our code
1211COPY . .
1312
13+ARG VERSION
14+
1415# Build binary and make sure there is at least an empty key file.
1516# This is useful for GCP App Engine custom runtime builds, because
1617# you cannot use multiline variables in their app.yaml, so you have to
Dockerfile.armv6+2−1
@@ -1,5 +1,4 @@
11FROM golang:1.16-buster AS builder
2−ARG VERSION
32
43# Copy sources
54WORKDIR $GOPATH/src/github.com/oauth2-proxy/oauth2-proxy
@@ -11,6 +10,8 @@ RUN GO111MODULE=on go mod download
1110# Now pull in our code
1211COPY . .
1312
13+ARG VERSION
14+
1415# Build binary and make sure there is at least an empty key file.
1516# This is useful for GCP App Engine custom runtime builds, because
1617# you cannot use multiline variables in their app.yaml, so you have to