Skip to content

Commit 389d5cd

Browse files
committed
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 <[email protected]>
1 parent 724c69f commit 389d5cd

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

.dockerignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
bundles
22
.gopath
33
vendor/pkg
4+
.go-pkg-cache

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
# a .bashrc may be added to customize the build environment
1111
.bashrc
1212
.gopath/
13+
.go-pkg-cache/
1314
autogen/
1415
bundles/
1516
cmd/dockerd/dockerd

Makefile

+10-2
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ DOCKER_ENVS := \
4141
BIND_DIR := $(if $(BINDDIR),$(BINDDIR),$(if $(DOCKER_HOST),,bundles))
4242
DOCKER_MOUNT := $(if $(BIND_DIR),-v "$(CURDIR)/$(BIND_DIR):/go/src/github.com/docker/docker/$(BIND_DIR)")
4343

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+
4449
# 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.
4550
# The volume will be cleaned up when the container is removed due to `--rm`.
4651
# 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
7277
binary: build ## build the linux binaries
7378
$(DOCKER_RUN_DOCKER) hack/make.sh binary
7479

75-
build: bundles
80+
build: bundles init-go-pkg-cache
7681
docker build ${DOCKER_BUILD_ARGS} -t "$(DOCKER_IMAGE)" -f "$(DOCKERFILE)" .
7782

78-
build-gccgo: bundles
83+
build-gccgo: bundles init-go-pkg-cache
7984
docker build ${DOCKER_BUILD_ARGS} -t "$(DOCKER_IMAGE)-gccgo" -f Dockerfile.gccgo .
8085

8186
bundles:
8287
mkdir bundles
8388

89+
init-go-pkg-cache:
90+
mkdir -p $(shell echo $(PKGCACHE_MAP) | sed -E 's@([^: ]*):[^ ]*@$(PKGCACHE_DIR)/\1@g')
91+
8492
cross: build ## cross build the binaries for darwin, freebsd and\nwindows
8593
$(DOCKER_RUN_DOCKER) hack/make.sh dynbinary binary cross
8694

0 commit comments

Comments
 (0)