Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add buildindocker to Makefile #69

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down