-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathstart.sh
executable file
·75 lines (59 loc) · 1.79 KB
/
start.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
#!/usr/bin/env bash
set -e
CURRENT_DIR=$PWD
PROJECT_DIR=$(dirname $(realpath "$0"))
FOLLOW_LOG='0'
PORT='8888'
################################################################################
## setup env
################################################################################
# Map arguments
while [[ $# -gt 0 ]] && [[ "$1" == "-"* ]] ;
do
opt="$1";
shift;
case "$opt" in
"--follow-log" )
FOLLOW_LOG='1';;
"--port" )
PORT="$1"; shift;;
*) echo >&2 "Invalid option: $opt"; exit 1;;
esac
done
if [ "$PORT" == '8888' ]; then
echo "[PORT]: ${PORT}. Use '--port' flag to change the default port."
else
echo "[PORT]: ${PORT}"
fi
if [ "$FOLLOW_LOG" == '1' ]; then
echo "[FOLLOW_LOG]: yes"
else
echo "[FOLLOW_LOG]: no. Use '--follow-log' flag to show docker container logs after startup."
fi
echo ""
################################################################################
## run docker-compose
################################################################################
cd ${PROJECT_DIR}/dev
echo ""
echo -e "\e[48;5;21m\e[38;5;226m LogViewer: building images \e[0m"
docker compose build --pull
echo ""
echo -e "\e[48;5;21m\e[38;5;226m LogViewer: Stopping current containers \e[0m"
docker compose stop
echo ""
echo -e "\e[48;5;21m\e[38;5;226m LogViewer: Starting containers \e[0m"
if [ "$FOLLOW_LOG" == '1' ]; then
NGINX_PORT=${PORT} docker compose up -d
else
NGINX_PORT=${PORT} docker compose up -d --wait
fi
echo ""
echo -e "\e[48;5;21m\e[38;5;226m LogViewer: Environment running \e[0m"
echo ""
echo " Environment available at: http://localhost:${PORT}/"
echo ""
if [ "$FOLLOW_LOG" == '1' ]; then
docker compose logs --tail=5 --follow
fi
cd ${CURRENT_DIR}