Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
76 lines (63 loc) · 3.5 KB
/
Copy pathMakefile
File metadata and controls
76 lines (63 loc) · 3.5 KB
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
67
68
69
70
71
72
73
74
75
76
.PHONY: proto web signing-key clean build-all build-collector build-agent build-client pack-all pack-collector pack-agent pack-client
# the version -version and the dashboard show, like v3.0.0-16-g2519821
VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo dev)
# agents only install updates from the dashboard when they are signed with
# this key, which stays where the builds are made and never on the servers.
# Its public key is built into agents, and is empty until make signing-key.
SIGNING_KEY ?= $(HOME)/.config/symon/agent-signing.key
UPDATE_KEY = $(shell cat $(SIGNING_KEY).pub 2>/dev/null)
# recursive, so a key made earlier in the same run is picked up
LDFLAGS = -ldflags "-X github.com/dhamith93/SyMon/internal/version.Version=$(VERSION) -X github.com/dhamith93/SyMon/internal/update.PublicKey=$(UPDATE_KEY)"
proto:
cd internal && protoc --go_out=. --go_opt=paths=source_relative \
--go-grpc_out=. --go-grpc_opt=paths=source_relative \
api/api.proto
signing-key:
go run ./tools/sign keygen -key $(SIGNING_KEY)
web:
cd client/web && npm ci && npm run build
clean:
rm -f agent/agent_linux_x86_64
rm -f client/client_linux_x86_64
rm -f collector/collector_linux_x86_64
rm -f agent/agent
rm -f client/client
rm -f collector/collector
rm -rf release
rm -rf collector/release/
rm -rf agent/release/
rm -rf client/release/
build-all: build-collector build-agent build-client
build-collector:
cd collector && GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build $(LDFLAGS) -o collector_linux_x86_64
build-agent:
cd agent && GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build $(LDFLAGS) -o agent_linux_x86_64
build-client: web
cd client && GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build $(LDFLAGS) -o client_linux_x86_64
pack-all: pack-collector pack-agent pack-client
pack-collector: build-collector
mkdir -p release/collector_linux_x86_64
cp collector/collector_linux_x86_64 release/collector_linux_x86_64
cp collector/.env-example release/collector_linux_x86_64
cp collector/alerts.json release/collector_linux_x86_64
cd release/ && tar -cvf collector_linux_x86_64.tar.gz collector_linux_x86_64
rm -rf release/collector_linux_x86_64
pack-agent: signing-key build-agent
mkdir -p release/agent_linux_x86_64
cp agent/agent_linux_x86_64 release/agent_linux_x86_64
cp agent/.env-example release/agent_linux_x86_64
cd release/ && tar -cvf agent_linux_x86_64.tar.gz agent_linux_x86_64
rm -rf release/agent_linux_x86_64
# the agent builds are what new hosts download from the dashboard.
# GOARM=6 also runs on ARMv7, so one arm build covers every Raspberry Pi.
pack-client: signing-key build-client
mkdir -p release/client_linux_x86_64/downloads
cp client/client_linux_x86_64 release/client_linux_x86_64
cd agent && GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build $(LDFLAGS) -o ../release/client_linux_x86_64/downloads/agent-linux-amd64
cd agent && GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build $(LDFLAGS) -o ../release/client_linux_x86_64/downloads/agent-linux-arm64
cd agent && GOOS=linux GOARCH=arm GOARM=6 CGO_ENABLED=0 go build $(LDFLAGS) -o ../release/client_linux_x86_64/downloads/agent-linux-arm
go run ./tools/sign sign -key $(SIGNING_KEY) release/client_linux_x86_64/downloads/agent-linux-amd64 release/client_linux_x86_64/downloads/agent-linux-arm64 release/client_linux_x86_64/downloads/agent-linux-arm
cp client/.env-example release/client_linux_x86_64
cp client/Dockerfile release/client_linux_x86_64
cd release/ && tar -cvf client_linux_x86_64.tar.gz client_linux_x86_64
rm -rf release/client_linux_x86_64