-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
58 lines (45 loc) · 1.79 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
GO111MODULE:=on
GOBIN:=$(GOPATH)/bin
PATH:=$(GOBIN):$(PATH)
PROJECT_NAME:=enterprise_application
PROJECT_DIR:=$(shell pwd)
GEN_DIR:=$(PROJECT_DIR)/pkg/common/gen
BUILD_DIR:=$(PROJECT_DIR)/build
VENDOR_DIR:=$(PROJECT_DIR)/vendor
DOCKER_COMPOSE:=$(PROJECT_DIR)/deployments/docker-compose.yml
export
define build_app
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o $(BUILD_DIR)/$(1)/main.go $(PROJECT_DIR)/cmd/$(1)/main.go
endef
clean:
rm -rf $(VENDOR_DIR)
install: clean
go get google.golang.org/grpc
go install google.golang.org/protobuf/cmd/[email protected]
go install google.golang.org/grpc/cmd/[email protected]
go install github.com/grpc-ecosystem/grpc-gateway/v2/[email protected]
go install github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2
go install github.com/alta/protopatch/cmd/protoc-gen-go-patch@latest
vendor:
go mod vendor
buf_update:
buf mod update
buf_generate: clean
rm -rf $(GEN_DIR)
buf generate
make vendor
build_apps:
rm -rf $(BUILD_DIR)
@$(foreach BUILD_APP, $(shell ls $(PROJECT_DIR)/cmd), CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o $(BUILD_DIR)/$(BUILD_APP) $(PROJECT_DIR)/cmd/$(BUILD_APP)/main.go;)
up: build_apps
docker-compose -p $(PROJECT_NAME) -f $(DOCKER_COMPOSE) up -d --build --force-recreate
down:
docker-compose -p $(PROJECT_NAME) -f $(DOCKER_COMPOSE) down --remove-orphans
docker image prune -f
docker volume prune -f
restart: down up
run: build_apps
docker-compose -p $(PROJECT_NAME) -f $(DOCKER_COMPOSE) up --build --force-recreate
cert_generate:
openssl req -newkey rsa -x509 -sha256 -days 3650 -nodes -out ${PROJECT_DIR}/configs/ssl/crt.pem -keyout ${PROJECT_DIR}/configs/ssl/private.key.pem
openssl rsa -in ${PROJECT_DIR}/configs/ssl/private.key.pem -outform PEM -pubout -out ${PROJECT_DIR}/configs/ssl/public.key.pem