-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
66 lines (57 loc) · 2.37 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
.PHONY: lint
lint:
golangci-lint run
.PHONY: build
build:
go build -v ./cmd/server
.PHONY: start
start:
server -config config/config.json
PHONY: generate
generate:
mkdir -p pkg/note_v1
protoc --proto_path=api/note_v1 --proto_path=vendor.protogen \
--go_opt=paths=source_relative --go_out=pkg/note_v1 \
--go-grpc_opt=paths=source_relative --go-grpc_out=pkg/note_v1 \
--grpc-gateway_out=pkg/note_v1 \
--grpc-gateway_opt=allow_delete_body=true \
--grpc-gateway_opt=logtostderr=true \
--grpc-gateway_opt=paths=source_relative \
--validate_opt=paths=source_relative --validate_out lang=go:pkg/note_v1 \
--swagger_out=allow_merge=true,merge_file_name=api:pkg/note_v1 \
--swagger_opt=allow_delete_body=true \
api/note_v1/note.proto
PHONY: vendor-proto
vendor-proto:
@if [ ! -d vendor.protogen/google ]; then \
git clone https://github.com/googleapis/googleapis vendor.protogen/googleapis &&\
mkdir -p vendor.protogen/google/ &&\
mv vendor.protogen/googleapis/google/api vendor.protogen/google &&\
rm -rf vendor.protogen/googleapis ;\
fi
@if [ ! -d vendor.protogen/github.com/envoyproxy ]; then \
mkdir -p vendor.protogen/validate &&\
git clone https://github.com/envoyproxy/protoc-gen-validate vendor.protogen/protoc-gen-validate &&\
mv vendor.protogen/protoc-gen-validate/validate/*.proto vendor.protogen/validate &&\
rm -rf vendor.protogen/protoc-gen-validate ;\
fi
@if [ ! -d vendor.protogen/google/protobuf ]; then \
git clone https://github.com/protocolbuffers/protobuf vendor.protogen/protobuf &&\
mkdir -p vendor.protogen/google/protobuf &&\
mv vendor.protogen/protobuf/src/google/protobuf/*.proto vendor.protogen/google/protobuf &&\
rm -rf vendor.protogen/protobuf ;\
fi
LOCAL_MIGRATION_DIR=./migrations
LOCAL_MIGRATION_DSN="host=localhost port=54321 dbname=note-service user=note-service-user password=note-service-password sslmode=disable"
.PHONY: install-goose
.install-goose:
go install github.com/pressly/goose/v3/cmd/goose@latest
.PHONY: local-migration-status
local-migration-status:
goose -dir ${LOCAL_MIGRATION_DIR} postgres ${LOCAL_MIGRATION_DSN} status -v
.PHONY: local-migration-up
local-migration-up:
goose -dir ${LOCAL_MIGRATION_DIR} postgres ${LOCAL_MIGRATION_DSN} up -v
.PHONY: local-migration-down
local-migration-down:
goose -dir ${LOCAL_MIGRATION_DIR} postgres ${LOCAL_MIGRATION_DSN} down -v