Skip to content

Commit 2172c41

Browse files
committed
Cache go get dependencies
Running 'go get' after copying the source files causes us to re-build all dependencies on every source file change. If we instead specify our dependencies in install-dependencies.sh we can install and cache them before installing the source files. It's a ghetto approach, but greatly improves build times between tests.
1 parent b4e719c commit 2172c41

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

Dockerfile-test

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ FROM golang:1.8
22

33
WORKDIR /go/src/github.com/danihodovic/contentful-terraform
44

5-
COPY . /go/src/github.com/danihodovic/contentful-terraform
5+
# http://stackoverflow.com/questions/39278756/cache-go-get-in-docker-build
6+
COPY ./install-dependencies.sh /go/src/github.com/danihodovic/contentful-terraform/
7+
RUN ./install-dependencies.sh
68

7-
RUN go get
9+
COPY . /go/src/github.com/danihodovic/contentful-terraform
810

911
CMD go test -v

install-dependencies.sh

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env bash
2+
# Let's avoid rebuilding the dependencies each time a source file changes.
3+
# See: http://stackoverflow.com/questions/39278756/cache-go-get-in-docker-build
4+
go get github.com/hashicorp/terraform/terraform
5+
go get github.com/hashicorp/terraform/helper/resource
6+
go get github.com/hashicorp/terraform/helper/schema
7+
go get github.com/tolgaakyuz/contentful-go

0 commit comments

Comments
 (0)