-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
111 lines (96 loc) · 3.82 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
GATEWAY_BINARY=gatewayApp
USER_BINARY=userApp
LOGGER_BINARY=loggerApp
DOCUMENT_BINARY=documentApp
## starts all containers in the background without forcing build
up:
@echo "Starting Docker images..."
docker-compose up -d
@echo "Docker images started!"
## Build go binaries
build_go: build_gateway build_user build_document
## stops docker-compose (if running), builds all projects and starts docker compose
up_build: grpc_init_go grpc_init_rust build_go
@echo "Stopping docker images (if running...)"
docker-compose down
@echo "Building (when required) and starting docker images..."
docker-compose up --build -d
@echo "Docker images built and started!"
## stop docker compose
down:
@echo "Stopping docker compose..."
docker-compose down
@echo "Done!"
# start SPA dev server
spa_run_dev:
@echo "Starting SPA dev server..."
cd ./frontend-service && npm run dev
@echo "Done!"
# build proto files and copy them into Go services
grpc_init_go:
@echo "Remove old gateway-service/proto folder"
rm -r gateway-service/proto || true
@echo "Create new gateway-service/proto folders"
mkdir gateway-service/proto gateway-service/proto/user gateway-service/proto/logs gateway-service/proto/document gateway-service/proto/calendar
@echo "Starting proto files generation for Go..."
protoc --go_out=./user-service --go_opt=paths=source_relative --go-grpc_out=./user-service --go-grpc_opt=paths=source_relative proto/user.proto
protoc --go_out=./document-service --go_opt=paths=source_relative --go-grpc_out=./document-service --go-grpc_opt=paths=source_relative proto/document.proto
protoc --go_out=./gateway-service --go_opt=paths=source_relative --go-grpc_out=./gateway-service --go-grpc_opt=paths=source_relative proto/calendar.proto
@echo "Copy pregenerated Go proto files into gateway-service"
cp user-service/proto/* gateway-service/proto/user
cp document-service/proto/* gateway-service/proto/document
@echo "Move calendar files from default folder into nested"
mv gateway-service/proto/calendar*.go gateway-service/proto/calendar
@echo "Done!"
# To init grpc for rust services we need to copy proto files into rust services
# Build proccess will be done by cargo
grpc_init_rust:
@echo "Remove old calendar-serviceproto folder"
rm -r calendar-service/proto || true
@echo "Create new calendar-service/proto folders"
mkdir calendar-service/proto
cp proto/calendar.proto calendar-service/proto
@echo "Done!"
# Lint rust services
lint_rust:
rustfmt calendar-service/src/*.rs --edition 2021
# Lint go services
lint_go:
@echo "Lint documents service:"
cd ./document-service && golangci-lint run
@echo "Lint users service:"
cd ./user-service && golangci-lint run
@echo "Lint gateway service:"
cd ./gateway-service && golangci-lint run
# Build rust
build_rust:
@echo "Building rust services..."
cd ./calendar-service && cargo build
@echo "Done!"
# Download depenedncies for all Go services
download_go_deps:
@echo "Download depenedncies for Go services..."
cd ./document-service && go mod download
cd ./user-service && go mod download
cd ./gateway-service && go mod download
@echo "Done!"
# Download NPM dependecies for SPA
download_npm_deps:
@echo "Download depenedncies for Go services..."
cd ./frontend-service && npm ci
@echo "Done!"
## builds the gateway binary as a linux executable
build_gateway:
@echo "Building broker binary..."
cd ./gateway-service && env GOOS=linux CGO_ENABLED=0 go build -o ${GATEWAY_BINARY} ./cmd/api
@echo "Done!"
## builds the user binary as a linux executable
build_user:
@echo "Building user binary..."
cd ./user-service && env GOOS=linux CGO_ENABLED=0 go build -o ${USER_BINARY} ./cmd/api
@echo "Done!"
## builds the document binary as a linux executable
build_document:
@echo "Building document binary..."
cd ./document-service && env GOOS=linux CGO_ENABLED=0 go build -o ${DOCUMENT_BINARY} ./cmd/api
@echo "Done!"