From 491d779d58b8e8e546aad401fd2da45a1afa0af3 Mon Sep 17 00:00:00 2001 From: Arijit Das Date: Thu, 10 Jun 2021 13:12:40 +0530 Subject: [PATCH] Optimize docker build. --- Dockerfile | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index a7c72db7..3073375d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,8 +6,17 @@ RUN apk add busybox-extras # Build ipld-eth-server WORKDIR /go/src/github.com/vulcanize/ipld-eth-server -ADD . . -RUN GO111MODULE=on GCO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -ldflags '-extldflags "-static"' -o ipld-eth-server . + +# Cache the modules +ENV GO111MODULE=on +COPY go.mod . +COPY go.sum . +RUN go mod download + +COPY . . + +# Build the binary +RUN GCO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -ldflags '-extldflags "-static"' -o ipld-eth-server . # Copy migration tool WORKDIR /