-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
56 lines (47 loc) · 1.54 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
GO := go
DOCKER := docker
SERVER_IMAGE := grpc-rate-limiting-example-server
CLIENT_IMAGE := grpc-rate-limiting-example-client
build: dependencies protoc server client
protoc:
@echo "** Generating Go files from proto"
@cd proto/math && protoc --go_out=plugins=grpc:. *.proto
@echo "** Done"
.PHONY: protoc
dependencies:
@echo "** Getting dependencies"
@$(GO) get google.golang.org/grpc
.PHONY: dependencies
server:
@echo "** Building local server"
@$(GO) build -o bin/server github.com/serhatcetinkaya/grpc-demo-app/app/server
@echo "** Done"
.PHONY: server
client:
@echo "** Building local client"
@$(GO) build -o bin/client github.com/serhatcetinkaya/grpc-demo-app/app/client
@echo "** Done"
.PHONY: client
client-docker:
@echo "** Cross compiling client"
@CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GO) build \
-o bin/client-linux github.com/serhatcetinkaya/grpc-demo-app/app/client
@echo "** Building a docker container for client"
@$(DOCKER) build -f app/client/Dockerfile -t $(CLIENT_IMAGE) .
@echo "** Done"
.PHONY: client-docker
server-docker:
@echo "** Cross compiling server"
@CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GO) build \
-o bin/server-linux github.com/serhatcetinkaya/grpc-demo-app/app/server
@echo "** Building a docker container for server"
@$(DOCKER) build -f app/server/Dockerfile -t $(SERVER_IMAGE) .
@echo "** Done"
.PHONY: server-docker
clean:
@echo "** Cleaning binaries"
@rm -rf bin/*
@echo "** Cleaning docker images"
@$(DOCKER) rmi -f $(SERVER_IMAGE) $(CLIENT_IMAGE) 2>/dev/null 1>&2
@echo "** Done"
.PHONY: clean