Skip to content

Commit 5d07caa

Browse files
committed
[BUILD] Unify docker environment
Change-Id: I83b70af4143027b7e857869043b9bbe9a063f7a3 Signed-off-by: Greg Haskins <[email protected]>
1 parent b61723f commit 5d07caa

File tree

1 file changed

+19
-17
lines changed

1 file changed

+19
-17
lines changed

Makefile

+19-17
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ endif
4949
PKGNAME = github.com/$(PROJECT_NAME)
5050
GO_LDFLAGS = -X $(PKGNAME)/metadata.Version=$(PROJECT_VERSION)
5151
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'
5353
ARCH=$(shell uname -m)
5454
OS=$(shell uname)
5555
CHAINTOOL_RELEASE=v0.10.0
@@ -61,38 +61,40 @@ DOCKER_TAG=$(ARCH)-$(PROJECT_VERSION)
6161
BASE_DOCKER_TAG=$(ARCH)-$(BASEIMAGE_RELEASE)
6262

6363
ifneq ($(OS),Darwin)
64-
DOCKER_FLAGS=--user=$(shell id -u)
64+
DOCKER_RUN_FLAGS=--user=$(shell id -u)
6565
endif
6666

6767
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)
7070
endif
7171
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)
7474
endif
7575
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)
7878
endif
7979
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)
8282
endif
8383
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)
8686
endif
8787
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)
9090
endif
9191

92-
DRUN = docker run -i --rm $(DOCKER_FLAGS) \
92+
DRUN = docker run -i --rm $(DOCKER_RUN_FLAGS) \
9393
-v $(abspath .):/opt/gopath/src/$(PKGNAME) \
9494
-w /opt/gopath/src/$(PKGNAME)
9595

96+
DBUILD = docker build $(DOCKER_BUILD_FLAGS)
97+
9698
EXECUTABLES = go docker git curl
9799
K := $(foreach exec,$(EXECUTABLES),\
98100
$(if $(shell which $(exec)),some string,$(error "No $(exec) in PATH: Check dependencies")))
@@ -166,7 +168,7 @@ build/docker/bin/%: $(PROJECT_FILES)
166168
-v $(abspath build/docker/bin):/opt/gopath/bin \
167169
-v $(abspath build/docker/$(TARGET)/pkg):/opt/gopath/pkg \
168170
hyperledger/fabric-baseimage:$(BASE_DOCKER_TAG) \
169-
go install $(GO_DOCKER_FLAGS) $(pkgmap.$(@F))
171+
go install -ldflags "$(DOCKER_GO_LDFLAGS)" $(pkgmap.$(@F))
170172
@touch $@
171173

172174
build/bin:
@@ -228,7 +230,7 @@ build/image/%/.dummy: Makefile build/image/%/payload
228230
| sed -e 's/_BASE_TAG_/$(BASE_DOCKER_TAG)/g' \
229231
| sed -e 's/_TAG_/$(DOCKER_TAG)/g' \
230232
> $(@D)/Dockerfile
231-
docker build $(DOCKER_ARGS_PROXY) -t $(PROJECT_NAME)-$(TARGET) $(@D)
233+
$(DBUILD) -t $(PROJECT_NAME)-$(TARGET) $(@D)
232234
docker tag $(PROJECT_NAME)-$(TARGET) $(PROJECT_NAME)-$(TARGET):$(DOCKER_TAG)
233235
@touch $@
234236

0 commit comments

Comments
 (0)