-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
135 lines (90 loc) · 3.87 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
134
135
.PHONY:
run_api_gateway:
go run api_gateway_service/cmd/main.go -config=./api_gateway_service/config/config.yaml
run_writer_microservice:
go run writer_service/cmd/main.go -config=./writer_service/config/config.yaml
run_reader_microservice:
go run writer_service/cmd/main.go -config=./writer_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
# ==============================================================================
# MongoDB
mongo:
cd ./scripts && mongo admin -u admin -p admin < init.js
# ==============================================================================
# Swagger
swagger:
@echo Starting swagger generating
swag init -g **/**/*.go
# ==============================================================================
# Proto
proto_kafka:
@echo Generating kafka proto
cd proto/kafka && protoc --go_out=. --go-grpc_opt=require_unimplemented_servers=false --go-grpc_out=. kafka.proto
proto_writer:
@echo Generating product writer microservice proto
cd writer_service/proto/product_writer && protoc --go_out=. --go-grpc_opt=require_unimplemented_servers=false --go-grpc_out=. product_writer.proto
proto_writer_message:
@echo Generating product writer messages microservice proto
cd writer_service/proto/product_writer && protoc --go_out=. --go-grpc_opt=require_unimplemented_servers=false --go-grpc_out=. product_writer_messages.proto
proto_reader:
@echo Generating product reader microservice proto
cd reader_service/proto/product_reader && protoc --go_out=. --go-grpc_opt=require_unimplemented_servers=false --go-grpc_out=. product_reader.proto
proto_reader_message:
@echo Generating product reader messages microservice proto
cd reader_service/proto/product_reader && protoc --go_out=. --go-grpc_opt=require_unimplemented_servers=false --go-grpc_out=. product_reader_messages.proto