forked from ncabatoff/dbms_exporter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
43 lines (31 loc) · 1.4 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
GO_DIRS := $(shell go list ./... |sed -e 1d -e s,github.com/ncabatoff/dbms_exporter/,,)
GO_SRC := dbms_exporter.go $(shell find ${GO_DIRS} -name '*.go')
CONTAINER_NAME = ncabatoff/dbms_exporter:latest
FREETDS_VERSION = 1.1.5
BUILD_CONTAINER_NAME = ncabatoff/dbms_exporter_builder:${FREETDS_VERSION}
TAG_VERSION ?= $(shell git describe --tags --abbrev=0)
# Possible BUILDTAGS settings are postgres, freetds, and odbc.
DRIVERS = postgres freetds
# Use make LDFLAGS= if you want to build with tag ODBC.
LDFLAGS = -extldflags=-static
all: vet test dbms_exporter
# Simple go build
dbms_exporter: $(GO_SRC)
go build -ldflags '$(LDFLAGS) -X main.Version=$(TAG_VERSION)' -o dbms_exporter -tags '$(DRIVERS)' .
docker: Dockerfile $(GO_SRC)
docker build --build-arg drivers="$(DRIVERS)" --build-arg ldflags="$(LDFLAGS)" -t $(CONTAINER_NAME) .
vet:
go vet . ./config ./common ./db ./recipes
test:
go test -v . ./config ./common ./db ./recipes
test-integration:
tests/test-smoke
docker-build-pre: Dockerfile-buildexporter
docker build --build-arg FREETDS_VERSION=${FREETDS_VERSION} -f Dockerfile-buildexporter -t $(BUILD_CONTAINER_NAME) .
# Do a self-contained build of dbms_exporter using Docker.
build-with-docker: $(GO_SRC) docker-build-pre Dockerfile
docker run --rm -v $(shell pwd):/work \
-w /work \
$(BUILD_CONTAINER_NAME) \
make DRIVERS="$(DRIVERS)" LDFLAGS="$(LDFLAGS)"
.PHONY: docker-build docker test vet