-
Notifications
You must be signed in to change notification settings - Fork 0
/
env.sh.example
71 lines (61 loc) · 1.49 KB
/
env.sh.example
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
#!/bin/sh
DATE=`date +%Y%m%d`
ENV="development" # (development / production)
REMOVE_CACHE="0" # (0 = using cache, 1 = no-cache)
RECREATE_CONTAINER="0" # (0 = disable recreate container, 1 = force recreate container)
CONTAINER_PRODUCTION="centos-base-consul-lite"
CONTAINER_DEVELOPMENT="centos-base-consul-lite"
export DOCKER_CLIENT_TIMEOUT=120
export COMPOSE_HTTP_TIMEOUT=120
build_env() {
if [ "$ENV" = "development" ]
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
}
loop_build() {
for CONTAINER in $BUILD_ENV
do
echo ""
echo ">>> docker-compose build $CONTAINER"
echo "-----------------------------------------------------------"
docker-compose build $CONTAINER
done
}
build_all() {
docker-compose up $RECREATE $BUILD_ENV
}
main() {
cache
recreate
build_env
echo "-----------------------------------------------------------"
echo "### docker-compose exec $CACHE $BUILD_ENV"
echo "-----------------------------------------------------------"
loop_build
echo ""
echo "-----------------------------------------------------------"
echo "### docker-compose up $RECREATE $BUILD_ENV"
echo "-----------------------------------------------------------"
build_all
}
### START HERE ###
main