forked from joe-pll/minio-exporter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
66 lines (51 loc) · 1.83 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# Copyright 2017 Giuseppe Pellegrino
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
GO ?= GO15VENDOREXPERIMENT=1 go
GOPATH := $(firstword $(subst :, ,$(shell $(GO) env GOPATH)))
TARGET = minio_exporter
VERSION := $(shell cat VERSION)
OS := $(shell uname | tr A-Z a-z)
ARCH := $(shell uname -p)
ARCHIVE := $(TARGET)-$(VERSION)-$(OS)-$(ARCH).tar.gz
DOCKER_IMAGE_NAME ?= joepll/minio-exporter
DOCKER_IMAGE_TAG ?= v$(VERSION)
pkgs := $(shell $(GO) list)
all: format build test
build: get_dep
@echo "... building binaries"
@CGO_ENABLED=0 $(GO) build -o $(TARGET) -a -installsuffix cgo $(pkgs)
format:
@echo "... formatting packages"
@$(GO) fmt $(pkgs)
test:
@echo "... testing binary"
@$(GO) test -short $(pkgs)
get_dep:
@echo "... getting dependencies"
@$(GO) get -d
docker: docker_build docker_push
@echo "... docker building and pushing"
docker_build: build
@echo "... building docker image"
@docker build -t $(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_TAG) .
docker_push:
@echo "... pushing docker image"
@docker push $(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_TAG)
clean:
@echo "... cleaning up"
@rm -rf $(TARGET) $(ARCHIVE) .build
tarball: $(ARCHIVE)
$(ARCHIVE): $(TARGET)
@echo "... creating tarball"
@tar -czf $@ $<
.PHONY: all build format test docker_build docker_push tarball clean