From 88f08e86b00f1bd6148ec2da97d50c218f91bbce Mon Sep 17 00:00:00 2001 From: Adrian Lanzafame Date: Fri, 7 Sep 2018 12:08:17 +1000 Subject: [PATCH] speed up building docker image By using gx install --local, deps are copied into the build context and therefore only stale deps will get pulled from the network on image build. License: MIT Signed-off-by: Adrian Lanzafame --- .gitignore | 1 + Dockerfile | 2 +- Makefile | 11 +++++++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 53bc1d4a..f7c4f828 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ deptools sharness/lib/sharness sharness/test-results sharness/trash* +vendor/ raftFolderFromTest* peerstore diff --git a/Dockerfile b/Dockerfile index ef7621ee..79288761 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,7 +8,7 @@ ENV SRC_PATH $GOPATH/src/github.com/ipfs/ipfs-cluster COPY . $SRC_PATH WORKDIR $SRC_PATH -RUN make install +RUN make docker_install ENV SUEXEC_VERSION v0.2 ENV TINI_VERSION v0.16.1 diff --git a/Makefile b/Makefile index a8cfbc15..0d475caa 100644 --- a/Makefile +++ b/Makefile @@ -28,6 +28,10 @@ install: deps $(MAKE) -C ipfs-cluster-service install $(MAKE) -C ipfs-cluster-ctl install +docker_install: docker_deps + $(MAKE) -C ipfs-cluster-service install + $(MAKE) -C ipfs-cluster-ctl install + build: deps go build -ldflags "-X ipfscluster.Commit=$(shell git rev-parse HEAD)" $(MAKE) -C ipfs-cluster-service build @@ -64,6 +68,13 @@ deps: gx $(gx_bin) install --global $(gx-go_bin) rewrite +# Run this target before building the docker image +# and then gx won't attempt to pull all deps +# from the network each time +docker_deps: gx + $(gx_bin) install --local + $(gx-go_bin) rewrite + check: go vet ./... golint -set_exit_status -min_confidence 0.3 ./...