-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
63 lines (47 loc) · 2.04 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
.PHONY: init install test build clean pack deploy ship compile_proto generate_gw generate_swagger
include .env
export $(shell sed 's/=.*//' .env)
#APP_NAME=$(shell basename $(CURDIR))
#TAG?=$(shell git rev-list HEAD --max-count=1 --abbrev-commit)
APP_NAME=marbles-api
TAG=latest
export TAG
export APP_NAME
init:
rm -rf ./dist/ && mkdir dist
install: init
dep ensure
test: init
go test ./...
build: init
cd dist; mkdir grpc; cp ../config ./grpc -r
cd cmd/grpc; GOOS=linux GOARCH=amd64 go build -ldflags "-X main.version=$(TAG)" -o ../../dist/grpc/app .
cd cmd/gw; GOOS=linux GOARCH=amd64 go build -ldflags "-X main.version=$(TAG)" -o ../../dist/gw/app .
clean:
rm ./dist/ -rf
pack:
docker build -t asia.gcr.io/fabric-blockchain/$(APP_NAME)-grpc:$(TAG) .
docker build --build-arg TARGET="gw" -t asia.gcr.io/fabric-blockchain/$(APP_NAME)-gw:$(TAG) .
pack1:
#docker build --build-arg TARGET="grpc" -t asia.gcr.io/fabric-blockchain/$(APP_NAME)-grpc:$(TAG) .
#docker build --build-arg TARGET="gw" -t asia.gcr.io/fabric-blockchain/$(APP_NAME)-gw:$(TAG) .
upload:
gcloud docker -- push asia.gcr.io/fabric-blockchain/$(APP_NAME)-grpc:$(TAG)
gcloud docker -- push asia.gcr.io/fabric-blockchain/$(APP_NAME)-gw:$(TAG)
deploy:
envsubst < k8s/deployment.yaml | kubectl apply -f -
envsubst < k8s/service.yaml | kubectl apply -f -
envsubst < k8s/ingress.yaml | kubectl apply -f -
ship: init test pack upload deploy clean
compile_proto:
cd ./api/; protoc -I. -I$(GOPATH)/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis -I$(GOPATH)/src --go_out=plugins=grpc:$(GOPATH)/src/ proto/*.proto
generate_gw:
cd ./api/; protoc -I/usr/local/include -I. \
-I$(GOPATH)/src \
-I$(GOPATH)/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \
--grpc-gateway_out=logtostderr=true:$(GOPATH)/src/ proto/marbles.srv.proto
generate_swagger:
cd ./api/; protoc -I/usr/local/include -I. \
-I$(GOPATH)/src \
-I$(GOPATH)/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \
--swagger_out=logtostderr=true:. proto/marbles.srv.proto