49
49
PKGNAME = github.com/$(PROJECT_NAME )
50
50
GO_LDFLAGS = -X $(PKGNAME ) /metadata.Version=$(PROJECT_VERSION )
51
51
CGO_FLAGS = CGO_CFLAGS=" "
52
- GO_DOCKER_FLAGS = -ldflags " $(GO_LDFLAGS ) -linkmode external -extldflags '-static -lpthread'"
52
+ DOCKER_GO_LDFLAGS = $(GO_LDFLAGS ) -linkmode external -extldflags '-static -lpthread'
53
53
ARCH =$(shell uname -m)
54
54
OS =$(shell uname)
55
55
CHAINTOOL_RELEASE =v0.10.0
@@ -61,38 +61,40 @@ DOCKER_TAG=$(ARCH)-$(PROJECT_VERSION)
61
61
BASE_DOCKER_TAG =$(ARCH ) -$(BASEIMAGE_RELEASE )
62
62
63
63
ifneq ($(OS ) ,Darwin)
64
- DOCKER_FLAGS =--user =$(shell id -u)
64
+ DOCKER_RUN_FLAGS =--user =$(shell id -u)
65
65
endif
66
66
67
67
ifneq ($(http_proxy ) ,)
68
- DOCKER_ARGS_PROXY + =--build-arg http_proxy=$(http_proxy )
69
- DOCKER_FLAGS + =-e http_proxy=$(http_proxy )
68
+ DOCKER_BUILD_FLAGS + =--build-arg http_proxy=$(http_proxy )
69
+ DOCKER_RUN_FLAGS + =-e http_proxy=$(http_proxy )
70
70
endif
71
71
ifneq ($(https_proxy ) ,)
72
- DOCKER_ARGS_PROXY + =--build-arg https_proxy=$(https_proxy )
73
- DOCKER_FLAGS + =-e https_proxy=$(https_proxy )
72
+ DOCKER_BUILD_FLAGS + =--build-arg https_proxy=$(https_proxy )
73
+ DOCKER_RUN_FLAGS + =-e https_proxy=$(https_proxy )
74
74
endif
75
75
ifneq ($(HTTP_PROXY ) ,)
76
- DOCKER_ARGS_PROXY + =--build-arg HTTP_PROXY=$(HTTP_PROXY )
77
- DOCKER_FLAGS + =-e HTTP_PROXY=$(HTTP_PROXY )
76
+ DOCKER_BUILD_FLAGS + =--build-arg HTTP_PROXY=$(HTTP_PROXY )
77
+ DOCKER_RUN_FLAGS + =-e HTTP_PROXY=$(HTTP_PROXY )
78
78
endif
79
79
ifneq ($(HTTPS_PROXY ) ,)
80
- DOCKER_ARGS_PROXY + =--build-arg HTTPS_PROXY=$(HTTPS_PROXY )
81
- DOCKER_FLAGS + =-e HTTPS_PROXY=$(HTTPS_PROXY )
80
+ DOCKER_BUILD_FLAGS + =--build-arg HTTPS_PROXY=$(HTTPS_PROXY )
81
+ DOCKER_RUN_FLAGS + =-e HTTPS_PROXY=$(HTTPS_PROXY )
82
82
endif
83
83
ifneq ($(no_proxy ) ,)
84
- DOCKER_ARGS_PROXY + =--build-arg no_proxy=$(no_proxy )
85
- DOCKER_FLAGS + =-e no_proxy=$(no_proxy )
84
+ DOCKER_BUILD_FLAGS + =--build-arg no_proxy=$(no_proxy )
85
+ DOCKER_RUN_FLAGS + =-e no_proxy=$(no_proxy )
86
86
endif
87
87
ifneq ($(NO_PROXY ) ,)
88
- DOCKER_ARGS_PROXY + =--build-arg NO_PROXY=$(NO_PROXY )
89
- DOCKER_FLAGS + =-e NO_PROXY=$(NO_PROXY )
88
+ DOCKER_BUILD_FLAGS + =--build-arg NO_PROXY=$(NO_PROXY )
89
+ DOCKER_RUN_FLAGS + =-e NO_PROXY=$(NO_PROXY )
90
90
endif
91
91
92
- DRUN = docker run -i --rm $(DOCKER_FLAGS ) \
92
+ DRUN = docker run -i --rm $(DOCKER_RUN_FLAGS ) \
93
93
-v $(abspath .) :/opt/gopath/src/$(PKGNAME ) \
94
94
-w /opt/gopath/src/$(PKGNAME )
95
95
96
+ DBUILD = docker build $(DOCKER_BUILD_FLAGS )
97
+
96
98
EXECUTABLES = go docker git curl
97
99
K := $(foreach exec,$(EXECUTABLES ) ,\
98
100
$(if $(shell which $(exec ) ) ,some string,$(error "No $(exec ) in PATH: Check dependencies") ) )
@@ -166,7 +168,7 @@ build/docker/bin/%: $(PROJECT_FILES)
166
168
-v $(abspath build/docker/bin) :/opt/gopath/bin \
167
169
-v $(abspath build/docker/$(TARGET ) /pkg) :/opt/gopath/pkg \
168
170
hyperledger/fabric-baseimage:$(BASE_DOCKER_TAG ) \
169
- go install $( GO_DOCKER_FLAGS ) $(pkgmap.$(@F ) )
171
+ go install -ldflags " $( DOCKER_GO_LDFLAGS ) " $(pkgmap.$(@F ) )
170
172
@touch $@
171
173
172
174
build/bin :
@@ -228,7 +230,7 @@ build/image/%/.dummy: Makefile build/image/%/payload
228
230
| sed -e ' s/_BASE_TAG_/$(BASE_DOCKER_TAG)/g' \
229
231
| sed -e ' s/_TAG_/$(DOCKER_TAG)/g' \
230
232
> $(@D ) /Dockerfile
231
- docker build $( DOCKER_ARGS_PROXY ) -t $(PROJECT_NAME ) -$(TARGET ) $(@D )
233
+ $( DBUILD ) -t $(PROJECT_NAME ) -$(TARGET ) $(@D )
232
234
docker tag $(PROJECT_NAME ) -$(TARGET ) $(PROJECT_NAME ) -$(TARGET ) :$(DOCKER_TAG )
233
235
@touch $@
234
236
0 commit comments