diff --git a/Makefile b/Makefile index af93987..884a91f 100644 --- a/Makefile +++ b/Makefile @@ -2,6 +2,9 @@ GO := GO15VENDOREXPERIMENT=1 go PROMU := $(GOPATH)/bin/promu pkgs = $(shell $(GO) list ./... | grep -v /vendor/) +DOCKER_RUN = docker run --rm -v $(shell pwd):/go/src/github.com/hnlq715/nginx-vts-exporter -w /go/src/github.com/hnlq715/nginx-vts-exporter/ +GOLANG_CONTAINER = golang:1.9 + PREFIX ?= $(shell pwd) BIN_DIR ?= $(shell pwd) DOCKER_IMAGE_NAME ?= nginx-vts-exporter @@ -29,6 +32,9 @@ vet: build: promu @echo ">> building binaries" @$(PROMU) build --prefix $(PREFIX) + +buildindocker: + $(DOCKER_RUN) -e CGO_ENABLED=0 $(GOLANG_CONTAINER) /bin/bash -c "go get -u github.com/prometheus/promu && go build -a -installsuffix cgo -ldflags \"-w\" -o nginx-vts-exporter *.go" crossbuild: promu @echo ">> crossbuilding binaries" diff --git a/README.md b/README.md index 49233c8..79bdf25 100644 --- a/README.md +++ b/README.md @@ -39,10 +39,16 @@ Binary can be downloaded from [Releases](https://github.com/hnlq715/nginx-vts-ex ## Compile ### build binary - +#### build local ``` shell make ``` +OR + +#### build in docker +``` shell +make buildindocker +``` ### build docker image ``` shell