optimize dockerfile caching for go builds
Signed-off-by: Ahmet Alp Balkan <ahmetb@google.com>
This commit is contained in:
		
							parent
							
								
									9728803877
								
							
						
					
					
						commit
						07bb077c10
					
				
					 3 changed files with 18 additions and 0 deletions
				
			
		|  | @ -1,7 +1,14 @@ | |||
| FROM golang:1.10-alpine as builder | ||||
| RUN apk add --no-cache ca-certificates git | ||||
| WORKDIR /go/src/checkoutservice | ||||
| 
 | ||||
| # get known dependencies | ||||
| RUN go get -d github.com/google/uuid \ | ||||
|     google.golang.org/grpc \ | ||||
|     google.golang.org/grpc/codes \ | ||||
|     google.golang.org/grpc/status | ||||
| COPY . . | ||||
| # get remaining dependencies | ||||
| RUN go get -d ./... | ||||
| RUN go build -o /checkoutservice . | ||||
| 
 | ||||
|  |  | |||
|  | @ -3,7 +3,13 @@ RUN apk add --no-cache \ | |||
|   ca-certificates \ | ||||
|   git | ||||
| WORKDIR /src/microservices-demo/productcatalogservice | ||||
| # get known dependencies | ||||
| RUN go get -d google.golang.org/grpc \ | ||||
|     google.golang.org/grpc/codes \ | ||||
|     google.golang.org/grpc/status | ||||
| 
 | ||||
| COPY . . | ||||
| # get remaining dependencies | ||||
| RUN go get -d ./... | ||||
| RUN go build -o /productcatalogservice . | ||||
| 
 | ||||
|  |  | |||
|  | @ -3,7 +3,12 @@ RUN apk add --no-cache \ | |||
|   ca-certificates \ | ||||
|   git | ||||
| WORKDIR /src/microservices-demo/shippingservice | ||||
| # get known dependencies | ||||
| RUN go get -d golang.org/x/net/context \ | ||||
| google.golang.org/grpc \ | ||||
| google.golang.org/grpc/reflection | ||||
| COPY . . | ||||
| # get other dependencies | ||||
| RUN go get -d ./... | ||||
| RUN go build -o /shippingservice . | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue