Skip to content

Commit

Permalink
[BUILD] Isolate docker instructions
Browse files Browse the repository at this point in the history
Change-Id: Ice1bf6eaacdd038254b6749ab44dfba2fcc2222b
Signed-off-by: Greg Haskins <gregory.haskins@gmail.com>
  • Loading branch information
ghaskins committed Nov 30, 2016
1 parent 5d07caa commit c0bc726
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 40 deletions.
42 changes: 2 additions & 40 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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")))
Expand All @@ -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
Expand Down
60 changes: 60 additions & 0 deletions docker-env.mk
Original file line number Diff line number Diff line change
@@ -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'



0 comments on commit c0bc726

Please sign in to comment.