diff --git a/Makefile b/Makefile index f54ffbf2..ef1c4fd7 100644 --- a/Makefile +++ b/Makefile @@ -9,7 +9,8 @@ BINARY_NAME := gostatsd IMAGE_NAME := atlassianlabs/$(BINARY_NAME) ARCH ?= darwin METALINTER_CONCURRENCY ?= 4 -GOVERSION = 1.6.2 +GOVERSION := 1.6.2 +GP := /gopath setup: setup-ci go get -v -u github.com/githubnemo/CompileDaemon @@ -85,19 +86,24 @@ git-hook: cp dev/push-hook.sh .git/hooks/pre-push # Compile a static binary. Cannot be used with -race -cross: - CGO_ENABLED=0 GOOS=linux go build -o build/bin/linux/$(BINARY_NAME) $(GOBUILD_VERSION_ARGS) -a -installsuffix cgo github.com/atlassian/gostatsd - -docker: cross +docker: + docker run \ + --rm \ + -v "$(GOPATH)":"$(GP)" \ + -w "$(GP)/src/github.com/atlassian/gostatsd" \ + -e GOPATH="$(GP)" \ + -e CGO_ENABLED=0 \ + golang:$(GOVERSION) \ + go build -o build/bin/linux/$(BINARY_NAME) $(GOBUILD_VERSION_ARGS) -a -installsuffix cgo github.com/atlassian/gostatsd docker build --pull -t $(IMAGE_NAME):$(GIT_HASH) build -# Compile a binary with -race. +# Compile a binary with -race. Needs to be run on a glibc-based system. docker-race: docker run \ --rm \ - -v "$(GOPATH)":/opt/gopath \ - -w /opt/gopath/src/github.com/atlassian/gostatsd \ - -e GOPATH=/opt/gopath \ + -v "$(GOPATH)":"$(GP)" \ + -w "$(GP)/src/github.com/atlassian/gostatsd" \ + -e GOPATH="$(GP)" \ golang:$(GOVERSION) \ go build -race -o build/bin/linux/$(BINARY_NAME) $(GOBUILD_VERSION_ARGS) -a -installsuffix cgo github.com/atlassian/gostatsd docker build --pull -t $(IMAGE_NAME):$(GIT_HASH)-race -f build/Dockerfile-glibc build @@ -111,6 +117,9 @@ release-normal: release-hash docker tag $(IMAGE_NAME):$(GIT_HASH) $(IMAGE_NAME):$(REPO_VERSION) docker push $(IMAGE_NAME):$(REPO_VERSION) +release-hash-race: check test docker-race + docker push $(IMAGE_NAME):$(GIT_HASH)-race + release-race: docker-race docker tag $(IMAGE_NAME):$(GIT_HASH)-race $(IMAGE_NAME):$(REPO_VERSION)-race docker push $(IMAGE_NAME):$(REPO_VERSION)-race