-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
167 lines (136 loc) · 2.83 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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
DB_URL = postgresql://root:secretpassword@localhost:5433/simple_bank?sslmode=disable
pull-postgres:
docker pull postgres:16.0-alpine3.18
start-postgres:
docker \
run \
--name postgres16-alpine \
--network bank-network \
-p 5433:5432 \
-e POSTGRES_USER=root \
-e POSTGRES_PASSWORD=secretpassword \
-d \
postgres:16.0-alpine3.18
logs-postgres:
docker logs -f postgres16-alpine
createdb:
docker \
exec \
-it \
postgres16-alpine \
createdb --username=root --owner=root simple_bank
dropdb:
docker exec -it postgres16-alpine dropdb simple_bank
migrateup-all:
migrate \
-path db/migration \
-database "${DB_URL}" \
-verbose \
up
migrateup-1:
migrate \
-path db/migration \
-database "${DB_URL}" \
-verbose \
up 1
migratedown-all:
migrate \
-path db/migration \
-database "${DB_URL}" \
-verbose \
down
migratedown-1:
migrate \
-path db/migration \
-database "${DB_URL}" \
-verbose \
down 1
sqlc:
sqlc generate
test:
go test -v -cover ./... -count=1
psql-console:
docker exec -it postgres16-alpine psql -U root -d simple_bank
server:
go run main.go
build-app-image:
docker build -t simple-bank:latest .
start-app-dev:
docker \
run \
--name simple-bank \
-p 8080:8080 \
-d \
simple-bank:latest
start-app-prod:
docker \
run \
--name simple-bank \
--network bank-network \
-p 8080:8080 \
-e GIN_MODE=release \
-e DB_SOURCE=postgresql://root:secretpassword@postgres16-alpine:5432/simple_bank?sslmode=disable \
-d \
simple-bank:latest
logs-app:
docker logs -f simple-bank-api-1
compose-up-prod:
docker compose -f compose.prod.yaml up -d
compose-down-prod:
docker compose -f compose.prod.yaml down
compose-up-dev:
docker compose -f compose.dev.yaml up -d
compose-down-dev:
docker compose -f compose.dev.yaml down
delete-image:
docker rmi simple-bank-api
logs-all:
docker-compose logs -t -f
mock:
mockgen \
-package mockdb \
-destination db/mock/store.go \
github.com/aryyawijaya/simple-bank/db/sqlc Store
format:
go fmt ./...
query-update:
make sqlc mock
db-docs:
dbdocs build doc/db.dbml
db-schema:
dbml2sql doc/db.dbml --postgres -o doc/schema.sql
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 \
--grpc-gateway_out=pb --grpc-gateway_opt=paths=source_relative \
--openapiv2_out=doc/swagger \
--openapiv2_opt=allow_merge=true,merge_file_name=simple_bank \
proto/*.proto
evans:
evans --host localhost --port 8081 -r repl
.PHONY: \
pull-postgres \
start-postgres \
logs-postgres \
createdb \
dropdb \
migrateup-all \
migrateup-1 \
migratedown-all \
migratedown-1 \
sqlc \
test \
server \
build-app-image \
start-app \
mock \
format \
query-update \
db-docs \
db-schema \
proto \
evans \