Changes the default when incremental build is enabled to use named
volumes instead of bindmounts.
The reason for this is, on Mac/Windows the bind mounts will go over the
shared fs, which is incredibly slow and itself uses lots of CPU.
Makes an incremental build on OSX go from ~40s to 10s.
To get the old behavior, can set `PKGCACHE_DIR=.go-pkg-cache`
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
| ... | ... |
@@ -51,10 +51,11 @@ DOCKER_MOUNT := $(if $(BIND_DIR),-v "$(CURDIR)/$(BIND_DIR):/go/src/github.com/do |
| 51 | 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. |
| 52 | 52 |
DOCKER_MOUNT := $(if $(DOCKER_MOUNT),$(DOCKER_MOUNT),-v /go/src/github.com/docker/docker/bundles) |
| 53 | 53 |
|
| 54 |
-# enable .go-pkg-cache if DOCKER_INCREMENTAL_BINARY and DOCKER_MOUNT (i.e.DOCKER_HOST) are set |
|
| 55 |
-PKGCACHE_DIR := $(if $(PKGCACHE_DIR),$(PKGCACHE_DIR),.go-pkg-cache) |
|
| 54 |
+# enable package cache if DOCKER_INCREMENTAL_BINARY and DOCKER_MOUNT (i.e.DOCKER_HOST) are set |
|
| 56 | 55 |
PKGCACHE_MAP := gopath:/go/pkg goroot-linux_amd64_netgo:/usr/local/go/pkg/linux_amd64_netgo |
| 57 |
-DOCKER_MOUNT := $(if $(DOCKER_INCREMENTAL_BINARY),$(DOCKER_MOUNT) $(shell echo $(PKGCACHE_MAP) | sed -E 's@([^ ]*)@-v "$(CURDIR)/$(PKGCACHE_DIR)/\1"@g'),$(DOCKER_MOUNT)) |
|
| 56 |
+PKGCACHE_VOLROOT := dockerdev-go-pkg-cache |
|
| 57 |
+PKGCACHE_VOL := $(if $(PKGCACHE_DIR),$(CURDIR)/$(PKGCACHE_DIR)/,$(PKGCACHE_VOLROOT)-) |
|
| 58 |
+DOCKER_MOUNT := $(if $(DOCKER_INCREMENTAL_BINARY),$(DOCKER_MOUNT) $(shell echo $(PKGCACHE_MAP) | sed -E 's@([^ ]*)@-v "$(PKGCACHE_VOL)\1"@g'),$(DOCKER_MOUNT)) |
|
| 58 | 59 |
|
| 59 | 60 |
GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD 2>/dev/null) |
| 60 | 61 |
GIT_BRANCH_CLEAN := $(shell echo $(GIT_BRANCH) | sed -e "s/[^[:alnum:]]/-/g") |
| ... | ... |
@@ -89,6 +90,13 @@ build: bundles init-go-pkg-cache |
| 89 | 89 |
bundles: |
| 90 | 90 |
mkdir bundles |
| 91 | 91 |
|
| 92 |
+clean: clean-pkg-cache-vol ## clean up cached resources |
|
| 93 |
+ |
|
| 94 |
+clean-pkg-cache-vol: |
|
| 95 |
+ @- $(foreach mapping,$(PKGCACHE_MAP), \ |
|
| 96 |
+ $(shell docker volume rm $(PKGCACHE_VOLROOT)-$(shell echo $(mapping) | awk -F':/' '{ print $$1 }') > /dev/null 2>&1) \
|
|
| 97 |
+ ) |
|
| 98 |
+ |
|
| 92 | 99 |
cross: build ## cross build the binaries for darwin, freebsd and\nwindows |
| 93 | 100 |
$(DOCKER_RUN_DOCKER) hack/make.sh dynbinary binary cross |
| 94 | 101 |
|
| ... | ... |
@@ -100,7 +108,7 @@ help: ## this help |
| 100 | 100 |
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {sub("\\\\n",sprintf("\n%22c"," "), $$2);printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
|
| 101 | 101 |
|
| 102 | 102 |
init-go-pkg-cache: |
| 103 |
- mkdir -p $(shell echo $(PKGCACHE_MAP) | sed -E 's@([^: ]*):[^ ]*@$(PKGCACHE_DIR)/\1@g') |
|
| 103 |
+ $(if $(PKGCACHE_DIR), mkdir -p $(shell echo $(PKGCACHE_MAP) | sed -E 's@([^: ]*):[^ ]*@$(PKGCACHE_DIR)/\1@g')) |
|
| 104 | 104 |
|
| 105 | 105 |
install: ## install the linux binaries |
| 106 | 106 |
KEEPBUNDLE=1 hack/make.sh install-binary |