From 389d5cde7b5474cd33d251aadc96be1f0bdbc711 Mon Sep 17 00:00:00 2001 From: Akihiro Suda Date: Mon, 27 Jun 2016 09:19:48 +0000 Subject: [PATCH] mount .go-pkg-cache for DOCKER_INCREMENTAL_BINARY The cache was not used when we run `make binary` from the host. Signed-off-by: Akihiro Suda --- .dockerignore | 1 + .gitignore | 1 + Makefile | 12 ++++++++++-- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/.dockerignore b/.dockerignore index 9bd2c02193..082cac9224 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,3 +1,4 @@ bundles .gopath vendor/pkg +.go-pkg-cache diff --git a/.gitignore b/.gitignore index 43aa9227e2..0f082f5290 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ # a .bashrc may be added to customize the build environment .bashrc .gopath/ +.go-pkg-cache/ autogen/ bundles/ cmd/dockerd/dockerd diff --git a/Makefile b/Makefile index 8e28b8013e..7ece10182c 100644 --- a/Makefile +++ b/Makefile @@ -41,6 +41,11 @@ DOCKER_ENVS := \ BIND_DIR := $(if $(BINDDIR),$(BINDDIR),$(if $(DOCKER_HOST),,bundles)) DOCKER_MOUNT := $(if $(BIND_DIR),-v "$(CURDIR)/$(BIND_DIR):/go/src/github.com/docker/docker/$(BIND_DIR)") +# enable .go-pkg-cache if DOCKER_INCREMENTAL_BINARY and DOCKER_MOUNT (i.e.DOCKER_HOST) are set +PKGCACHE_DIR := $(if $(PKGCACHE_DIR),$(PKGCACHE_DIR),.go-pkg-cache) +PKGCACHE_MAP := gopath:/go/pkg vendor:/go/src/github.com/docker/docker/vendor/pkg goroot-linux_amd64_netgo:/usr/local/go/pkg/linux_amd64_netgo +DOCKER_MOUNT := $(if $(DOCKER_INCREMENTAL_BINARY),$(DOCKER_MOUNT) $(shell echo $(PKGCACHE_MAP) | sed -E 's@([^ ]*)@-v "$(CURDIR)/$(PKGCACHE_DIR)/\1"@g'),$(DOCKER_MOUNT)) + # This allows the test suite to be able to run without worrying about the underlying fs used by the container running the daemon (e.g. aufs-on-aufs), so long as the host running the container is running a supported fs. # The volume will be cleaned up when the container is removed due to `--rm`. # Note that `BIND_DIR` will already be set to `bundles` if `DOCKER_HOST` is not set (see above BIND_DIR line), in such case this will do nothing since `DOCKER_MOUNT` will already be set. @@ -72,15 +77,18 @@ all: build ## validate all checks, build linux binaries, run all tests\ncross bu binary: build ## build the linux binaries $(DOCKER_RUN_DOCKER) hack/make.sh binary -build: bundles +build: bundles init-go-pkg-cache docker build ${DOCKER_BUILD_ARGS} -t "$(DOCKER_IMAGE)" -f "$(DOCKERFILE)" . -build-gccgo: bundles +build-gccgo: bundles init-go-pkg-cache docker build ${DOCKER_BUILD_ARGS} -t "$(DOCKER_IMAGE)-gccgo" -f Dockerfile.gccgo . bundles: mkdir bundles +init-go-pkg-cache: + mkdir -p $(shell echo $(PKGCACHE_MAP) | sed -E 's@([^: ]*):[^ ]*@$(PKGCACHE_DIR)/\1@g') + cross: build ## cross build the binaries for darwin, freebsd and\nwindows $(DOCKER_RUN_DOCKER) hack/make.sh dynbinary binary cross