From b5dab1def43899cf661674399edcd80b28983dcd Mon Sep 17 00:00:00 2001 From: EXEC Date: Tue, 3 May 2022 17:17:24 +0800 Subject: [PATCH] docker: speed up docker image build (#24796) This PR improves the docker build speed for repeated builds where go.mod and go.sum do no change, by placing the downloaded dependencies in a lower layer --- Dockerfile | 5 +++++ Dockerfile.alltools | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/Dockerfile b/Dockerfile index 7badbc1320a4..5246f4d1bad3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,6 +8,11 @@ FROM golang:1.17-alpine as builder RUN apk add --no-cache gcc musl-dev linux-headers git +# Get dependencies - will also be cached if we won't change go.mod/go.sum +COPY go.mod /go-ethereum/ +COPY go.sum /go-ethereum/ +RUN cd /go-ethereum && go mod download + ADD . /go-ethereum RUN cd /go-ethereum && go run build/ci.go install ./cmd/geth diff --git a/Dockerfile.alltools b/Dockerfile.alltools index 3ae5377e4f36..73cb661b7fba 100644 --- a/Dockerfile.alltools +++ b/Dockerfile.alltools @@ -8,6 +8,11 @@ FROM golang:1.17-alpine as builder RUN apk add --no-cache gcc musl-dev linux-headers git +# Get dependencies - will also be cached if we won't change go.mod/go.sum +COPY go.mod /go-ethereum/ +COPY go.sum /go-ethereum/ +RUN cd /go-ethereum && go mod download + ADD . /go-ethereum RUN cd /go-ethereum && go run build/ci.go install