2015-08-24 17:27:14 +00:00
|
|
|
|
2016-05-28 04:19:55 +00:00
|
|
|
GO_SRC := $(shell find -type f -name "*.go")
|
|
|
|
|
|
|
|
CONTAINER_NAME ?= wrouesnel/postgres_exporter:latest
|
|
|
|
|
|
|
|
all: vet test postgres_exporter
|
|
|
|
|
2016-03-12 10:07:31 +00:00
|
|
|
# Simple go build
|
2016-05-28 04:19:55 +00:00
|
|
|
postgres_exporter: $(GO_SRC)
|
|
|
|
CGO_ENABLED=0 GOOS=linux go build -a -ldflags "-extldflags '-static' -X main.Version=git:$(shell git rev-parse HEAD)" -o postgres_exporter .
|
|
|
|
|
|
|
|
# Take a go build and turn it into a minimal container
|
|
|
|
docker: postgres_exporter
|
|
|
|
tar -cf - postgres_exporter | docker import --change "EXPOSE 9113" \
|
|
|
|
--change 'ENTRYPOINT [ "/postgres_exporter" ]' \
|
|
|
|
- $(CONTAINER_NAME)
|
|
|
|
|
|
|
|
vet:
|
|
|
|
go vet .
|
|
|
|
|
|
|
|
test:
|
|
|
|
go test -v .
|
2015-08-24 17:27:14 +00:00
|
|
|
|
2016-03-12 10:07:31 +00:00
|
|
|
# Do a self-contained docker build - we pull the official upstream container,
|
|
|
|
# then template out a dockerfile which builds the real image.
|
2016-05-28 04:19:55 +00:00
|
|
|
docker-build: postgres_exporter
|
2016-03-12 10:07:31 +00:00
|
|
|
docker run -v $(shell pwd):/go/src/github.com/wrouesnel/postgres_exporter \
|
2016-05-28 04:19:55 +00:00
|
|
|
-w /go/src/github.com/wrouesnel/postgres_exporter \
|
2016-03-12 10:07:31 +00:00
|
|
|
golang:1.6-wheezy \
|
2016-05-28 04:19:55 +00:00
|
|
|
/bin/bash -c "make >&2 && tar -cf - ./postgres_exporter" | \
|
2016-03-12 10:07:31 +00:00
|
|
|
docker import --change "EXPOSE 9113" \
|
|
|
|
--change 'ENTRYPOINT [ "/postgres_exporter" ]' \
|
2016-05-28 04:19:55 +00:00
|
|
|
- $(CONTAINER_NAME)
|
2016-03-12 10:07:31 +00:00
|
|
|
|
2016-05-28 04:19:55 +00:00
|
|
|
.PHONY: docker-build docker test vet
|