forked from sapcc/mosquitto-exporter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
31 lines (27 loc) · 866 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
31
PKG_NAME:=github.com/sapcc/mosquitto-exporter
BUILD_DIR:=bin
MOSQUITTO_EXPORTER_BINARY:=$(BUILD_DIR)/mosquitto_exporter
IMAGE := gcr.io/pdk-io/mosquitto-exporter
VERSION=0.0.2
LDFLAGS=-s -w -X main.Version=$(VERSION) -X main.GITCOMMIT=`git rev-parse --short HEAD`
CGO_ENABLED=0
GOARCH=amd64
.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:
@mkdir -p $(BUILD_DIR)
go build -o $(MOSQUITTO_EXPORTER_BINARY) -ldflags="$(LDFLAGS)" $(PKG_NAME)
linux: export GOOS=linux
linux: build
docker: linux
docker build -t $(IMAGE):$(VERSION) .
docker build -t $(IMAGE):latest .
push:
docker push $(IMAGE):$(VERSION)
docker push $(IMAGE):latest