-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
47 lines (35 loc) · 1.03 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
44
45
46
47
APP_NAME := nest_exporter
VERSION ?= $(shell git rev-parse --abbrev-ref HEAD)
DOCKER_REPO ?= scnewma
DOCKER_TAG ?= $(VERSION)
.DEFAULT_GOAL := clean-build
.PHONY: release
release: test docker docker-publish
.PHONY: docker
docker:
@docker build --build-arg VCS_REF=`git rev-parse --short HEAD` \
--build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` \
--build-arg VERSION=$(VERSION) \
-t $(DOCKER_REPO)/$(APP_NAME):$(DOCKER_TAG) .
.PHONY: docker-run
docker-run:
@docker run -p 9264:9264 $(DOCKER_REPO)/$(APP_NAME):$(DOCKER_TAG) --nest.token=$(shell cat .token)
.PHONY: docker-publish
docker-publish:
@docker push $(DOCKER_REPO)/$(APP_NAME):$(DOCKER_TAG)
PKGS := $(shell go list ./... | grep -v /vendor)
.PHONY: test
test:
go test $(PKGS)
BINARY := $(APP_NAME)
BASE_PKG := github.com/scnewma/nest_exporter
LD_FLAGS := -ldflags "-X $(BASE_PKG)/version.Version=$(VERSION)"
$(BINARY):
mkdir -p bin
go build $(LD_FLAGS) -o $(BINARY)
build: $(BINARY)
.PHONY: clean
clean:
rm -f $(BINARY)
.PHONY: clean-build
clean-build: clean build