github.com/fabiokung/docker@v0.11.2-0.20170222101415-4534dcd49497/Makefile (about) 1 .PHONY: all binary build cross deb help init-go-pkg-cache install manpages rpm run shell test test-docker-py test-integration-cli test-unit tgz validate win 2 3 # set the graph driver as the current graphdriver if not set 4 DOCKER_GRAPHDRIVER := $(if $(DOCKER_GRAPHDRIVER),$(DOCKER_GRAPHDRIVER),$(shell docker info 2>&1 | grep "Storage Driver" | sed 's/.*: //')) 5 export DOCKER_GRAPHDRIVER 6 DOCKER_INCREMENTAL_BINARY := $(if $(DOCKER_INCREMENTAL_BINARY),$(DOCKER_INCREMENTAL_BINARY),1) 7 export DOCKER_INCREMENTAL_BINARY 8 9 # get OS/Arch of docker engine 10 DOCKER_OSARCH := $(shell bash -c 'source hack/make/.detect-daemon-osarch && echo $${DOCKER_ENGINE_OSARCH:-$$DOCKER_CLIENT_OSARCH}') 11 DOCKERFILE := $(shell bash -c 'source hack/make/.detect-daemon-osarch && echo $${DOCKERFILE}') 12 13 DOCKER_GITCOMMIT := $(shell git rev-parse --short HEAD || echo unsupported) 14 export DOCKER_GITCOMMIT 15 16 # env vars passed through directly to Docker's build scripts 17 # to allow things like `make KEEPBUNDLE=1 binary` easily 18 # `project/PACKAGERS.md` have some limited documentation of some of these 19 DOCKER_ENVS := \ 20 -e BUILD_APT_MIRROR \ 21 -e BUILDFLAGS \ 22 -e KEEPBUNDLE \ 23 -e DOCKER_BUILD_ARGS \ 24 -e DOCKER_BUILD_GOGC \ 25 -e DOCKER_BUILD_PKGS \ 26 -e DOCKER_DEBUG \ 27 -e DOCKER_EXPERIMENTAL \ 28 -e DOCKER_GITCOMMIT \ 29 -e DOCKER_GRAPHDRIVER \ 30 -e DOCKER_INCREMENTAL_BINARY \ 31 -e DOCKER_PORT \ 32 -e DOCKER_REMAP_ROOT \ 33 -e DOCKER_STORAGE_OPTS \ 34 -e DOCKER_USERLANDPROXY \ 35 -e TESTDIRS \ 36 -e TESTFLAGS \ 37 -e TIMEOUT \ 38 -e HTTP_PROXY \ 39 -e HTTPS_PROXY \ 40 -e NO_PROXY \ 41 -e http_proxy \ 42 -e https_proxy \ 43 -e no_proxy 44 # note: we _cannot_ add "-e DOCKER_BUILDTAGS" here because even if it's unset in the shell, that would shadow the "ENV DOCKER_BUILDTAGS" set in our Dockerfile, which is very important for our official builds 45 46 # to allow `make BIND_DIR=. shell` or `make BIND_DIR= test` 47 # (default to no bind mount if DOCKER_HOST is set) 48 # note: BINDDIR is supported for backwards-compatibility here 49 BIND_DIR := $(if $(BINDDIR),$(BINDDIR),$(if $(DOCKER_HOST),,bundles)) 50 DOCKER_MOUNT := $(if $(BIND_DIR),-v "$(CURDIR)/$(BIND_DIR):/go/src/github.com/docker/docker/$(BIND_DIR)") 51 52 # 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. 53 # The volume will be cleaned up when the container is removed due to `--rm`. 54 # 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. 55 DOCKER_MOUNT := $(if $(DOCKER_MOUNT),$(DOCKER_MOUNT),-v /go/src/github.com/docker/docker/bundles) -v $(CURDIR)/.git:/go/src/github.com/docker/docker/.git 56 57 # This allows to set the docker-dev container name 58 DOCKER_CONTAINER_NAME := $(if $(CONTAINER_NAME),--name $(CONTAINER_NAME),) 59 60 # enable package cache if DOCKER_INCREMENTAL_BINARY and DOCKER_MOUNT (i.e.DOCKER_HOST) are set 61 PKGCACHE_MAP := gopath:/go/pkg goroot-linux_amd64_netgo:/usr/local/go/pkg/linux_amd64_netgo 62 PKGCACHE_VOLROOT := dockerdev-go-pkg-cache 63 PKGCACHE_VOL := $(if $(PKGCACHE_DIR),$(CURDIR)/$(PKGCACHE_DIR)/,$(PKGCACHE_VOLROOT)-) 64 DOCKER_MOUNT := $(if $(DOCKER_INCREMENTAL_BINARY),$(DOCKER_MOUNT) $(shell echo $(PKGCACHE_MAP) | sed -E 's@([^ ]*)@-v "$(PKGCACHE_VOL)\1"@g'),$(DOCKER_MOUNT)) 65 66 GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD 2>/dev/null) 67 GIT_BRANCH_CLEAN := $(shell echo $(GIT_BRANCH) | sed -e "s/[^[:alnum:]]/-/g") 68 DOCKER_IMAGE := docker-dev$(if $(GIT_BRANCH_CLEAN),:$(GIT_BRANCH_CLEAN)) 69 DOCKER_PORT_FORWARD := $(if $(DOCKER_PORT),-p "$(DOCKER_PORT)",) 70 71 DOCKER_FLAGS := docker run --rm -i --privileged $(DOCKER_CONTAINER_NAME) $(DOCKER_ENVS) $(DOCKER_MOUNT) $(DOCKER_PORT_FORWARD) 72 BUILD_APT_MIRROR := $(if $(DOCKER_BUILD_APT_MIRROR),--build-arg APT_MIRROR=$(DOCKER_BUILD_APT_MIRROR)) 73 export BUILD_APT_MIRROR 74 75 SWAGGER_DOCS_PORT ?= 9000 76 77 # if this session isn't interactive, then we don't want to allocate a 78 # TTY, which would fail, but if it is interactive, we do want to attach 79 # so that the user can send e.g. ^C through. 80 INTERACTIVE := $(shell [ -t 0 ] && echo 1 || echo 0) 81 ifeq ($(INTERACTIVE), 1) 82 DOCKER_FLAGS += -t 83 endif 84 85 DOCKER_RUN_DOCKER := $(DOCKER_FLAGS) "$(DOCKER_IMAGE)" 86 87 default: binary 88 89 all: build ## validate all checks, build linux binaries, run all tests\ncross build non-linux binaries and generate archives 90 $(DOCKER_RUN_DOCKER) bash -c 'hack/validate/default && hack/make.sh' 91 92 binary: build ## build the linux binaries 93 $(DOCKER_RUN_DOCKER) hack/make.sh binary 94 95 build: bundles init-go-pkg-cache 96 docker build ${BUILD_APT_MIRROR} ${DOCKER_BUILD_ARGS} -t "$(DOCKER_IMAGE)" -f "$(DOCKERFILE)" . 97 98 bundles: 99 mkdir bundles 100 101 clean: clean-pkg-cache-vol ## clean up cached resources 102 103 clean-pkg-cache-vol: 104 @- $(foreach mapping,$(PKGCACHE_MAP), \ 105 $(shell docker volume rm $(PKGCACHE_VOLROOT)-$(shell echo $(mapping) | awk -F':/' '{ print $$1 }') > /dev/null 2>&1) \ 106 ) 107 108 cross: build ## cross build the binaries for darwin, freebsd and\nwindows 109 $(DOCKER_RUN_DOCKER) hack/make.sh dynbinary binary cross 110 111 deb: build ## build the deb packages 112 $(DOCKER_RUN_DOCKER) hack/make.sh dynbinary build-deb 113 114 115 help: ## this help 116 @awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {sub("\\\\n",sprintf("\n%22c"," "), $$2);printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) 117 118 init-go-pkg-cache: 119 $(if $(PKGCACHE_DIR), mkdir -p $(shell echo $(PKGCACHE_MAP) | sed -E 's@([^: ]*):[^ ]*@$(PKGCACHE_DIR)/\1@g')) 120 121 install: ## install the linux binaries 122 KEEPBUNDLE=1 hack/make.sh install-binary 123 124 manpages: ## Generate man pages from go source and markdown 125 docker build ${DOCKER_BUILD_ARGS} -t docker-manpage-dev -f "man/$(DOCKERFILE)" ./man 126 docker run --rm \ 127 -v $(PWD):/go/src/github.com/docker/docker/ \ 128 docker-manpage-dev 129 130 rpm: build ## build the rpm packages 131 $(DOCKER_RUN_DOCKER) hack/make.sh dynbinary build-rpm 132 133 run: build ## run the docker daemon in a container 134 $(DOCKER_RUN_DOCKER) sh -c "KEEPBUNDLE=1 hack/make.sh install-binary run" 135 136 shell: build ## start a shell inside the build env 137 $(DOCKER_RUN_DOCKER) bash 138 139 test: build ## run the unit, integration and docker-py tests 140 $(DOCKER_RUN_DOCKER) hack/make.sh dynbinary cross test-unit test-integration-cli test-docker-py 141 142 test-docker-py: build ## run the docker-py tests 143 $(DOCKER_RUN_DOCKER) hack/make.sh dynbinary test-docker-py 144 145 test-integration-cli: build ## run the integration tests 146 $(DOCKER_RUN_DOCKER) hack/make.sh build-integration-test-binary dynbinary test-integration-cli 147 148 test-unit: build ## run the unit tests 149 $(DOCKER_RUN_DOCKER) hack/make.sh test-unit 150 151 tgz: build ## build the archives (.zip on windows and .tgz\notherwise) containing the binaries 152 $(DOCKER_RUN_DOCKER) hack/make.sh dynbinary binary cross tgz 153 154 validate: build ## validate DCO, Seccomp profile generation, gofmt,\n./pkg/ isolation, golint, tests, tomls, go vet and vendor 155 $(DOCKER_RUN_DOCKER) hack/validate/all 156 157 win: build ## cross build the binary for windows 158 $(DOCKER_RUN_DOCKER) hack/make.sh win 159 160 .PHONY: swagger-gen 161 swagger-gen: 162 docker run --rm -v $(PWD):/go/src/github.com/docker/docker \ 163 -w /go/src/github.com/docker/docker \ 164 --entrypoint hack/generate-swagger-api.sh \ 165 -e GOPATH=/go \ 166 quay.io/goswagger/swagger:0.7.4 167 168 .PHONY: swagger-docs 169 swagger-docs: ## preview the API documentation 170 @echo "API docs preview will be running at http://localhost:$(SWAGGER_DOCS_PORT)" 171 @docker run --rm -v $(PWD)/api/swagger.yaml:/usr/share/nginx/html/swagger.yaml \ 172 -e 'REDOC_OPTIONS=hide-hostname="true" lazy-rendering' \ 173 -p $(SWAGGER_DOCS_PORT):80 \ 174 bfirsh/redoc:1.6.2