-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
105 lines (84 loc) · 2.59 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
VERSION := 1.0.0
COMMIT_HASH := $(shell git rev-parse HEAD)
PROJECT_NAME := ojs
.PHONY: database
database:
docker run --name mysql -d -p 3306:3306 -e MYSQL_ROOT_PASSWORD=secret -e MYSQL_DATABASE=ojs mysql:8.3.0 --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
.PHONY: new_migration
new_migration:
migrate create -ext sql -dir ./internal/dataaccess/database/migrations/mysql -seq $(NAME)
.PHONY: up_migration
up_migration:
migrate -path ./internal/dataaccess/database/migrations/mysql -database "mysql://root:secret@tcp(0.0.0.0:3306)/ojs?charset=utf8mb4&parseTime=True&loc=Local" -verbose up $(STEP)
.PHONY: down_migration
down_migration:
migrate -path ./internal/dataaccess/database/migrations/mysql -database "mysql://root:secret@tcp(0.0.0.0:3306)/ojs?charset=utf8mb4&parseTime=True&loc=Local" -verbose down $(STEP)
.PHONY: proto
proto:
protoc \
-I api \
--go_out=./internal/generated \
--go-grpc_out=./internal/generated \
--validate_out="lang=go:./internal/generated" \
--openapiv2_out=./api/v1 \
--grpc-gateway_out ./internal/generated --grpc-gateway_opt generate_unbound_methods=true \
--experimental_allow_proto3_optional \
api/ojs.proto
.PHONY: wire
wire:
wire ./internal/wiring/wire.go
.PHONY: openapi
openapi:
openapi-generator-cli generate \
-i api/v1/ojs.swagger.json \
-g javascript \
-o web/src/api
.PHONY: generate
generate:
make proto
make wire
make openapi
.PHONY: tidy
tidy:
go mod tidy
.PHONY: build-web
build-web:
cd web/src/api && npm install && cd ../../../
cd web && npm install && npm run build && cd ..
.PHONY: build-backend
build-backend:
go build \
-ldflags "-X main.version=$(VERSION) -X main.commitHash=$(COMMIT_HASH)" \
-o build/$(PROJECT_NAME) \
cmd/$(PROJECT_NAME)/*.go
.PHONY: build
build:
make build-web
make build-backend
.PHONY: standalone-server
standalone-server:
go run ./cmd/ojs/main.go standalone-server
.PHONY: http-server
http-server:
go run ./cmd/ojs/main.go http-server
.PHONY: worker
worker:
go run ./cmd/ojs/main.go worker
.PHONY: cron
cron:
go run ./cmd/ojs/main.go cron
.PHONY: docker-compose-dev-up
docker-compose-dev-up:
docker compose -f ./internal/deployments/docker-compose.dev.yml up -d
.PHONY: docker-compose-dev-down
docker-compose-dev-down:
docker compose -f ./internal/deployments/docker-compose.dev.yml down
.PHONY: docker-compose-prod-up
docker-compose-prod-up:
docker compose -f ./internal/deployments/docker-compose.prod.yml up -d
.PHONY: docker-compose-prod-down
docker-compose-prod-down:
docker compose -f ./internal/deployments/docker-compose.prod.yml down
.PHONY: run
run:
./build/ojs standalone-server