The cache was not used when we run `make binary` from the host.
Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
| ... | ... |
@@ -41,6 +41,11 @@ DOCKER_ENVS := \ |
| 41 | 41 |
BIND_DIR := $(if $(BINDDIR),$(BINDDIR),$(if $(DOCKER_HOST),,bundles)) |
| 42 | 42 |
DOCKER_MOUNT := $(if $(BIND_DIR),-v "$(CURDIR)/$(BIND_DIR):/go/src/github.com/docker/docker/$(BIND_DIR)") |
| 43 | 43 |
|
| 44 |
+# enable .go-pkg-cache if DOCKER_INCREMENTAL_BINARY and DOCKER_MOUNT (i.e.DOCKER_HOST) are set |
|
| 45 |
+PKGCACHE_DIR := $(if $(PKGCACHE_DIR),$(PKGCACHE_DIR),.go-pkg-cache) |
|
| 46 |
+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 |
|
| 47 |
+DOCKER_MOUNT := $(if $(DOCKER_INCREMENTAL_BINARY),$(DOCKER_MOUNT) $(shell echo $(PKGCACHE_MAP) | sed -E 's@([^ ]*)@-v "$(CURDIR)/$(PKGCACHE_DIR)/\1"@g'),$(DOCKER_MOUNT)) |
|
| 48 |
+ |
|
| 44 | 49 |
# 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. |
| 45 | 50 |
# The volume will be cleaned up when the container is removed due to `--rm`. |
| 46 | 51 |
# 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 |
| 72 | 72 |
binary: build ## build the linux binaries |
| 73 | 73 |
$(DOCKER_RUN_DOCKER) hack/make.sh binary |
| 74 | 74 |
|
| 75 |
-build: bundles |
|
| 75 |
+build: bundles init-go-pkg-cache |
|
| 76 | 76 |
docker build ${DOCKER_BUILD_ARGS} -t "$(DOCKER_IMAGE)" -f "$(DOCKERFILE)" .
|
| 77 | 77 |
|
| 78 |
-build-gccgo: bundles |
|
| 78 |
+build-gccgo: bundles init-go-pkg-cache |
|
| 79 | 79 |
docker build ${DOCKER_BUILD_ARGS} -t "$(DOCKER_IMAGE)-gccgo" -f Dockerfile.gccgo .
|
| 80 | 80 |
|
| 81 | 81 |
bundles: |
| 82 | 82 |
mkdir bundles |
| 83 | 83 |
|
| 84 |
+init-go-pkg-cache: |
|
| 85 |
+ mkdir -p $(shell echo $(PKGCACHE_MAP) | sed -E 's@([^: ]*):[^ ]*@$(PKGCACHE_DIR)/\1@g') |
|
| 86 |
+ |
|
| 84 | 87 |
cross: build ## cross build the binaries for darwin, freebsd and\nwindows |
| 85 | 88 |
$(DOCKER_RUN_DOCKER) hack/make.sh dynbinary binary cross |
| 86 | 89 |
|