diff --git a/Makefile b/Makefile index e0a621f657c..0a0948ea83d 100644 --- a/Makefile +++ b/Makefile @@ -49,52 +49,12 @@ endif PKGNAME = github.com/$(PROJECT_NAME) GO_LDFLAGS = -X $(PKGNAME)/metadata.Version=$(PROJECT_VERSION) CGO_FLAGS = CGO_CFLAGS=" " -DOCKER_GO_LDFLAGS= $(GO_LDFLAGS) -linkmode external -extldflags '-static -lpthread' ARCH=$(shell uname -m) -OS=$(shell uname) CHAINTOOL_RELEASE=v0.10.0 BASEIMAGE_RELEASE=$(shell cat ./.baseimage-release) export GO_LDFLAGS -DOCKER_TAG=$(ARCH)-$(PROJECT_VERSION) -BASE_DOCKER_TAG=$(ARCH)-$(BASEIMAGE_RELEASE) - -ifneq ($(OS),Darwin) -DOCKER_RUN_FLAGS=--user=$(shell id -u) -endif - -ifneq ($(http_proxy),) -DOCKER_BUILD_FLAGS+=--build-arg http_proxy=$(http_proxy) -DOCKER_RUN_FLAGS+=-e http_proxy=$(http_proxy) -endif -ifneq ($(https_proxy),) -DOCKER_BUILD_FLAGS+=--build-arg https_proxy=$(https_proxy) -DOCKER_RUN_FLAGS+=-e https_proxy=$(https_proxy) -endif -ifneq ($(HTTP_PROXY),) -DOCKER_BUILD_FLAGS+=--build-arg HTTP_PROXY=$(HTTP_PROXY) -DOCKER_RUN_FLAGS+=-e HTTP_PROXY=$(HTTP_PROXY) -endif -ifneq ($(HTTPS_PROXY),) -DOCKER_BUILD_FLAGS+=--build-arg HTTPS_PROXY=$(HTTPS_PROXY) -DOCKER_RUN_FLAGS+=-e HTTPS_PROXY=$(HTTPS_PROXY) -endif -ifneq ($(no_proxy),) -DOCKER_BUILD_FLAGS+=--build-arg no_proxy=$(no_proxy) -DOCKER_RUN_FLAGS+=-e no_proxy=$(no_proxy) -endif -ifneq ($(NO_PROXY),) -DOCKER_BUILD_FLAGS+=--build-arg NO_PROXY=$(NO_PROXY) -DOCKER_RUN_FLAGS+=-e NO_PROXY=$(NO_PROXY) -endif - -DRUN = docker run -i --rm $(DOCKER_RUN_FLAGS) \ - -v $(abspath .):/opt/gopath/src/$(PKGNAME) \ - -w /opt/gopath/src/$(PKGNAME) - -DBUILD = docker build $(DOCKER_BUILD_FLAGS) - EXECUTABLES = go docker git curl K := $(foreach exec,$(EXECUTABLES),\ $(if $(shell which $(exec)),some string,$(error "No $(exec) in PATH: Check dependencies"))) @@ -109,6 +69,8 @@ pkgmap.peer := $(PKGNAME)/peer pkgmap.orderer := $(PKGNAME)/orderer pkgmap.block-listener := $(PKGNAME)/examples/events/block-listener +include docker-env.mk + all: native docker checks checks: linter unit-test behave diff --git a/docker-env.mk b/docker-env.mk new file mode 100644 index 00000000000..7476d83061e --- /dev/null +++ b/docker-env.mk @@ -0,0 +1,60 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +ifneq ($(shell uname),Darwin) +DOCKER_RUN_FLAGS=--user=$(shell id -u) +endif + +ifneq ($(http_proxy),) +DOCKER_BUILD_FLAGS+=--build-arg http_proxy=$(http_proxy) +DOCKER_RUN_FLAGS+=-e http_proxy=$(http_proxy) +endif +ifneq ($(https_proxy),) +DOCKER_BUILD_FLAGS+=--build-arg https_proxy=$(https_proxy) +DOCKER_RUN_FLAGS+=-e https_proxy=$(https_proxy) +endif +ifneq ($(HTTP_PROXY),) +DOCKER_BUILD_FLAGS+=--build-arg HTTP_PROXY=$(HTTP_PROXY) +DOCKER_RUN_FLAGS+=-e HTTP_PROXY=$(HTTP_PROXY) +endif +ifneq ($(HTTPS_PROXY),) +DOCKER_BUILD_FLAGS+=--build-arg HTTPS_PROXY=$(HTTPS_PROXY) +DOCKER_RUN_FLAGS+=-e HTTPS_PROXY=$(HTTPS_PROXY) +endif +ifneq ($(no_proxy),) +DOCKER_BUILD_FLAGS+=--build-arg no_proxy=$(no_proxy) +DOCKER_RUN_FLAGS+=-e no_proxy=$(no_proxy) +endif +ifneq ($(NO_PROXY),) +DOCKER_BUILD_FLAGS+=--build-arg NO_PROXY=$(NO_PROXY) +DOCKER_RUN_FLAGS+=-e NO_PROXY=$(NO_PROXY) +endif + +DRUN = docker run -i --rm $(DOCKER_RUN_FLAGS) \ + -v $(abspath .):/opt/gopath/src/$(PKGNAME) \ + -w /opt/gopath/src/$(PKGNAME) + +DBUILD = docker build $(DOCKER_BUILD_FLAGS) + +DOCKER_TAG=$(ARCH)-$(PROJECT_VERSION) +BASE_DOCKER_TAG=$(ARCH)-$(BASEIMAGE_RELEASE) + +DOCKER_GO_LDFLAGS += $(GO_LDFLAGS) +DOCKER_GO_LDFLAGS += -linkmode external -extldflags '-static -lpthread' + + +