From 92274f4ff48e38f5d1d843c8816cc896da5fba11 Mon Sep 17 00:00:00 2001 From: Ahmet Alp Balkan Date: Thu, 28 Jun 2018 18:46:58 -0700 Subject: [PATCH] frontend: optimize dockerfile Signed-off-by: Ahmet Alp Balkan --- src/frontend/Dockerfile | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/frontend/Dockerfile b/src/frontend/Dockerfile index 61e1604..4b48d10 100644 --- a/src/frontend/Dockerfile +++ b/src/frontend/Dockerfile @@ -1,23 +1,29 @@ FROM golang:1.10-alpine as builder RUN apk add --no-cache ca-certificates git WORKDIR /go/src/frontend -COPY . . -# download known dependencies +# fetch known dependencies for caching RUN go get -d github.com/google/uuid \ github.com/gorilla/mux \ google.golang.org/grpc \ google.golang.org/grpc/codes \ google.golang.org/grpc/status -# other dependencies might not have listed above +# copy go-only part of the build +COPY *.go ./ +COPY ./genproto ./genproto +COPY ./money ./money + +# fetch other dependencies might not have listed above (ideally noop) RUN go get -d ./... -RUN go build -o /frontend . +RUN go install . + +# --- FROM alpine as release RUN apk add --no-cache ca-certificates WORKDIR /frontend -COPY --from=builder /frontend /frontend/server +COPY --from=builder /go/bin/frontend /frontend/server COPY ./templates ./templates COPY ./static ./static EXPOSE 8080