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>
This commit is contained in:
		
							parent
							
								
									3315e5d4b8
								
							
						
					
					
						commit
						3fc194ee72
					
				|  | @ -1,5 +1,4 @@ | ||||||
| FROM golang:1.16-buster AS builder | FROM golang:1.16-buster AS builder | ||||||
| ARG VERSION |  | ||||||
| 
 | 
 | ||||||
| # Copy sources | # Copy sources | ||||||
| WORKDIR $GOPATH/src/github.com/oauth2-proxy/oauth2-proxy | WORKDIR $GOPATH/src/github.com/oauth2-proxy/oauth2-proxy | ||||||
|  | @ -11,6 +10,8 @@ RUN GO111MODULE=on go mod download | ||||||
| # Now pull in our code | # Now pull in our code | ||||||
| COPY . . | COPY . . | ||||||
| 
 | 
 | ||||||
|  | ARG VERSION | ||||||
|  | 
 | ||||||
| # Build binary and make sure there is at least an empty key file. | # Build binary and make sure there is at least an empty key file. | ||||||
| #  This is useful for GCP App Engine custom runtime builds, because | #  This is useful for GCP App Engine custom runtime builds, because | ||||||
| #  you cannot use multiline variables in their app.yaml, so you have to | #  you cannot use multiline variables in their app.yaml, so you have to | ||||||
|  |  | ||||||
|  | @ -1,5 +1,4 @@ | ||||||
| FROM golang:1.16-buster AS builder | FROM golang:1.16-buster AS builder | ||||||
| ARG VERSION |  | ||||||
| 
 | 
 | ||||||
| # Copy sources | # Copy sources | ||||||
| WORKDIR $GOPATH/src/github.com/oauth2-proxy/oauth2-proxy | WORKDIR $GOPATH/src/github.com/oauth2-proxy/oauth2-proxy | ||||||
|  | @ -11,6 +10,8 @@ RUN GO111MODULE=on go mod download | ||||||
| # Now pull in our code | # Now pull in our code | ||||||
| COPY . . | COPY . . | ||||||
| 
 | 
 | ||||||
|  | ARG VERSION | ||||||
|  | 
 | ||||||
| # Build binary and make sure there is at least an empty key file. | # Build binary and make sure there is at least an empty key file. | ||||||
| #  This is useful for GCP App Engine custom runtime builds, because | #  This is useful for GCP App Engine custom runtime builds, because | ||||||
| #  you cannot use multiline variables in their app.yaml, so you have to | #  you cannot use multiline variables in their app.yaml, so you have to | ||||||
|  |  | ||||||
|  | @ -1,5 +1,4 @@ | ||||||
| FROM golang:1.16-buster AS builder | FROM golang:1.16-buster AS builder | ||||||
| ARG VERSION |  | ||||||
| 
 | 
 | ||||||
| # Copy sources | # Copy sources | ||||||
| WORKDIR $GOPATH/src/github.com/oauth2-proxy/oauth2-proxy | WORKDIR $GOPATH/src/github.com/oauth2-proxy/oauth2-proxy | ||||||
|  | @ -11,6 +10,8 @@ RUN GO111MODULE=on go mod download | ||||||
| # Now pull in our code | # Now pull in our code | ||||||
| COPY . . | COPY . . | ||||||
| 
 | 
 | ||||||
|  | ARG VERSION | ||||||
|  | 
 | ||||||
| # Build binary and make sure there is at least an empty key file. | # Build binary and make sure there is at least an empty key file. | ||||||
| #  This is useful for GCP App Engine custom runtime builds, because | #  This is useful for GCP App Engine custom runtime builds, because | ||||||
| #  you cannot use multiline variables in their app.yaml, so you have to | #  you cannot use multiline variables in their app.yaml, so you have to | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue