-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
94 lines (67 loc) · 3 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
pwd = C:\Users\morka_joshua\StudioProjects\GoProjects\shinybank
# dburl = shine-bank.cwaywcycutdv.us-east-1.rds.amazonaws.com
dburl = localhost:5432
dbname=shiny_bank
build:
CGO_ENABLED=0 GOOS=linux go build -o main
run: build
@./bin/microservices2
postgres:
docker run --name postgres12 --network api-bank-network -p 5432:5432 -e POSTGRES_USER=root -e POSTGRES_PASSWORD=secret -d postgres:alpine
createdb:
docker exec -it postgres12 createdb --username=root --owner=root shiny_bank
dropdb:
docker exec -it postgres12 dropdb shiny_bank
createmigrate:
migrate create -ext sql -dir ./src/db/migration -seq $(name)
migrateup:
migrate -path ./src/db/migration -database "postgresql://root:secret@$(dburl)/$(dbname)?sslmode=disable" -verbose up
migrateup1:
migrate -path ./src/db/migration -database "postgresql://root:secret@$(dburl)/$(dbname)?sslmode=disable" -verbose up 1
migrateup2:
migrate -path ./src/db/migration -database "postgresql://root:secret@$(dburl)/$(dbname)?sslmode=disable" -verbose up 2
migratedown:
migrate -path src/db/migration -database "postgresql://root:secret@$(dburl)/$(dbname)?sslmode=disable" -verbose down
migratedown1:
migrate -path src/db/migration -database "postgresql://root:secret@$(dburl)/$(dbname)?sslmode=disable" -verbose down 1
sqlc:
docker run --rm -v $(pwd):/src -w /src kjconroy/sqlc generate
# sqlc generate
mockgenstore:
mockgen -package mockdb -destination src/db/mock/store.go github.com/morka17/shiny_bank/v1/src/db/sqlc Store
mockgen -package mockwk -destination src/worker/mock/distributor.go github.com/morka17/shiny_bank/v1/src/worker TaskDistributor
db_docs:
dbdocs build doc/db.dbml
db_schema:
dbml2sql --postgres -o doc/schema.sql doc/db.dbml
server:
go run main.go
docker:
docker build -t shinybank:latest .
dockerContainer:
docker run --name shinybank --network api-bank-network -p 8080:8080 -e GIN_MODE=release -e DB_Source="postgresql://root:secret@postgres12:5432/shiny_bank?sslmode=disable" shinybank:latest
createdockernetwork:
docker network create api-bank-network
connectdockernetwork:
docker network connect api-bank-network postgres12
proto:
rm -f pb/*.go
rm -f doc/swagger/*.swagger.json
# protoc --proto_path=proto --go_out=pb --go_opt=paths=source_relative \
# --go-grpc_out=pb --go-grpc_opt=paths=source_relative \
# --go-gateway_out=pb --grpc-gateway_opt=paths=source_relative \
# proto/*.proto
protoc -I ./proto \
--go_out ./pb --go_opt paths=source_relative \
--go-grpc_out ./pb --go-grpc_opt paths=source_relative \
--grpc-gateway_out ./pb --grpc-gateway_opt paths=source_relative \
--openapiv2_out ./doc/swagger --openapiv2_opt allow_merge=true,merge_file_name=shiny_bank\
./proto/*.proto
statik -src=./doc/swagger -dest=./doc
evans:
evans --host localhost --port 9090 -r repl
redis:
docker run --name redis -p 6379:6379 -d redis:7-alpine
test:
go test -v -cover -short ./...
.PHONY: postgres mockgenstore createdb db_docs db_schema dropdb migrateup migrateup1 migratedown1 migratedown sqlc test server proto