Docker build optimization
Update Dockefile to get a much smaller footprint with alpine image. Optimize ordering of build steps to avoid needless downloads. Include CA certificates needed for practical use.
This commit is contained in:
		
							parent
							
								
									2943da00e2
								
							
						
					
					
						commit
						cb41a91a65
					
				
							
								
								
									
										20
									
								
								Dockerfile
								
								
								
								
							
							
						
						
									
										20
									
								
								Dockerfile
								
								
								
								
							|  | @ -1,18 +1,22 @@ | |||
| FROM golang:1.11-stretch AS builder | ||||
| WORKDIR /go/src/github.com/pusher/oauth2_proxy | ||||
| 
 | ||||
| # Download tools | ||||
| RUN wget -O $GOPATH/bin/dep https://github.com/golang/dep/releases/download/v0.5.0/dep-linux-amd64 | ||||
| RUN chmod +x $GOPATH/bin/dep | ||||
| 
 | ||||
| # Copy sources | ||||
| WORKDIR $GOPATH/src/github.com/pusher/oauth2_proxy | ||||
| COPY . . | ||||
| 
 | ||||
| # Fetch dependencies | ||||
| RUN wget -O dep https://github.com/golang/dep/releases/download/v0.5.0/dep-linux-amd64 | ||||
| RUN chmod +x dep | ||||
| RUN mv dep $GOPATH/bin/dep | ||||
| RUN dep ensure --vendor-only | ||||
| 
 | ||||
| # Build image | ||||
| RUN ./configure && make clean oauth2_proxy | ||||
| # Build binary | ||||
| RUN ./configure && make build | ||||
| 
 | ||||
| # Copy binary to debian | ||||
| FROM debian:stretch | ||||
| # Copy binary to alpine | ||||
| FROM alpine:3.8 | ||||
| RUN apk add --no-cache ca-certificates | ||||
| COPY --from=builder /go/src/github.com/pusher/oauth2_proxy/oauth2_proxy /bin/oauth2_proxy | ||||
| 
 | ||||
| ENTRYPOINT ["/bin/oauth2_proxy"] | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue