-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy.sh
executable file
·95 lines (79 loc) · 2.65 KB
/
deploy.sh
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
#!/bin/bash
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
DGRAY='\033[1;30m'
NC='\033[0m' # No Color
install(){
echo -e "\n${GREEN}## Intalling the backend dependencies and applying patches ...${DGRAY}"
npm install && npm run postinstall
echo -e "\n${YELLOW} ## Done!${NC}"
}
server(){
echo -e "\n${GREEN}## Starting Debauthn server ..."
echo -e "\n${YELLOW}!!Warning: check all configuration at /src/config and the environment variables${DGRAY}"
npm run start
}
build_front(){
echo -e "\n${RED}#1 ${GREEN}Cloning the front code ...${DGRAY}"
git submodule update --init --recursive || { echo -e "${RED}Error when cloning the code" && exit; }
cd debauthn-frontend
echo -e "\n${RED}#2 ${GREEN}Installing npm dependencies ...${DGRAY}"
npm install || { echo -e "${RED}Error when installing dependencies" && exit; }
echo -e "\n${RED}#3 ${GREEN}Building the static files ...${DGRAY}"
npm run build || { echo -e "${RED}Error when building the frontend" && exit; }
echo -e "\n${RED}#4 ${GREEN}Removing public folder at the backend public folder ...${DGRAY}"
rm -rf ../src/public/
echo -e "\n${RED}#5 ${GREEN}Copying files ...${DGRAY}"
mkdir ../src/public
cp -r dist/* ../src/public/
echo -e "\n${YELLOW}## Done! Now you have successfully built and you are ready to go!${NC}"
cd ..
}
docker(){
echo -e "\n${GREEN}## Building and deploying the whole project (will take some minutes) ...${DGRAY}"
echo -e "\n${YELLOW}!!Warning: check all configuration at docker-compose.yml.${DGRAY}"
docker-compose up -d --build
}
all(){
echo -e "\n${GREEN}## Running quick start ...${DGRAY}"
install
build_front
server
}
usage(){
echo "Usage: ./deploy"
echo " -a|--all : Installs and deploys the project"
echo " -i|--install : Installs backend dependencies"
echo " -s|--server : Runs the backend server"
echo " -f|--front : Builds the front and installs it"
echo " -d|--docker : Creates a docker image"
echo " -h|--help : Displays this help"
echo -e "${YELLOW} \n Check the server configuration at /src/config${NC}"
}
echo -e "${DGRAY}\n#########################################"
echo -e "## DEBAUTHN #"
echo -e "#########################################"
echo -e "#A WebAuthn Authenticator Debugging Tool#\n${NC}"
case $1 in
-a|--all)
all
;;
-i|--install)
install
;;
-s|--server)
server
;;
-f|--front)
build_front
;;
-d|--docker)
docker
;;
-h|--help)
usage
;;
*)
usage
esac