Skip to content

Commit c0bc726

Browse files
committed
[BUILD] Isolate docker instructions
Change-Id: Ice1bf6eaacdd038254b6749ab44dfba2fcc2222b Signed-off-by: Greg Haskins <[email protected]>
1 parent 5d07caa commit c0bc726

File tree

2 files changed

+62
-40
lines changed

2 files changed

+62
-40
lines changed

Makefile

+2-40
Original file line numberDiff line numberDiff line change
@@ -49,52 +49,12 @@ endif
4949
PKGNAME = github.com/$(PROJECT_NAME)
5050
GO_LDFLAGS = -X $(PKGNAME)/metadata.Version=$(PROJECT_VERSION)
5151
CGO_FLAGS = CGO_CFLAGS=" "
52-
DOCKER_GO_LDFLAGS= $(GO_LDFLAGS) -linkmode external -extldflags '-static -lpthread'
5352
ARCH=$(shell uname -m)
54-
OS=$(shell uname)
5553
CHAINTOOL_RELEASE=v0.10.0
5654
BASEIMAGE_RELEASE=$(shell cat ./.baseimage-release)
5755

5856
export GO_LDFLAGS
5957

60-
DOCKER_TAG=$(ARCH)-$(PROJECT_VERSION)
61-
BASE_DOCKER_TAG=$(ARCH)-$(BASEIMAGE_RELEASE)
62-
63-
ifneq ($(OS),Darwin)
64-
DOCKER_RUN_FLAGS=--user=$(shell id -u)
65-
endif
66-
67-
ifneq ($(http_proxy),)
68-
DOCKER_BUILD_FLAGS+=--build-arg http_proxy=$(http_proxy)
69-
DOCKER_RUN_FLAGS+=-e http_proxy=$(http_proxy)
70-
endif
71-
ifneq ($(https_proxy),)
72-
DOCKER_BUILD_FLAGS+=--build-arg https_proxy=$(https_proxy)
73-
DOCKER_RUN_FLAGS+=-e https_proxy=$(https_proxy)
74-
endif
75-
ifneq ($(HTTP_PROXY),)
76-
DOCKER_BUILD_FLAGS+=--build-arg HTTP_PROXY=$(HTTP_PROXY)
77-
DOCKER_RUN_FLAGS+=-e HTTP_PROXY=$(HTTP_PROXY)
78-
endif
79-
ifneq ($(HTTPS_PROXY),)
80-
DOCKER_BUILD_FLAGS+=--build-arg HTTPS_PROXY=$(HTTPS_PROXY)
81-
DOCKER_RUN_FLAGS+=-e HTTPS_PROXY=$(HTTPS_PROXY)
82-
endif
83-
ifneq ($(no_proxy),)
84-
DOCKER_BUILD_FLAGS+=--build-arg no_proxy=$(no_proxy)
85-
DOCKER_RUN_FLAGS+=-e no_proxy=$(no_proxy)
86-
endif
87-
ifneq ($(NO_PROXY),)
88-
DOCKER_BUILD_FLAGS+=--build-arg NO_PROXY=$(NO_PROXY)
89-
DOCKER_RUN_FLAGS+=-e NO_PROXY=$(NO_PROXY)
90-
endif
91-
92-
DRUN = docker run -i --rm $(DOCKER_RUN_FLAGS) \
93-
-v $(abspath .):/opt/gopath/src/$(PKGNAME) \
94-
-w /opt/gopath/src/$(PKGNAME)
95-
96-
DBUILD = docker build $(DOCKER_BUILD_FLAGS)
97-
9858
EXECUTABLES = go docker git curl
9959
K := $(foreach exec,$(EXECUTABLES),\
10060
$(if $(shell which $(exec)),some string,$(error "No $(exec) in PATH: Check dependencies")))
@@ -109,6 +69,8 @@ pkgmap.peer := $(PKGNAME)/peer
10969
pkgmap.orderer := $(PKGNAME)/orderer
11070
pkgmap.block-listener := $(PKGNAME)/examples/events/block-listener
11171

72+
include docker-env.mk
73+
11274
all: native docker checks
11375

11476
checks: linter unit-test behave

docker-env.mk

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
ifneq ($(shell uname),Darwin)
19+
DOCKER_RUN_FLAGS=--user=$(shell id -u)
20+
endif
21+
22+
ifneq ($(http_proxy),)
23+
DOCKER_BUILD_FLAGS+=--build-arg http_proxy=$(http_proxy)
24+
DOCKER_RUN_FLAGS+=-e http_proxy=$(http_proxy)
25+
endif
26+
ifneq ($(https_proxy),)
27+
DOCKER_BUILD_FLAGS+=--build-arg https_proxy=$(https_proxy)
28+
DOCKER_RUN_FLAGS+=-e https_proxy=$(https_proxy)
29+
endif
30+
ifneq ($(HTTP_PROXY),)
31+
DOCKER_BUILD_FLAGS+=--build-arg HTTP_PROXY=$(HTTP_PROXY)
32+
DOCKER_RUN_FLAGS+=-e HTTP_PROXY=$(HTTP_PROXY)
33+
endif
34+
ifneq ($(HTTPS_PROXY),)
35+
DOCKER_BUILD_FLAGS+=--build-arg HTTPS_PROXY=$(HTTPS_PROXY)
36+
DOCKER_RUN_FLAGS+=-e HTTPS_PROXY=$(HTTPS_PROXY)
37+
endif
38+
ifneq ($(no_proxy),)
39+
DOCKER_BUILD_FLAGS+=--build-arg no_proxy=$(no_proxy)
40+
DOCKER_RUN_FLAGS+=-e no_proxy=$(no_proxy)
41+
endif
42+
ifneq ($(NO_PROXY),)
43+
DOCKER_BUILD_FLAGS+=--build-arg NO_PROXY=$(NO_PROXY)
44+
DOCKER_RUN_FLAGS+=-e NO_PROXY=$(NO_PROXY)
45+
endif
46+
47+
DRUN = docker run -i --rm $(DOCKER_RUN_FLAGS) \
48+
-v $(abspath .):/opt/gopath/src/$(PKGNAME) \
49+
-w /opt/gopath/src/$(PKGNAME)
50+
51+
DBUILD = docker build $(DOCKER_BUILD_FLAGS)
52+
53+
DOCKER_TAG=$(ARCH)-$(PROJECT_VERSION)
54+
BASE_DOCKER_TAG=$(ARCH)-$(BASEIMAGE_RELEASE)
55+
56+
DOCKER_GO_LDFLAGS += $(GO_LDFLAGS)
57+
DOCKER_GO_LDFLAGS += -linkmode external -extldflags '-static -lpthread'
58+
59+
60+

0 commit comments

Comments
 (0)