-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup
executable file
·65 lines (58 loc) · 1.65 KB
/
setup
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
#!/usr/bin/env bash
error () {
echo -e "\e[31m[error]\e[0m $1"
}
info() {
echo -e "\e[94m[info]\e[0m $1"
}
success () {
echo -e "\e[32m[success]\e[0m $1"
}
ask() {
read -p $'\e[33m[action required] \e[0m'"$1"$' (y/n): ' -r
}
confirm() {
read -p $'\e[33m[action required] \e[0m'"$1"$' (y): ' -r
}
# Environment variables
echo "Setting environment variables"
if [ -f "./.env" ]; then
export $(cat .env | sed 's/#.*//g' | xargs)
else
cp .env.example .env
fi
# Check for npm dependencies
if [[ -f "package.json" ]] && [[ ! -d "node_modules" ]]
then
ask "npm dependencies are not installed, would you to install them now?"
if [[ $REPLY =~ ^[Yy]$ ]] ; then
npm install
success "npm dependencies installed!"
else
echo "continuing..."
fi
fi
# API secret
ask "Generate app secret for authenticated client requests?"
if [[ $REPLY =~ ^[Yy]$ ]] ; then
./node_modules/.bin/ts-node ./cli.ts app:secret
info "don't forget to store the access token above for making requests from your client!"
else
echo "continuing..."
fi
echo "---"
info "Starting docker development environment"
echo "Before continuing, please make sure you have configured environment variables:"
echo "[PROXY_PUBLIC_PORT, ICEMAN_PROJECT, ICEMAN_API_HOST]"
echo "Consult the README for more details."
confirm "Please confirm once you are ready to continue"
# Boot container
ask "Would you like to rebuild images when spinning up containers?"
if [[ $REPLY =~ ^[Yy]$ ]] ; then
echo "Rebuilding images and starting containers"
docker-compose up -d --build iceman-proxy
else
echo "Spinning up containers"
docker-compose up -d iceman-proxy
fi
exit 0;