github.com/devdivbcp/moby@v17.12.0-ce-rc1.0.20200726071732-2d4bfdc789ad+incompatible/Makefile (about) 1 .PHONY: all binary dynbinary build cross help install manpages run shell test test-docker-py test-integration test-unit 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 7 # enable/disable cross-compile 8 DOCKER_CROSS ?= false 9 10 # get OS/Arch of docker engine 11 DOCKER_OSARCH := $(shell bash -c 'source hack/make/.detect-daemon-osarch && echo $${DOCKER_ENGINE_OSARCH}') 12 DOCKERFILE := $(shell bash -c 'source hack/make/.detect-daemon-osarch && echo $${DOCKERFILE}') 13 14 DOCKER_GITCOMMIT := $(shell git rev-parse --short HEAD || echo unsupported) 15 export DOCKER_GITCOMMIT 16 17 # allow overriding the repository and branch that validation scripts are running 18 # against these are used in hack/validate/.validate to check what changed in the PR. 19 export VALIDATE_REPO 20 export VALIDATE_BRANCH 21 export VALIDATE_ORIGIN_BRANCH 22 23 # env vars passed through directly to Docker's build scripts 24 # to allow things like `make KEEPBUNDLE=1 binary` easily 25 # `project/PACKAGERS.md` have some limited documentation of some of these 26 # 27 # DOCKER_LDFLAGS can be used to pass additional parameters to -ldflags 28 # option of "go build". For example, a built-in graphdriver priority list 29 # can be changed during build time like this: 30 # 31 # make DOCKER_LDFLAGS="-X github.com/docker/docker/daemon/graphdriver.priority=overlay2,devicemapper" dynbinary 32 # 33 DOCKER_ENVS := \ 34 -e DOCKER_CROSSPLATFORMS \ 35 -e BUILD_APT_MIRROR \ 36 -e BUILDFLAGS \ 37 -e KEEPBUNDLE \ 38 -e DOCKER_BUILD_ARGS \ 39 -e DOCKER_BUILD_GOGC \ 40 -e DOCKER_BUILD_OPTS \ 41 -e DOCKER_BUILD_PKGS \ 42 -e DOCKER_BUILDKIT \ 43 -e DOCKER_BASH_COMPLETION_PATH \ 44 -e DOCKER_CLI_PATH \ 45 -e DOCKER_DEBUG \ 46 -e DOCKER_EXPERIMENTAL \ 47 -e DOCKER_GITCOMMIT \ 48 -e DOCKER_GRAPHDRIVER \ 49 -e DOCKER_LDFLAGS \ 50 -e DOCKER_PORT \ 51 -e DOCKER_REMAP_ROOT \ 52 -e DOCKER_STORAGE_OPTS \ 53 -e DOCKER_TEST_HOST \ 54 -e DOCKER_USERLANDPROXY \ 55 -e DOCKERD_ARGS \ 56 -e TEST_INTEGRATION_DIR \ 57 -e TEST_SKIP_INTEGRATION \ 58 -e TEST_SKIP_INTEGRATION_CLI \ 59 -e TESTDEBUG \ 60 -e TESTDIRS \ 61 -e TESTFLAGS \ 62 -e TESTFLAGS_INTEGRATION \ 63 -e TESTFLAGS_INTEGRATION_CLI \ 64 -e TEST_FILTER \ 65 -e TIMEOUT \ 66 -e VALIDATE_REPO \ 67 -e VALIDATE_BRANCH \ 68 -e VALIDATE_ORIGIN_BRANCH \ 69 -e HTTP_PROXY \ 70 -e HTTPS_PROXY \ 71 -e NO_PROXY \ 72 -e http_proxy \ 73 -e https_proxy \ 74 -e no_proxy \ 75 -e VERSION \ 76 -e PLATFORM \ 77 -e DEFAULT_PRODUCT_LICENSE \ 78 -e PRODUCT 79 # 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 80 81 # to allow `make BIND_DIR=. shell` or `make BIND_DIR= test` 82 # (default to no bind mount if DOCKER_HOST is set) 83 # note: BINDDIR is supported for backwards-compatibility here 84 BIND_DIR := $(if $(BINDDIR),$(BINDDIR),$(if $(DOCKER_HOST),,bundles)) 85 86 # DOCKER_MOUNT can be overriden, but use at your own risk! 87 ifndef DOCKER_MOUNT 88 DOCKER_MOUNT := $(if $(BIND_DIR),-v "$(CURDIR)/$(BIND_DIR):/go/src/github.com/docker/docker/$(BIND_DIR)") 89 DOCKER_MOUNT := $(if $(DOCKER_BINDDIR_MOUNT_OPTS),$(DOCKER_MOUNT):$(DOCKER_BINDDIR_MOUNT_OPTS),$(DOCKER_MOUNT)) 90 91 # 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. 92 # The volume will be cleaned up when the container is removed due to `--rm`. 93 # 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. 94 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" 95 96 DOCKER_MOUNT_CACHE := -v docker-dev-cache:/root/.cache 97 DOCKER_MOUNT_CLI := $(if $(DOCKER_CLI_PATH),-v $(shell dirname $(DOCKER_CLI_PATH)):/usr/local/cli,) 98 DOCKER_MOUNT_BASH_COMPLETION := $(if $(DOCKER_BASH_COMPLETION_PATH),-v $(shell dirname $(DOCKER_BASH_COMPLETION_PATH)):/usr/local/completion/bash,) 99 DOCKER_MOUNT := $(DOCKER_MOUNT) $(DOCKER_MOUNT_CACHE) $(DOCKER_MOUNT_CLI) $(DOCKER_MOUNT_BASH_COMPLETION) 100 endif # ifndef DOCKER_MOUNT 101 102 # This allows to set the docker-dev container name 103 DOCKER_CONTAINER_NAME := $(if $(CONTAINER_NAME),--name $(CONTAINER_NAME),) 104 105 GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD 2>/dev/null) 106 GIT_BRANCH_CLEAN := $(shell echo $(GIT_BRANCH) | sed -e "s/[^[:alnum:]]/-/g") 107 DOCKER_IMAGE := docker-dev$(if $(GIT_BRANCH_CLEAN),:$(GIT_BRANCH_CLEAN)) 108 DOCKER_PORT_FORWARD := $(if $(DOCKER_PORT),-p "$(DOCKER_PORT)",) 109 110 DOCKER_FLAGS := docker run --rm -i --privileged $(DOCKER_CONTAINER_NAME) $(DOCKER_ENVS) $(DOCKER_MOUNT) $(DOCKER_PORT_FORWARD) 111 BUILD_APT_MIRROR := $(if $(DOCKER_BUILD_APT_MIRROR),--build-arg APT_MIRROR=$(DOCKER_BUILD_APT_MIRROR)) 112 export BUILD_APT_MIRROR 113 114 SWAGGER_DOCS_PORT ?= 9000 115 116 define \n 117 118 119 endef 120 121 # if this session isn't interactive, then we don't want to allocate a 122 # TTY, which would fail, but if it is interactive, we do want to attach 123 # so that the user can send e.g. ^C through. 124 INTERACTIVE := $(shell [ -t 0 ] && echo 1 || echo 0) 125 ifeq ($(INTERACTIVE), 1) 126 DOCKER_FLAGS += -t 127 endif 128 129 DOCKER_RUN_DOCKER := $(DOCKER_FLAGS) "$(DOCKER_IMAGE)" 130 131 default: binary 132 133 all: build ## validate all checks, build linux binaries, run all tests\ncross build non-linux binaries and generate archives 134 $(DOCKER_RUN_DOCKER) bash -c 'hack/validate/default && hack/make.sh' 135 136 binary: build ## build the linux binaries 137 $(DOCKER_RUN_DOCKER) hack/make.sh binary 138 139 dynbinary: build ## build the linux dynbinaries 140 $(DOCKER_RUN_DOCKER) hack/make.sh dynbinary 141 142 143 144 cross: DOCKER_CROSS := true 145 cross: build ## cross build the binaries for darwin, freebsd and\nwindows 146 $(DOCKER_RUN_DOCKER) hack/make.sh dynbinary binary cross 147 148 ifdef DOCKER_CROSSPLATFORMS 149 build: DOCKER_CROSS := true 150 endif 151 ifeq ($(BIND_DIR), .) 152 build: DOCKER_BUILD_OPTS += --target=dev 153 endif 154 build: DOCKER_BUILD_ARGS += --build-arg=CROSS=$(DOCKER_CROSS) 155 build: DOCKER_BUILDKIT ?= 1 156 build: bundles 157 $(warning The docker client CLI has moved to github.com/docker/cli. For a dev-test cycle involving the CLI, run:${\n} DOCKER_CLI_PATH=/host/path/to/cli/binary make shell ${\n} then change the cli and compile into a binary at the same location.${\n}) 158 DOCKER_BUILDKIT="${DOCKER_BUILDKIT}" docker build --build-arg=GO_VERSION ${BUILD_APT_MIRROR} ${DOCKER_BUILD_ARGS} ${DOCKER_BUILD_OPTS} -t "$(DOCKER_IMAGE)" -f "$(DOCKERFILE)" . 159 160 bundles: 161 mkdir bundles 162 163 .PHONY: clean 164 clean: clean-cache 165 166 .PHONY: clean-cache 167 clean-cache: 168 docker volume rm -f docker-dev-cache 169 170 help: ## this help 171 @awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z0-9_-]+:.*?## / {gsub("\\\\n",sprintf("\n%22c",""), $$2);printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) 172 173 install: ## install the linux binaries 174 KEEPBUNDLE=1 hack/make.sh install-binary 175 176 run: build ## run the docker daemon in a container 177 $(DOCKER_RUN_DOCKER) sh -c "KEEPBUNDLE=1 hack/make.sh install-binary run" 178 179 shell: build ## start a shell inside the build env 180 $(DOCKER_RUN_DOCKER) bash 181 182 test: build test-unit ## run the unit, integration and docker-py tests 183 $(DOCKER_RUN_DOCKER) hack/make.sh dynbinary cross test-integration test-docker-py 184 185 test-docker-py: build ## run the docker-py tests 186 $(DOCKER_RUN_DOCKER) hack/make.sh dynbinary test-docker-py 187 188 test-integration-cli: test-integration ## (DEPRECATED) use test-integration 189 190 ifneq ($(and $(TEST_SKIP_INTEGRATION),$(TEST_SKIP_INTEGRATION_CLI)),) 191 test-integration: 192 @echo Both integrations suites skipped per environment variables 193 else 194 test-integration: build ## run the integration tests 195 $(DOCKER_RUN_DOCKER) hack/make.sh dynbinary test-integration 196 endif 197 198 test-integration-flaky: build ## run the stress test for all new integration tests 199 $(DOCKER_RUN_DOCKER) hack/make.sh dynbinary test-integration-flaky 200 201 test-unit: build ## run the unit tests 202 $(DOCKER_RUN_DOCKER) hack/test/unit 203 204 validate: build ## validate DCO, Seccomp profile generation, gofmt,\n./pkg/ isolation, golint, tests, tomls, go vet and vendor 205 $(DOCKER_RUN_DOCKER) hack/validate/all 206 207 win: build ## cross build the binary for windows 208 $(DOCKER_RUN_DOCKER) DOCKER_CROSSPLATFORMS=windows/amd64 hack/make.sh cross 209 210 .PHONY: swagger-gen 211 swagger-gen: 212 docker run --rm -v $(PWD):/go/src/github.com/docker/docker \ 213 -w /go/src/github.com/docker/docker \ 214 --entrypoint hack/generate-swagger-api.sh \ 215 -e GOPATH=/go \ 216 quay.io/goswagger/swagger:0.7.4 217 218 .PHONY: swagger-docs 219 swagger-docs: ## preview the API documentation 220 @echo "API docs preview will be running at http://localhost:$(SWAGGER_DOCS_PORT)" 221 @docker run --rm -v $(PWD)/api/swagger.yaml:/usr/share/nginx/html/swagger.yaml \ 222 -e 'REDOC_OPTIONS=hide-hostname="true" lazy-rendering' \ 223 -p $(SWAGGER_DOCS_PORT):80 \ 224 bfirsh/redoc:1.6.2