diff --git a/Makefile b/Makefile index d90438379a5..903e4934bd8 100644 --- a/Makefile +++ b/Makefile @@ -48,14 +48,22 @@ endif PKGNAME = github.com/$(PROJECT_NAME) GO_LDFLAGS = -X $(PKGNAME)/metadata.Version=$(PROJECT_VERSION) CGO_FLAGS = CGO_CFLAGS=" " CGO_LDFLAGS="-lrocksdb -lstdc++ -lm -lz -lbz2 -lsnappy" -UID = $(shell id -u) ARCH=$(shell uname -m) +OS=$(shell uname) CHAINTOOL_RELEASE=v0.10.0 BASEIMAGE_RELEASE=$(shell cat ./.baseimage-release) DOCKER_TAG=$(ARCH)-$(PROJECT_VERSION) BASE_DOCKER_TAG=$(ARCH)-$(BASEIMAGE_RELEASE) +ifneq ($(OS),Darwin) +DOCKER_FLAGS=--user=$(shell id -u) +endif + +DRUN = docker run -i --rm $(DOCKER_FLAGS) \ + -v $(abspath .):/opt/gopath/src/$(PKGNAME) \ + -w /opt/gopath/src/$(PKGNAME) + EXECUTABLES = go docker git curl K := $(foreach exec,$(EXECUTABLES),\ $(if $(shell which $(exec)),some string,$(error "No $(exec) in PATH: Check dependencies"))) @@ -117,11 +125,11 @@ linter: gotools %/bin/protoc-gen-go: Makefile @echo "Building $@" @mkdir -p $(@D) - @docker run -i \ - --user=$(UID) \ + @$(DRUN) \ -v $(abspath vendor/github.com/golang/protobuf):/opt/gopath/src/github.com/golang/protobuf \ -v $(abspath $(@D)):/opt/gopath/bin \ - hyperledger/fabric-baseimage:$(BASE_DOCKER_TAG) go install github.com/golang/protobuf/protoc-gen-go + hyperledger/fabric-baseimage:$(BASE_DOCKER_TAG) \ + go install github.com/golang/protobuf/protoc-gen-go build/bin/chaintool: Makefile @echo "Installing chaintool" @@ -139,11 +147,9 @@ build/docker/bin/%: $(PROJECT_FILES) $(eval TARGET = ${patsubst build/docker/bin/%,%,${@}}) @echo "Building $@" @mkdir -p build/docker/bin build/docker/pkg - @docker run -i \ - --user=$(UID) \ + @$(DRUN) \ -v $(abspath build/docker/bin):/opt/gopath/bin \ -v $(abspath build/docker/pkg):/opt/gopath/pkg \ - -v $(abspath .):/opt/gopath/src/$(PKGNAME) \ hyperledger/fabric-baseimage:$(BASE_DOCKER_TAG) \ go install -ldflags "$(GO_LDFLAGS)" $(pkgmap.$(@F)) @touch $@