-
Notifications
You must be signed in to change notification settings - Fork 2
/
laradock.sh
executable file
·154 lines (136 loc) · 5.38 KB
/
laradock.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
#!/usr/bin/env sh
# -----------------------------------------------------------------------------
# GRAFANA BUILDER SCRIPT
# -----------------------------------------------------------------------------
# Author : Dwi Fahni Denni (@zeroc0d3)
# Repository : https://github.com/zeroc0d3/docker-framework
# License : MIT
# -----------------------------------------------------------------------------
TITLE="GRAFANA BUILDER SCRIPT" # script name
VER="1.4.2" # script version
ENV="0" # container environment (0 = development, 1 = production)
SKIP_BUILD="0" # (0 = with build process, 1 = bypass build process)
REMOVE_CACHE="0" # (0 = using cache, 1 = no-cache)
RECREATE_CONTAINER="0" # (0 = disable recreate container, 1 = force recreate container)
DAEMON_MODE="1" # (0 = disable daemon mode, 1 = running daemon mode / background)
USERNAME=`echo $USER`
PATH_HOME=`echo $HOME`
CONTAINER_PRODUCTION="prometheus alertmanager nodeexporter cadvisor grafana pushgateway portainer caddy"
CONTAINER_DEVELOPMENT="prometheus alertmanager nodeexporter cadvisor grafana pushgateway caddy portainer"
export DOCKER_CLIENT_TIMEOUT=300
export COMPOSE_HTTP_TIMEOUT=300
get_time() {
DATE=`date '+%Y-%m-%d %H:%M:%S'`
}
logo() {
clear
echo "\033[22;32m=======================================================================================\033[0m"
echo "\033[22;31m '##::::::::::'###::::'########:::::'###::::'########:::'#######:::'######::'##:::'##: \033[0m"
echo "\033[22;31m ##:::::::::'## ##::: ##.... ##:::'## ##::: ##.... ##:'##.... ##:'##... ##: ##::'##:: \033[0m"
echo "\033[22;31m ##::::::::'##:. ##:: ##:::: ##::'##:. ##:: ##:::: ##: ##:::: ##: ##:::..:: ##:'##::: \033[0m"
echo "\033[22;31m ##:::::::'##:::. ##: ########::'##:::. ##: ##:::: ##: ##:::: ##: ##::::::: #####:::: \033[0m"
echo "\033[22;31m ##::::::: #########: ##.. ##::: #########: ##:::: ##: ##:::: ##: ##::::::: ##. ##::: \033[0m"
echo "\033[22;31m ##::::::: ##.... ##: ##::. ##:: ##.... ##: ##:::: ##: ##:::: ##: ##::: ##: ##:. ##:: \033[0m"
echo "\033[22;31m ########: ##:::: ##: ##:::. ##: ##:::: ##: ########::. #######::. ######:: ##::. ##: \033[0m"
echo "\033[22;31m ........::..:::::..::..:::::..::..:::::..::........::::.......::::......:::..::::..:: \033[0m"
echo "\033[22;32m---------------------------------------------------------------------------------------\033[0m"
echo "\033[22;32m# $TITLE :: ver-$VER \033[0m"
}
header() {
logo
echo "\033[22;32m=======================================================================================\033[0m"
get_time
echo "\033[22;31m# BEGIN PROCESS..... (Please Wait) \033[0m"
echo "\033[22;31m# Start at: $DATE \033[0m\n"
}
footer() {
echo "\033[22;32m=======================================================================================\033[0m"
get_time
echo "\033[22;31m# Finish at: $DATE \033[0m"
echo "\033[22;31m# END PROCESS..... \033[0m\n"
}
build_env() {
if [ "$ENV" = "0" ]
then
BUILD_ENV="$CONTAINER_DEVELOPMENT"
else
BUILD_ENV="$CONTAINER_PRODUCTION"
fi
}
cache() {
if [ "$REMOVE_CACHE" = "0" ]
then
CACHE=""
else
CACHE="--no-cache "
fi
}
recreate() {
if [ "$RECREATE_CONTAINER" = "0" ]
then
RECREATE=""
else
RECREATE="--force-recreate "
fi
}
daemon_mode() {
if [ "$DAEMON_MODE" = "0" ]
then
DAEMON=""
else
DAEMON="-d "
fi
}
docker_build() {
if [ "$SKIP_BUILD" = "0" ]
then
echo "--------------------------------------------------------------------------"
get_time
echo "\033[22;34m[ $DATE ] ##### Docker Compose: \033[0m "
echo "\033[22;32m[ $DATE ] docker-compose build $CACHE$BUILD_ENV \033[0m\n"
## MULTI CONTAINER
## ------------------------------
for CONTAINER in $BUILD_ENV
do
get_time
echo "--------------------------------------------------------------------------"
echo "\033[22;32m[ $DATE ] docker-compose build $CONTAINER \033[0m "
echo "--------------------------------------------------------------------------"
docker-compose build $CONTAINER
echo ""
done
## SINGLE CONTAINER (test)
## ------------------------------
## get_time
## echo "--------------------------------------------------------------------------"
## echo "\033[22;32m[ $DATE ] docker-compose build $BUILD_ENV \033[0m "
## echo "--------------------------------------------------------------------------"
## docker-compose build $BUILD_ENV
## echo ""
fi
}
docker_up() {
daemon_mode
echo ""
echo "--------------------------------------------------------------------------"
get_time
echo "\033[22;34m[ $DATE ] ##### Docker Compose Up: \033[0m "
echo "\033[22;32m[ $DATE ] docker-compose up $RECREATE$BUILD_ENV \033[0m\n "
get_time
echo "--------------------------------------------------------------------------"
echo "\033[22;32m[ $DATE ] docker-compose up $RECREATE$BUILD_ENV \033[0m "
echo "--------------------------------------------------------------------------"
docker-compose up $DAEMON $RECREATE$BUILD_ENV
echo ""
}
main() {
header
cache
recreate
build_env
docker_build
docker_up
footer
}
### START HERE ###
main $@