-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
61 lines (50 loc) · 1.67 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
RELEASE?=$(shell git describe --tags --abbrev=0 --exact-match 2>/dev/null || echo "latest")
COMMIT?=$(shell git rev-parse --short HEAD)
BUILD?=$(shell date +"%Y-%m-%dT%H:%M:%S%:z")
PROJECT=github.com/tianhanfangyan/grpc-app
GOFILES=`find . -name "*.go" -type f -not -path "./vendor/*"`
.PHONY: vendor
vendor:
go mod vendor
fmt:
@gofmt -w ${GOFILES}
grpc-gen:
protoc --proto_path=api/proto \
--proto_path=third_party \
--go_out=plugins=grpc:pkg/api \
api/proto/*.proto
grpc-gateway:
protoc --proto_path=api/proto \
--proto_path=third_party \
--grpc-gateway_out=logtostderr=true:pkg/api \
api/proto/*.proto
grpc-swagger:
protoc --proto_path=api/proto \
--proto_path=third_party \
--swagger_out=logtostderr=true:api/swagger \
api/proto/*.proto
grpc: grpc-gen grpc-gateway grpc-swagger
app:
go build \
-mod=vendor \
-ldflags "-s -w \
-X ${PROJECT}/version.Release=${RELEASE} \
-X ${PROJECT}/version.Commit=${COMMIT} \
-X ${PROJECT}/version.Build=${BUILD}" \
-o ./grpc-app \
./main.go
image: grpc
docker build -t grpc-app \
--build-arg RELEASE=${RELEASE} \
--build-arg COMMIT=${COMMIT} \
--build-arg BUILD=${BUILD} \
--build-arg GOPROXY=https://goproxy.cn \
.
doc: grpc-swagger
docker run -d --name grpc-app-doc \
-p 8080:8080 \
-v ${PWD}/api/swagger:/data \
-e "SWAGGER_JSON=/data/student.swagger.json" \
-e "VALIDATOR_URL=null" \
-e 'DEFAULT_MODELS_EXPAND_DEPTH=-1' \
swaggerapi/swagger-ui:v3.22.0