-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
81 lines (62 loc) · 3.58 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
PROJECT_NAME=pandemic-api
SERVICE_OUT := server.bin
PKG := github.com/gidyon/pandemic-api
SERVICE_PKG_BUILD := ${PKG}/cmd/gateway
API_IN_PATH := api/proto
API_OUT_PATH := pkg/api
SWAGGER_DOC_OUT_PATH := api/swagger
setup_dev: ## start development databases
cd deployments/docker-compose && docker-compose up -d
teardown_dev: ## stop development databases
cd deployments/docker-compose && docker-compose down
run: ## run compiled binary
./$(SERVICE_OUT)
run_gateway: ## go run server
go run cmd/gateway/*.go
run_messaging:
cd cmd/messaging && go build -o service && FCM_SERVER_KEY=abc ./service -config-file=/home/gideon/go/src/github.com/gidyon/pandemic-api/configs/messaging_dev.yml
run_tracing:
cd cmd/tracing && go build -o service && ./service -config-file=/home/gideon/go/src/github.com/gidyon/pandemic-api/configs/tracing_dev.yml
run_location:
cd cmd/location && go build -o service && ./service -config-file=/home/gideon/go/src/github.com/gidyon/pandemic-api/configs/location_dev.yml
run_rest:
cd cmd/restful && go build -o service && ROOT_DIR=/home/gideon/go/src/github.com/gidyon/pandemic-api/api/json ./service -config-file=/home/gideon/go/src/github.com/gidyon/pandemic-api/configs/restful_dev.yml
run_pusher:
cd cmd/pusher && go build -o service && FCM_SERVER_KEY=AAAApoeNiqU:APA91bH7JMT0ITyGESfWtKzP8901ja834A_u4DP6rXw92OgujEPVJzqlL2fRyMjfU6yakaDGiGVaBBRfW-lwX7AGtBd_Ub1YZP4RMaIqCLkEZ18TD55oEReMu2ge5no1RQ5d7frrkEYW ./service -config-file=/home/gideon/go/src/github.com/gidyon/pandemic-api/configs/pusher_dev.yml
# ==============================================================================
proto_compile_location:
protoc -I=$(API_IN_PATH) -I=third_party --go_out=plugins=grpc:$(API_OUT_PATH)/location location.proto &&\
protoc -I=$(API_IN_PATH) -I=third_party --grpc-gateway_out=logtostderr=true:$(API_OUT_PATH)/location location.proto &&\
protoc -I=$(API_IN_PATH) -I=third_party --swagger_out=logtostderr=true:$(SWAGGER_DOC_OUT_PATH) location.proto
proto_compile_tracing:
protoc -I=$(API_IN_PATH) -I=third_party --go_out=plugins=grpc:$(API_OUT_PATH)/contact_tracing contact.tracing.proto &&\
protoc -I=$(API_IN_PATH) -I=third_party --grpc-gateway_out=logtostderr=true:$(API_OUT_PATH)/contact_tracing contact.tracing.proto &&\
protoc -I=$(API_IN_PATH) -I=third_party --swagger_out=logtostderr=true:$(SWAGGER_DOC_OUT_PATH) contact.tracing.proto
proto_compile_messaging:
protoc -I=$(API_IN_PATH) -I=third_party --go_out=plugins=grpc:$(API_OUT_PATH)/messaging messaging.proto &&\
protoc -I=$(API_IN_PATH) -I=third_party --grpc-gateway_out=logtostderr=true:$(API_OUT_PATH)/messaging messaging.proto &&\
protoc -I=$(API_IN_PATH) -I=third_party --swagger_out=logtostderr=true:$(SWAGGER_DOC_OUT_PATH) messaging.proto
proto_compile: proto_compile_location proto_compile_tracing proto_compile_messaging
compile_gateway:
go build -o service -i -v -o gateway $(SERVICE_PKG_BUILD)
docker_build: ## Create a docker image for the service
ifdef tag
@docker build -t gidyon/$(PROJECT_NAME):$(tag) .
else
@docker build -t gidyon/$(PROJECT_NAME):latest .
endif
docker_tag: ## Tag image
ifdef tag
@docker tag gidyon/$(PROJECT_NAME):$(tag) gidyon/$(PROJECT_NAME):$(tag)
else
@docker tag gidyon/$(PROJECT_NAME):latest gidyon/$(PROJECT_NAME):latest
endif
docker_push: ## Push image
ifdef tag
@docker push gidyon/$(PROJECT_NAME):$(tag)
else
@docker push gidyon/$(PROJECT_NAME):latest
endif
build_and_push: compile_gateway docker_build docker_tag docker_push
help: ## Display this help screen
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'