-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
executable file
·143 lines (111 loc) · 4.16 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
INTERNAL_PKG = ./internal/...
ALL_PKG = ./internal/... ./pkg/...
COV_DIR = scripts/result_cover
include .env
export
build:
sudo systemctl stop nginx.service || true
sudo systemctl stop postgresql || true
mkdir -p -m 777 logs/postgres
mkdir -p -m 777 logs/app
docker-compose up -d --build --remove-orphans
build-binaries:
go build cmd/api/main.go
go build cmd/auth/main.go
go build cmd/file_storage/main.go
go build cmd/auth/main.go
go build cmd/mail/main.go
go build cmd/user/main.go
build-file_storage:
docker-compose -f docker-compose-prod.yml up -d --build --remove-orphans file_storage
build-user:
docker-compose -f docker-compose-prod.yml up -d --remove-orphans user
build-auth:
docker-compose -f docker-compose-prod.yml up -d --remove-orphans auth
build-mail:
docker-compose -f docker-compose-prod.yml up -d --remove-orphans mail
build-api:
docker-compose -f docker-compose-prod.yml up -d --remove-orphans api
build-prod-cd:
sudo systemctl stop nginx.service || true
sudo systemctl stop postgresql || true
mkdir -p -m 777 logs/app
mkdir -p -m 777 logs/postgres
docker-compose -f docker-compose-prod.yml up -d --remove-orphans
sudo cp ./nginx/nginx.prod.conf /etc/nginx/nginx.conf
sudo systemctl restart nginx
build-prod:
sudo systemctl stop nginx.service || true
sudo systemctl stop postgresql || true
mkdir -p -m 777 logs/app
mkdir -p -m 777 logs/postgres
docker-compose -f docker-compose-prod.yml up -d --build --remove-orphans
sudo cp ./nginx/nginx.prod.conf /etc/nginx/nginx.conf
sudo systemctl restart nginx
build-dev-env:
sudo systemctl stop nginx.service || true
sudo systemctl stop postgresql || true
mkdir -p -m 777 logs/postgres
mkdir -p -m 777 logs/app
docker-compose up -d --build --remove-orphans
sudo cp ./nginx/nginx.conf /etc/nginx/nginx.conf
sudo systemctl restart nginx
run-dev:
@make build-dev-env
@make run-all-services POSTGRES_HOST=127.0.0.1 REDIS_HOST=127.0.0.1
run-all-services:
make -j 5 run-api-service run-auth-service run-file_storage-service run-mail-service run-user-service
run-auth-service:
go run ./cmd/auth/main.go -config=./cmd/config/debug.yml
run-api-service:
go run ./cmd/api/main.go -config=./cmd/config/debug.yml
run-user-service:
go run ./cmd/user/main.go -config=./cmd/config/debug.yml
run-mail-service:
go run ./cmd/mail/main.go -config=./cmd/config/debug.yml
run-file_storage-service:
go run ./cmd/file_storage/main.go -config=./cmd/config/debug.yml
run-smtp-server:
sudo go run cmd/smtp/main.go -config=./cmd/config/debug.yml
docker-prune:
@bash -c 'docker system prune -f'
docker-stop-back:
docker container stop 2023_1_seekers_grafana_1 || true
docker container stop 2023_1_seekers_prometheus_1 || true
docker container stop 2023_1_seekers_api_1 || true
docker container stop 2023_1_seekers_mail_1 || true
docker container stop 2023_1_seekers_auth_1 || true
docker container stop 2023_1_seekers_user_1 || true
docker container stop 2023_1_seekers_admin_db_1 || true
docker container stop 2023_1_seekers_db_1 || true
docker container stop 2023_1_seekers_cache_1 || true
docker container stop 2023_1_seekers_file_storage_1 || true
docker container stop 2023_1_seekers_node_exporter_1 || true
make docker-prune
docker-stop-all:
@bash -c "docker kill $(shell eval docker ps -q)"
@bash -c "docker rm $(shell eval docker ps -a -q)"
@make docker-prune
docker-rm-volumes:
@bash -c "docker volume rm $(shell eval docker volume ls -qf dangling=true)"
docker-rm-images:
@bash -c "docker rmi $(shell eval docker images -q)"
cov:
mkdir -p ${COV_DIR}
go test -race -coverpkg=${INTERNAL_PKG} -coverprofile ${COV_DIR}/cover.out ${INTERNAL_PKG}; cat ${COV_DIR}/cover.out | fgrep -v "test.go" | fgrep -v "register.go"| fgrep -v "docs" | fgrep -v ".pb.go" | fgrep -v "mock" | fgrep -v "config" | fgrep -v "_easyjson.go" > ${COV_DIR}/cover2.out
go tool cover -func ${COV_DIR}/cover2.out
go tool cover -html ${COV_DIR}/cover2.out -o ${COV_DIR}/coverage.html
clean_logs:
sudo rm -rf logs/*
mkdir -p -m 777 logs/postgres
mkdir -p -m 777 logs/app
doc:
swag init -g cmd/api/main.go -o docs
generate:
go generate ${ALL_PKG}
perm-dirs:
sudo chmod -R 777 ./
lint:
golangci-lint run -c ./.golangci.yml
test:
go test ./...