forked from sapcc/mosquitto-exporter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
30 lines (26 loc) · 853 Bytes
/
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
PKG_NAME:=github.com/sapcc/mosquitto-exporter
BUILD_DIR:=bin
MOSQUITTO_EXPORTER_BINARY:=$(BUILD_DIR)/mosquitto_exporter
IMAGE := sapcc/mosquitto-exporter
VERSION=0.8.0
LDFLAGS=-s -w -X main.Version=$(VERSION) -X main.GITCOMMIT=`git rev-parse --short HEAD`
.PHONY: help
help:
@echo
@echo "Available targets:"
@echo " * build - build the binary, output to $(ARC_BINARY)"
@echo " * linux - build the binary, output to $(ARC_BINARY)"
@echo " * docker - build docker image"
.PHONY: build
build: export CGO_ENABLED=0
build:
@mkdir -p $(BUILD_DIR)
go build -o $(MOSQUITTO_EXPORTER_BINARY) -ldflags="$(LDFLAGS)" $(PKG_NAME)
linux: export GOOS=linux
linux: build
docker:
docker build -t $(IMAGE):$(VERSION) .
docker build -t $(IMAGE):latest .
push:
docker push $(IMAGE):$(VERSION)
docker push $(IMAGE):latest