-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
97 lines (77 loc) · 2.44 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
include .env
.DEFAULT_GOAL := build
API=chasse-api
APP=chasse-app
BUILD_DIR=build
GIT_SHA_FETCH := $(shell git rev-parse HEAD | cut -c 1-8)
export GIT_SHA=$(GIT_SHA_FETCH)
API_FILE_NAME=${API}-${GIT_SHA}
APP_FILE_NAME=${APP}-${GIT_SHA}.tar.gz
.PHONY: clean
clean:
docker-compose down
if [ -d ${APP}/${BUILD_DIR} ] ; then rm -rf ${APP}/${BUILD_DIR} ; fi
if [ -d ${API}/${BUILD_DIR} ] ; then rm -rf ${API}/${BUILD_DIR} ; fi
if [ -d ${API}/db ] ; then rm -rf ${API}/db ; fi
if [ -d ${BUILD_DIR} ] ; then rm -rf ${BUILD_DIR} ; fi
.PHONY: build-app
build-app:
if ! [ -d ${BUILD_DIR} ] ; then mkdir ${BUILD_DIR} ; fi
cd ${APP};\
npm install;\
REACT_APP_VERSION=ver_${GIT_SHA} REACT_APP_API_URL=${REACT_APP_API_URL} REACT_APP_WS_URL=${REACT_APP_WS_URL} npm run build;\
tar -zcvf ${APP_FILE_NAME} build;\
mv ${APP_FILE_NAME} ../${BUILD_DIR};
.PHONY: build-api
build-api:
if ! [ -d ${BUILD_DIR} ] ; then mkdir ${BUILD_DIR} ; fi
cd ${API};\
go mod tidy;\
GOOS=linux GOARCH=amd64 go build -o ../build/${API_FILE_NAME} .;
.PHONY: build
build: build-api build-app
.PHONY: run-app
run-app:
cd ${APP};\
npm install;\
REACT_APP_VERSION=ver_dev_ REACT_APP_DEV_MODE=true npm run start;
.PHONY: run-app-remote
run-app-remote:
cd ${APP};\
npm install;\
REACT_APP_VERSION=ver_dev_ REACT_APP_DEV_MODE=true REACT_APP_API_URL=${REACT_APP_API_URL} REACT_APP_WS_URL=${REACT_APP_WS_URL} npm run start;
.PHONY: run-api
run-api:
docker-compose up -d
cd ${API};\
if ! [ -d ${BUILD_DIR} ] ; then mkdir ${BUILD_DIR} ; fi;\
go mod tidy;\
air -c .air.toml
.PHONY: run
run: run-api run-app
.PHONY: deploy-api
deploy-api:
scp build/${API_FILE_NAME} root@${SERVER_URL}:~/bin
ssh root@${SERVER_URL} "./deploy-api.sh bin/${API_FILE_NAME}"
misc/scripts/deploy-notifier.sh ${AIRBRAKE_ID} ${AIRBRAKE_KEY} api ${GIT_SHA}
.PHONY: deploy-app
deploy-app:
scp build/${APP_FILE_NAME} root@${SERVER_URL}:~/bin
ssh root@${SERVER_URL} "./deploy-app.sh bin/${APP_FILE_NAME}"
misc/scripts/deploy-notifier.sh ${AIRBRAKE_ID} ${AIRBRAKE_KEY} app ${GIT_SHA}
.PHONY: build-deploy-api
build-deploy-api: build-api deploy-api
.PHONY: build-deploy-app
build-deploy-app: build-app deploy-app
.PHONY: deploy
deploy: deploy-api deploy-app
.PHONY: build-deploy
build-deploy: build deploy
.PHONY: health-api
health-api:
./misc/scripts/check-health-api.sh ${GIT_SHA} ${HEALTH_URL}
.PHONY: health-app
health-app:
./misc/scripts/check-health-app.sh 200 ${APP_URL}
.PHONY: health
health: health-api health-app