optimize dockerfile caching for go builds

Signed-off-by: Ahmet Alp Balkan <ahmetb@google.com>
This commit is contained in:
Ahmet Alp Balkan 2018-06-28 17:09:22 -07:00
parent 9728803877
commit 07bb077c10
3 changed files with 18 additions and 0 deletions

View file

@ -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 .

View file

@ -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 .

View file

@ -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 .