Skip to content

Commit

Permalink
Use a go build cache to speed up builds.
Browse files Browse the repository at this point in the history
With a docker build cache already primed with the build image I am seeing
`time make build -f docker.Makefile DOCKER_BUILDKIT=1 GO_BUILD_CACHE=n` takes
more than 1 minute.

By contrast `time make build -f docker.Makefile DOCKER_BUILDKIT=1
GO_BUILD_CACHE=y` takes less than 10s with a hot cache irrespective of whether
the source tree has changed

Signed-off-by: Ian Campbell <ijc@docker.com>
  • Loading branch information
Ian Campbell committed Dec 11, 2018
1 parent 7c8ee78 commit d5de835
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions docker.Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ LINTER_IMAGE_NAME = docker-cli-lint$(IMAGE_TAG)
CROSS_IMAGE_NAME = docker-cli-cross$(IMAGE_TAG)
VALIDATE_IMAGE_NAME = docker-cli-shell-validate$(IMAGE_TAG)
E2E_IMAGE_NAME = docker-cli-e2e$(IMAGE_TAG)
GO_BUILD_CACHE ?= y
MOUNTS = -v "$(CURDIR)":/go/src/github.com/docker/cli
CACHE_VOLUME_NAME := docker-cli-dev-cache
ifeq ($(GO_BUILD_CACHE),y)
MOUNTS += -v "$(CACHE_VOLUME_NAME):/root/.cache/go-build"
endif
VERSION = $(shell cat VERSION)
ENVVARS = -e VERSION=$(VERSION) -e GITCOMMIT -e PLATFORM

Expand Down Expand Up @@ -49,6 +54,7 @@ build: binary ## alias for binary
.PHONY: clean
clean: build_docker_image ## clean build artifacts
docker run --rm $(ENVVARS) $(MOUNTS) $(DEV_DOCKER_IMAGE_NAME) make clean
docker volume rm -f $(CACHE_VOLUME_NAME)

.PHONY: test-unit
test-unit: build_docker_image # run unit tests (using go test)
Expand Down

0 comments on commit d5de835

Please sign in to comment.