-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
158 lines (131 loc) · 5.93 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
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
GOPATH:=$(shell go env GOPATH)
VERSION=$(shell git describe --tags --always)
INTERNAL_PROTO_FILES=$(shell find internal -name *.proto)
CONTAINER_TOOL ?= docker
DRY_RUN=${DRY_RUN:-}
REPO ?= kubesphere
TAG ?= latest
PROXY_IMAGE ?= $(REPO)/model-mesh-proxy:$(TAG)
BROKER_IMAGE ?= $(REPO)/model-mesh-broker:$(TAG)
MSC_IMAGE ?= $(REPO)/model-mesh-msc:$(TAG)
CONTROLLER_TOOLS_VERSION ?= v0.13.0
PLATFORMS ?= linux/arm64,linux/amd64
## Location to install dependencies to
LOCALBIN ?= $(shell pwd)/bin
$(LOCALBIN):
mkdir -p $(LOCALBIN)
CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
.PHONY: init
# init env
init:
go get -d -u github.com/tkeel-io/tkeel-interface/openapi
go get -d -u github.com/tkeel-io/kit
go get -d -u github.com/grpc-ecosystem/grpc-gateway/v2/[email protected]
go install github.com/ocavue/protoc-gen-typescript@latest
go install github.com/tkeel-io/tkeel-interface/tool/cmd/artisan@latest
go install google.golang.org/protobuf/cmd/[email protected]
go install google.golang.org/grpc/cmd/[email protected]
go install github.com/tkeel-io/tkeel-interface/protoc-gen-go-http@latest
go install github.com/tkeel-io/tkeel-interface/protoc-gen-go-errors@latest
go install github.com/grpc-ecosystem/grpc-gateway/v2/[email protected]
.PHONY: proto
proto:
API_PROTO_FILES=( $$(find {api,mindspore_serving} -name '*.proto') ); \
for f in "$${API_PROTO_FILES[@]}"; do \
echo 'Processing '+$$f;\
protoc \
-I ./ \
--gogo_out=plugins=grpc,:.\
--govalidators_out=gogoimport=true,:.\
$$f;\
done
.PHONY: build
# build
build:
mkdir -p bin/ && go build -ldflags "-X main.Version=$(VERSION)" -o ./bin/ ./...
.PHONY: generate
# generate
generate:
go generate ./...
.PHONY: generate
# generate
test: clean
#find . -type f -name '*_test.go' -print0 | xargs -0 -n1 dirname | sort | uniq | xargs -I{} go test -v -vet=all -failfast -race {}
ginkgo -v internal/broker/picker
ginkgo -v tests/e2e
clean:
rm -rf bin/
.PHONY: all
# generate all
all:
make api;
make generate;
# show help
help:
@echo ''
@echo 'Usage:'
@echo ' make [target]'
@echo ''
@echo 'Targets:'
@awk '/^[a-zA-Z\-\_0-9]+:/ { \
helpMessage = match(lastLine, /^# (.*)/); \
if (helpMessage) { \
helpCommand = substr($$1, 0, index($$1, ":")-1); \
helpMessage = substr(lastLine, RSTART + 2, RLENGTH); \
printf "\033[36m%-22s\033[0m %s\n", helpCommand,helpMessage; \
} \
} \
{ lastLine = $$0 }' $(MAKEFILE_LIST)
.DEFAULT_GOAL := help
##@Build
.PHONY: build-broker-image
build-broker-image:
$(CONTAINER_TOOL) build -f build/broker/Dockerfile -t ${BROKER_IMAGE} .
.PHONY: build-proxy-image
build-proxy-image:
$(CONTAINER_TOOL) build -f build/proxy/Dockerfile -t ${PROXY_IMAGE} .
.PHONY: build-msc-image
build-msc-image:
$(CONTAINER_TOOL) build -f build/msc/Dockerfile -t ${MSC_IMAGE} .
.PHONY: build-and-push-all-images
build-and-push-all-images: build-broker-image build-proxy-image build-msc-image
$(CONTAINER_TOOL) push ${PROXY_IMAGE}
$(CONTAINER_TOOL) push ${MSC_IMAGE}
$(CONTAINER_TOOL) push ${BROKER_IMAGE}
.PHONY: build-test-images
build-test-images:
$(CONTAINER_TOOL) build -f tests/mock/app/Dockerfile -t "edgewize/app-mock:latest" .
$(CONTAINER_TOOL) build -f tests/mock/model/Dockerfile -t "edgewize/model-mock:latest" .
.PHONY: docker-buildx-test-images
docker-buildx-test-images:
$(CONTAINER_TOOL) buildx build --builder mybuilder -t "harbor.dev.thingsdao.com/test/app:latest" --platform linux/amd64,linux/arm64 -f tests/mock/app/Dockerfile.buildx --push .
$(CONTAINER_TOOL) buildx build --builder mybuilder -t "harbor.dev.thingsdao.com/test/model:latest" --platform linux/amd64,linux/arm64 -f tests/mock/model/Dockerfile.buildx --push .
.PHONY: docker-buildx-msc-image
docker-buildx-msc-image: ## Build and push docker image for the msc for cross-platform support
# copy existing Dockerfile and insert --platform=${BUILDPLATFORM} into Dockerfile.cross, and preserve the original Dockerfile
sed -e '1 s/\(^FROM\)/FROM --platform=\$$\{BUILDPLATFORM\}/; t' -e ' 1,// s//FROM --platform=\$$\{BUILDPLATFORM\}/' build/msc/Dockerfile > Dockerfile.msc-cross
- $(CONTAINER_TOOL) buildx create --name project-v3-builder
$(CONTAINER_TOOL) buildx use project-v3-builder
- $(CONTAINER_TOOL) buildx build --push --platform=$(PLATFORMS) --tag ${MSC_IMAGE} -f Dockerfile.msc-cross .
- $(CONTAINER_TOOL) buildx rm project-v3-builder
rm Dockerfile.msc-cross
.PHONY: docker-buildx-proxy-image
docker-buildx-proxy-image: ## Build and push docker image for the proxy for cross-platform support
# copy existing Dockerfile and insert --platform=${BUILDPLATFORM} into Dockerfile.cross, and preserve the original Dockerfile
sed -e '1 s/\(^FROM\)/FROM --platform=\$$\{BUILDPLATFORM\}/; t' -e ' 1,// s//FROM --platform=\$$\{BUILDPLATFORM\}/' build/proxy/Dockerfile > Dockerfile.proxy-cross
- $(CONTAINER_TOOL) buildx create --name project-v3-builder
$(CONTAINER_TOOL) buildx use project-v3-builder
- $(CONTAINER_TOOL) buildx build --push --platform=$(PLATFORMS) --tag ${PROXY_IMAGE} -f Dockerfile.proxy-cross .
- $(CONTAINER_TOOL) buildx rm project-v3-builder
rm Dockerfile.proxy-cross
.PHONY: docker-buildx-broker-image
docker-buildx-broker-image: ## Build and push docker image for the broker for cross-platform support
# copy existing Dockerfile and insert --platform=${BUILDPLATFORM} into Dockerfile.cross, and preserve the original Dockerfile
sed -e '1 s/\(^FROM\)/FROM --platform=\$$\{BUILDPLATFORM\}/; t' -e ' 1,// s//FROM --platform=\$$\{BUILDPLATFORM\}/' build/broker/Dockerfile > Dockerfile.broker-cross
- $(CONTAINER_TOOL) buildx create --name project-v3-builder
$(CONTAINER_TOOL) buildx use project-v3-builder
- $(CONTAINER_TOOL) buildx build --push --platform=$(PLATFORMS) --tag ${BROKER_IMAGE} -f Dockerfile.broker-cross .
- $(CONTAINER_TOOL) buildx rm project-v3-builder
rm Dockerfile.broker-cross
.PHONY: build-muti-architecture-images
build-muti-architecture-images: docker-buildx-msc-image docker-buildx-proxy-image docker-buildx-broker-image