-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
98 lines (71 loc) · 2.76 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
.PHONY: all help install install-client install-go lint lint-client lint-go migrate codegen codegen-client codegen-go codegen-proto build build-client build-go clean test dev docker-dev docker-dev-down client-dev questionsgen docker-images docker-image-api docker-image-generator
GOCMD = go
JSCMD = pnpm
DOCKER_COMPOSE = docker compose -f infra/docker/docker-compose.dev.yml
DOCKER_EXEC = docker exec quizory go run
GOTOOL = $(GOCMD) tool
BINARIES_DIR = out
CLIENT_DIR = client
all: help
help:
@echo "install : Installs the dependencies (Go & JS)."
@echo "lint : Runs linters (golangci-lint & eslint)."
@echo "migrate : Runs database migrations."
@echo "codegen : Runs codegen tools."
@echo "build : Builds the project."
@echo "clean : Removes the outputs generated by the build command."
@echo "test : Runs tests."
@echo "dev : Runs the local Docker infra, client, and API server in dev mode."
@echo "questionsgen : Runs the the questions generation once."
@echo "docker-images : Builds the backend Docker images."
install: install-go install-client
install-client:
cd $(CLIENT_DIR) && $(JSCMD) install
install-go:
$(GOCMD) install google.golang.org/protobuf/cmd/[email protected] && \
$(GOCMD) install google.golang.org/grpc/cmd/[email protected] && \
$(GOCMD) mod tidy
lint: lint-go lint-client
lint-client:
cd $(CLIENT_DIR) && $(JSCMD) lint
lint-go:
golangci-lint run
migrate:
$(DOCKER_EXEC) ./cmd/migrate
codegen: codegen-go codegen-client codegen-proto
codegen-client:
cd $(CLIENT_DIR) && $(JSCMD) codegen
codegen-go:
$(DOCKER_EXEC) ./cmd/codegen
codegen-proto:
protoc --proto_path=http/grpc/proto \
--go_out=paths=source_relative:http/grpc/proto \
--go-grpc_out=paths=source_relative:http/grpc/proto \
http/grpc/proto/*.proto
build: install build-go build-client
build-client:
cd $(CLIENT_DIR) && $(JSCMD) build
build-go:
$(GOCMD) build -o $(BINARIES_DIR)/api -v ./cmd/api
clean:
rm -rf $(BINARIES_DIR) && rm -rf $(CLIENT_DIR)/dist && rm -rf $(CLIENT_DIR)/src/generated/api/apis
test:
$(GOCMD) test -race -shuffle=on ./...
dev:
@sh -c '\
$(MAKE) docker-dev & DOCKER_PID=$$!; \
$(MAKE) client-dev & CLIENT_PID=$$!; \
wait $$DOCKER_PID $$CLIENT_PID'
docker-dev:
$(DOCKER_COMPOSE) up $(ARGS)
docker-dev-down:
$(DOCKER_COMPOSE) down
client-dev:
cd $(CLIENT_DIR) && $(JSCMD) dev
questionsgen: docker-image-generator
docker run --rm --network docker_quizory --env-file .env.quizory sasalatart/quizory-generator
docker-images: docker-image-api docker-image-generator
docker-image-api:
docker build -t sasalatart/quizory-api -f ./infra/docker/Dockerfile.api .
docker-image-generator:
docker build -t sasalatart/quizory-generator -f ./infra/docker/Dockerfile.generator .