This repository has been archived by the owner on Apr 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
55 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
*.exe | ||
binaries |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,11 @@ | ||
FROM golang:1.8 | ||
FROM golang:1.12 | ||
WORKDIR /go/src/github.com/carlpett/stream_exporter/ | ||
RUN go get -u github.com/kardianos/govendor | ||
COPY . . | ||
RUN govendor build +p | ||
RUN make build | ||
|
||
FROM centos:centos7 | ||
FROM busybox:glibc | ||
WORKDIR /usr/bin/ | ||
COPY --from=0 /go/src/github.com/carlpett/stream_exporter/stream_exporter /usr/bin/stream_exporter | ||
RUN adduser -u 1000 stream_exporter | ||
USER stream_exporter | ||
USER 1000 | ||
ENTRYPOINT ["/usr/bin/stream_exporter"] | ||
EXPOSE 9178 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,50 @@ | ||
GO := go | ||
FIRST_GOPATH := $(firstword $(subst :, ,$(GOPATH))) | ||
PROMU := $(FIRST_GOPATH)/bin/promu | ||
pkgs = $(shell $(GO) list ./... | grep -v /vendor/) | ||
DOCKER ?= docker | ||
|
||
PREFIX ?= $(shell pwd)/.build | ||
BIN_DIR ?= $(shell pwd) | ||
CROSSBUILD_OS = linux windows darwin | ||
CROSSBUILD_ARCH = 386 amd64 | ||
|
||
ifdef DEBUG | ||
bindata_flags = -debug | ||
endif | ||
VERSION := $(shell git describe --tags --dirty=-dirty) | ||
REVISION := $(shell git describe --abbrev=0 --always --match=always-commit-hash --dirty=-dirty) | ||
BRANCH := $(shell git symbolic-ref --short HEAD) | ||
BUILDDATE := $(shell date --iso-8601=seconds) | ||
BUILDUSER ?= $(USER) | ||
BUILDHOST ?= $(HOSTNAME) | ||
LDFLAGS = -X github.com/prometheus/common/version.Version=$(VERSION) \ | ||
-X github.com/prometheus/common/version.Revision=$(REVISION) \ | ||
-X github.com/prometheus/common/version.Branch=$(BRANCH) \ | ||
-X github.com/prometheus/common/version.BuildUser=$(BUILDUSER)@$(BUILDHOST) \ | ||
-X github.com/prometheus/common/version.BuildDate=$(BUILDDATE) | ||
|
||
all: format build | ||
|
||
style: | ||
@echo ">> checking code style" | ||
@! gofmt -d $(shell find . -path ./vendor -prune -o -name '*.go' -print) | grep '^' | ||
|
||
format: | ||
@echo ">> formatting code" | ||
@$(GO) fmt $(pkgs) | ||
|
||
vet: | ||
@echo ">> vetting code" | ||
@$(GO) vet $(pkgs) | ||
all: build test | ||
|
||
test: | ||
@echo ">> testing code" | ||
@$(GO) test -v $(pkgs) | ||
@go test -v -cover ./... | ||
|
||
bench: | ||
@$(GO) test -v -bench=. $(pkgs) | ||
|
||
build: promu | ||
build: | ||
@echo ">> building binaries" | ||
@$(PROMU) build --prefix $(PREFIX) | ||
@go build -ldflags="$(LDFLAGS)" | ||
|
||
crossbuild: $(GOPATH)/bin/gox | ||
@echo ">> cross-building" | ||
@gox -arch="$(CROSSBUILD_ARCH)" -os="$(CROSSBUILD_OS)" -ldflags="$(LDFLAGS)" -output="binaries/stream_exporter_{{.OS}}_{{.Arch}}" | ||
|
||
release: bin/github-release | ||
@echo ">> uploading release ${VERSION}" | ||
@for bin in binaries/*; do \ | ||
./bin/github-release upload -t ${VERSION} -n $$(basename $${bin}) -f $${bin}; \ | ||
done | ||
|
||
tarball: promu | ||
@echo ">> building release tarball" | ||
@$(PROMU) tarball --prefix $(PREFIX) $(BIN_DIR) | ||
docker: | ||
@echo ">> building docker image" | ||
@$(DOCKER) build -t carlpett/stream_exporter . | ||
|
||
promu: | ||
@GOOS=$(shell uname -s | tr A-Z a-z) \ | ||
GOARCH=$(subst x86_64,amd64,$(patsubst i%86,386,$(shell uname -m))) \ | ||
$(GO) get -u github.com/prometheus/promu | ||
$(GOPATH)/bin/gox: | ||
# Need to disable modules for this to not pollute go.mod | ||
@GO111MODULE=off go get -u github.com/mitchellh/gox | ||
|
||
bin/github-release: | ||
@mkdir -p bin | ||
@curl -sL 'https://github.com/aktau/github-release/releases/download/v0.6.2/linux-amd64-github-release.tar.bz2' | tar xjf - --strip-components 3 -C bin | ||
|
||
.PHONY: all style format build vet tarball docker promu | ||
.PHONY: all build crossbuild test release |