-
Notifications
You must be signed in to change notification settings - Fork 0
/
doit.sh
executable file
·58 lines (49 loc) · 1.15 KB
/
doit.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
#!/bin/bash
GREEN='\033[0;32m'
RED='\033[0;31m'
NC='\033[0m' # No Color
function message {
echo -e "${GREEN}\n---> $1${NC}"
}
function error {
echo -e "${RED}ERROR: $1${NC}"
}
BUILD=0
function usage {
echo -e $1
echo -e "Usage: ./doit"
echo "Options:"
echo -e "\t-b -> Build docker image before running"
}
while getopts ":bh" o; do
case "${o}" in
b)
BUILD=1 ;;
h)
usage ;;
\?)
echo "Invalid option: -$OPTARG"
usage ;;
esac
done
# Check docker package is installed
dpkg -s lxc-docker &> /dev/null
if [ $? -ne 0 ]; then
# echo -e "${RED}Docker not installed. Try apt-get install lxc-docker${NC}"
error "Docker not installed"
echo "Try apt-get install lxc-docker"
exit $?
fi
# Build docker image
if [ $BUILD -eq 1 ]; then
message "Building docker image..."
docker build -t internshyps_frontend_deploy .
if [ $? -ne 0 ]; then
error "Failed to build docker image"
exit $?
fi
fi
# Run docker image
message "Running docker image..."
clear
docker run --env-file=deploy/environment -tiv $(pwd):/project/internshyps_frontend_deploy internshyps_frontend_deploy /bin/bash