-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
122 lines (93 loc) · 3.31 KB
/
Copy pathMakefile
File metadata and controls
122 lines (93 loc) · 3.31 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
VERSION ?= 0.0.1-dev
COMMIT ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo unknown)
LDFLAGS := -X github.com/marstack-labs/marstack-cloud/internal/version.Version=$(VERSION) \
-X github.com/marstack-labs/marstack-cloud/internal/version.Commit=$(COMMIT)
GOBIN ?= $(shell go env GOPATH)/bin
PREFIX ?= /usr/local
DIST ?= dist
TARGETS ?= linux/amd64 linux/arm64 darwin/arm64
.PHONY: build install uninstall test vet cross dist docs site fmt staticcheck vuln gosec secrets security check tools hooks run stage-images dev-up dev-down dev-logs dev-reset clean
site:
cp web/console/meridian.css site/meridian.css
docs: build
./bin/marstack docs --out docs/cli.md
build:
go build -ldflags "$(LDFLAGS)" -o bin/marstack ./cmd/marstack
install:
install -d $(DESTDIR)$(PREFIX)/bin
install -m 0755 bin/marstack $(DESTDIR)$(PREFIX)/bin/marstack
uninstall:
rm -f $(DESTDIR)$(PREFIX)/bin/marstack
test:
go test -race ./...
vet:
go vet ./...
fmt:
gofmt -l -w .
staticcheck:
$(GOBIN)/staticcheck ./...
vuln:
$(GOBIN)/govulncheck ./...
gosec:
$(GOBIN)/gosec -quiet -severity medium -confidence medium -exclude=G124,G204,G301,G302,G304,G306,G703 ./...
secrets:
gitleaks detect --redact --no-banner
security: vuln gosec
check: vet cross test staticcheck security
cross:
GOOS=linux GOARCH=arm64 go build ./...
GOOS=linux GOARCH=arm64 go vet ./...
GOOS=linux GOARCH=amd64 go build ./...
GOOS=linux GOARCH=amd64 go vet ./...
GOOS=darwin GOARCH=arm64 go build ./...
dist:
rm -rf $(DIST)
mkdir -p $(DIST)
@for target in $(TARGETS); do \
os=$${target%/*}; arch=$${target#*/}; \
stage=$(DIST)/marstack_$(VERSION)_$${os}_$${arch}; \
mkdir -p $$stage || exit 1; \
echo "building $$os/$$arch"; \
GOOS=$$os GOARCH=$$arch CGO_ENABLED=0 \
go build -trimpath -ldflags "$(LDFLAGS)" -o $$stage/marstack ./cmd/marstack || exit 1; \
cp LICENSE README.md $$stage/ || exit 1; \
tar -C $(DIST) -czf $$stage.tar.gz $$(basename $$stage) || exit 1; \
rm -rf $$stage; \
done
@stage=$(DIST)/marstack_console_$(VERSION); \
mkdir -p $$stage && cp web/console/index.html web/console/meridian.css LICENSE $$stage/ && \
tar -C $(DIST) -czf $$stage.tar.gz marstack_console_$(VERSION) && rm -rf $$stage && \
echo "packed the console"
cd $(DIST) && shasum -a 256 *.tar.gz > SHA256SUMS
@ls -l $(DIST)
tools:
go install honnef.co/go/tools/cmd/staticcheck@latest
go install golang.org/x/vuln/cmd/govulncheck@latest
go install github.com/securego/gosec/v2/cmd/gosec@latest
hooks:
git config core.hooksPath .githooks
chmod +x .githooks/pre-commit
run: build
./bin/marstack server
DEV_DATA ?= $(HOME)/marstack-data
DEV_LOGS ?= $(HOME)
DEV_NODE ?= bm-1
DEV_ZONE ?= rack-a
stage-images:
sudo -E scripts/stage-images.sh
dev-up: build
@$(MAKE) --no-print-directory dev-down
setsid nohup ./bin/marstack server --data-dir $(DEV_DATA) > $(DEV_LOGS)/ms-server.log 2>&1 < /dev/null &
@sleep 2
setsid sudo nohup ./bin/marstack agent --name $(DEV_NODE) --zone $(DEV_ZONE) > $(DEV_LOGS)/ms-agent.log 2>&1 < /dev/null &
@sleep 3
@./bin/marstack node list
dev-down:
@for p in $$(pgrep -x marstack); do sudo kill $$p 2>/dev/null || true; done; sleep 1
dev-logs:
@tail -n 30 $(DEV_LOGS)/ms-server.log $(DEV_LOGS)/ms-agent.log
dev-reset: dev-down
rm -rf $(DEV_DATA)
sudo rm -rf /var/lib/marstack/instances
clean:
rm -rf bin dist data coverage.out