forked from AleksK1NG/Go-CQRS-Kafka-gRPC-Microservices
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
133 lines (90 loc) · 3.62 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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
.PHONY:
run_gw:
go run api_gateway_service/cmd/main.go -config=./api_gateway_service/config/config.yaml
run_core:
go run core_service/cmd/main.go -config=./core_service/config/config.yaml
run_graph:
go run graphql_service/cmd/main.go -config=./graphql_service/config/config.yaml
# ==============================================================================
# Docker
docker_dev:
@echo Starting local docker dev compose
docker-compose -f docker-compose.yaml up --build
local:
@echo Starting local docker compose
docker-compose -f docker-compose.local.yaml up -d --build
# ==============================================================================
# Docker support
FILES := $(shell docker ps -aq)
down-local:
docker stop $(FILES)
docker rm $(FILES)
clean:
docker system prune -f
logs-local:
docker logs -f $(FILES)
# ==============================================================================
# Modules support
tidy:
go mod tidy
deps-reset:
git checkout -- go.mod
go mod tidy
deps-upgrade:
go get -u -t -d -v ./...
go mod tidy
deps-cleancache:
go clean -modcache
# ==============================================================================
# Linters https://golangci-lint.run/usage/install/
run-linter:
@echo Starting linters
golangci-lint run ./...
# ==============================================================================
# PPROF
pprof_heap:
go tool pprof -http :8006 http://localhost:6060/debug/pprof/heap?seconds=10
pprof_cpu:
go tool pprof -http :8006 http://localhost:6060/debug/pprof/profile?seconds=10
pprof_allocs:
go tool pprof -http :8006 http://localhost:6060/debug/pprof/allocs?seconds=10
# ==============================================================================
# Go migrate postgresql https://github.com/golang-migrate/migrate
DB_NAME = products
DB_HOST = localhost
DB_PORT = 5432
SSL_MODE = disable
force_db:
migrate -database postgres://postgres:postgres@$(DB_HOST):$(DB_PORT)/$(DB_NAME)?sslmode=$(SSL_MODE) -path migrations force 1
version_db:
migrate -database postgres://postgres:postgres@$(DB_HOST):$(DB_PORT)/$(DB_NAME)?sslmode=$(SSL_MODE) -path migrations version
migrate_up:
migrate -database postgres://postgres:postgres@$(DB_HOST):$(DB_PORT)/$(DB_NAME)?sslmode=$(SSL_MODE) -path migrations up 1
migrate_down:
migrate -database postgres://postgres:postgres@$(DB_HOST):$(DB_PORT)/$(DB_NAME)?sslmode=$(SSL_MODE) -path migrations down 1
# ==============================================================================
# Swagger
swagger:
@echo Starting swagger generating
swag init -g api_gateway_service/cmd/main.go
# ==============================================================================
# Proto
proto_kafka:
@echo Generating kafka proto
cd proto && protoc --go_out=. --go-grpc_opt=require_unimplemented_servers=false --go-grpc_out=. kafka.proto
proto_auth:
@echo Generating authorization microservice proto
cd auth_service/proto && protoc --go_out=. --go-grpc_opt=require_unimplemented_servers=false --go-grpc_out=. --proto_path=. auth_service.proto auth_dto.proto
proto_core:
@echo Generating connector microservice proto
cd core_service/proto && protoc --go_out=. --go-grpc_opt=require_unimplemented_servers=false --go-grpc_out=. core_svc.proto core_messages.proto
# ==============================================================================
# Evans
evans_core:
@echo Run grpc client with core proto
cd core_service/proto && evans core_svc.proto -p 5003
# ==============================================================================
# gqlgen
gqlgen:
@echo Generating GraphQL modules
cd .data/gqlgen && go run -mod=mod github.com/99designs/gqlgen --verbose gener