forked from alibaba/kt-connect
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
75 lines (60 loc) · 2.47 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
67
68
69
70
71
72
73
74
75
PREFIX ?= registry.cn-hangzhou.aliyuncs.com/rdc-incubator
TAG ?= dev
SHADOW_IMAGE = kt-connect-shadow
SHADOW_BASE_IMAGE = shadow-base
ROUTER_IMAGE = kt-connect-router
NAVIGATOR_IMAGE = kt-connect-navigator
# run mod tidy
mod:
go mod tidy -compat=1.17
# run unit test
test:
mkdir -p artifacts/report/coverage
go test -v -cover -coverprofile artifacts/report/coverage/c.out ./...
go tool cover -html=artifacts/report/coverage/c.out -o artifacts/report/coverage/index.html
# build kt release package
release:
goreleaser --snapshot --skip-publish --rm-dist
# check the style
check:
go vet ./pkg/... ./cmd/...
# build ktctl
ktctl:
go mod download
GOARCH=amd64 GOOS=linux go build -ldflags "-s -w -X main.version=${TAG}" -o artifacts/linux/ktctl ./cmd/ktctl
GOARCH=amd64 GOOS=darwin go build -ldflags "-s -w -X main.version=${TAG}" -o artifacts/macos/ktctl ./cmd/ktctl
GOARCH=amd64 GOOS=windows go build -ldflags "-s -w -X main.version=${TAG}" -o artifacts/windows/ktctl.exe ./cmd/ktctl
# minimize binary size
upx:
upx -9 artifacts/linux/ktctl artifacts/macos/ktctl artifacts/windows/ktctl.exe
# build this image before shadow
shadow-base:
docker build -t $(PREFIX)/$(SHADOW_BASE_IMAGE):$(TAG) -f build/docker/shadow/Dockerfile_base .
# build shadow image
shadow:
GOARCH=amd64 GOOS=linux go build -gcflags "all=-N -l" -o artifacts/shadow/shadow-linux-amd64 cmd/shadow/main.go
docker build -t $(PREFIX)/$(SHADOW_IMAGE):$(TAG) -f build/docker/shadow/Dockerfile .
# shadow with dlv
shadow-dlv:
make shadow TAG=latest
scripts/build-shadow-dlv
# shadow for local debug
shadow-local:
go build -gcflags "all=-N -l" -o artifacts/shadow/shadow-local cmd/shadow/main.go
# build router image
router:
GOARCH=amd64 GOOS=linux go build -gcflags "all=-N -l" -o artifacts/router/router-linux-amd64 cmd/router/main.go
docker build -t $(PREFIX)/$(ROUTER_IMAGE):$(TAG) -f build/docker/router/Dockerfile .
# build this image before navigator
navigator-base:
docker build -t $(PREFIX)/$(NAVIGATOR_BASE_IMAGE):$(TAG) -f build/docker/navigator/Dockerfile_base .
# build navigator image
navigator:
GOARCH=amd64 GOOS=linux go build -gcflags "all=-N -l" -o artifacts/navigator/navigator-linux-amd64 cmd/navigator/main.go
docker build -t $(PREFIX)/$(NAVIGATOR_IMAGE):$(TAG) -f build/docker/navigator/Dockerfile .
# navigator for local debug
navigator-local:
go build -gcflags "all=-N -l" -o artifacts/navigator/navigator cmd/navigator/main.go
# clean up workspace
clean:
rm -fr artifacts output dist