forked from flashcatcloud/categraf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
58 lines (45 loc) · 2.13 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
.SILENT:
.PHONY: build build-linux build-windows pack
APP:=categraf
ROOT:=$(shell pwd -P)
GIT_COMMIT:=$(shell git --work-tree ${ROOT} rev-parse 'HEAD^{commit}')
_GIT_VERSION:=$(shell git --work-tree ${ROOT} describe --tags --abbrev=14 "${GIT_COMMIT}^{commit}" 2>/dev/null)
TAG=$(shell echo "${_GIT_VERSION}" | awk -F"-" '{print $$1}')
GIT_VERSION:="$(TAG)-$(GIT_COMMIT)"
BUILD_VERSION:='flashcat.cloud/categraf/config.Version=$(GIT_VERSION)'
LDFLAGS:="-w -s -X $(BUILD_VERSION)"
all: build
vendor:
GOPROXY=https://goproxy.cn go mod vendor
build:
echo "Building version $(GIT_VERSION)"
go build -ldflags $(LDFLAGS) -o $(APP)
build-enterprise:
echo "Building version $(GIT_VERSION)"
go build --tags "enterprise" -ldflags $(LDFLAGS) -o $(APP)
build-pure:
echo "Building version $(GIT_VERSION)"
go build --tags "no_prometheus no_traces" -ldflags $(LDFLAGS) -o $(APP)
build-linux:
echo "Building version $(GIT_VERSION) for linux"
GOOS=linux GOARCH=amd64 go build -ldflags $(LDFLAGS) -o $(APP)
build-linux-arm:
echo "Building version $(GIT_VERSION) for linux"
GOOS=linux GOARCH=arm64 go build -ldflags $(LDFLAGS) -o $(APP)
build-windows:
echo "Building version $(GIT_VERSION) for windows"
GOOS=windows GOARCH=amd64 go build -ldflags $(LDFLAGS) -o $(APP).exe
build-mac:
echo "Building version $(GIT_VERSION) for mac"
GOOS=darwin GOARCH=amd64 go build -ldflags $(LDFLAGS) -o $(APP).mac
build-mac-arm:
echo "Building version $(GIT_VERSION) for mac"
GOOS=darwin GOARCH=arm64 go build -ldflags $(LDFLAGS) -o $(APP).mac
build-image: build-linux
echo "Building image flashcatcloud/categraf:$(TAG)"
cp -rf conf/config.toml conf/logs.toml conf/input.cpu conf/input.disk conf/input.diskio conf/input.docker conf/input.kernel conf/input.kernel_vmstat conf/input.linux_sysctl_fs conf/input.mem conf/input.net conf/input.netstat conf/input.processes conf/input.system docker/conf/ && cp -f categraf docker/ && cd docker && docker build -t flashcatcloud/categraf:$(TAG) .
pack:build-linux build-windows
rm -rf $(APP)-$(TAG).tar.gz
rm -rf $(APP)-$(TAG).zip
tar -zcvf $(APP)-$(TAG)-linux-amd64.tar.gz conf $(APP)
zip -r $(APP)-$(TAG)-windows-amd64.zip conf $(APP).exe