github.com/dddengyunjie/fabric-ca@v0.0.0-20190606043049-92df60ae2f0f/docker-env.mk (about) 1 # Copyright London Stock Exchange Group All Rights Reserved. 2 # 3 # Licensed under the Apache License, Version 2.0 (the "License"); 4 # you may not use this file except in compliance with the License. 5 # You may obtain a copy of the License at 6 # 7 # http://www.apache.org/licenses/LICENSE-2.0 8 # 9 # Unless required by applicable law or agreed to in writing, software 10 # distributed under the License is distributed on an "AS IS" BASIS, 11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 # See the License for the specific language governing permissions and 13 # limitations under the License. 14 15 ifneq ($(shell uname),Darwin) 16 DOCKER_RUN_FLAGS=--user=$(shell id -u) 17 endif 18 19 ifneq ($(http_proxy),) 20 DOCKER_BUILD_FLAGS+=--build-arg http_proxy=$(http_proxy) 21 DOCKER_RUN_FLAGS+=-e http_proxy=$(http_proxy) 22 endif 23 ifneq ($(https_proxy),) 24 DOCKER_BUILD_FLAGS+=--build-arg https_proxy=$(https_proxy) 25 DOCKER_RUN_FLAGS+=-e https_proxy=$(https_proxy) 26 endif 27 ifneq ($(HTTP_PROXY),) 28 DOCKER_BUILD_FLAGS+=--build-arg HTTP_PROXY=$(HTTP_PROXY) 29 DOCKER_RUN_FLAGS+=-e HTTP_PROXY=$(HTTP_PROXY) 30 endif 31 ifneq ($(HTTPS_PROXY),) 32 DOCKER_BUILD_FLAGS+=--build-arg HTTPS_PROXY=$(HTTPS_PROXY) 33 DOCKER_RUN_FLAGS+=-e HTTPS_PROXY=$(HTTPS_PROXY) 34 endif 35 ifneq ($(no_proxy),) 36 DOCKER_BUILD_FLAGS+=--build-arg no_proxy=$(no_proxy) 37 DOCKER_RUN_FLAGS+=-e no_proxy=$(no_proxy) 38 endif 39 ifneq ($(NO_PROXY),) 40 DOCKER_BUILD_FLAGS+=--build-arg NO_PROXY=$(NO_PROXY) 41 DOCKER_RUN_FLAGS+=-e NO_PROXY=$(NO_PROXY) 42 endif 43 44 DRUN = docker run -i --rm $(DOCKER_RUN_FLAGS) \ 45 -v $(abspath .):/opt/gopath/src/$(PKGNAME) \ 46 -w /opt/gopath/src/$(PKGNAME) 47 48 DBUILD = docker build $(DOCKER_BUILD_FLAGS) 49 50 BASE_DOCKER_NS ?= hyperledger 51 BASE_DOCKER_TAG=$(ARCH)-$(BASEIMAGE_RELEASE) 52 53 DOCKER_NS ?= hyperledger 54 NEXUS_URL ?= nexus3.hyperledger.org:10001/hyperledger 55 DOCKER_TAG=$(ARCH)-$(PROJECT_VERSION) 56 57 DOCKER_GO_LDFLAGS += $(GO_LDFLAGS) 58 ifeq ($(FABRIC_CA_DYNAMIC_LINK),true) 59 DOCKER_GO_LDFLAGS += -linkmode external -extldflags '-lpthread' 60 else 61 DOCKER_GO_LDFLAGS += -linkmode external -extldflags '-static -lpthread' 62 endif 63 64 # 65 # What is a .dummy file? 66 # 67 # Make is designed to work with files. It uses the presence (or lack thereof) 68 # and timestamps of files when deciding if a given target needs to be rebuilt. 69 # Docker containers throw a wrench into the works because the output of docker 70 # builds do not translate into standard files that makefile rules can evaluate. 71 # Therefore, we have to fake it. We do this by constructioning our rules such 72 # as 73 # my-docker-target/.dummy: 74 # docker build ... 75 # touch $@ 76 # 77 # If the docker-build succeeds, the touch operation creates/updates the .dummy 78 # file. If it fails, the touch command never runs. This means the .dummy 79 # file follows relatively 1:1 with the underlying container. 80 # 81 # This isn't perfect, however. For instance, someone could delete a docker 82 # container using docker-rmi outside of the build, and make would be fooled 83 # into thinking the dependency is statisfied when it really isn't. This is 84 # our closest approximation we can come up with. 85 # 86 # As an aside, also note that we incorporate the version number in the .dummy 87 # file to differentiate different tags to fix FAB-1145 88 # 89 DUMMY = .dummy-$(DOCKER_TAG) 90 91 92