blob: 1b3f370d27294b63a898c5006f4daa2c174becb3 [file] [log] [blame]
Michael Lando451a3402017-02-19 10:28:42 +02001#!/bin/bash
2
3
4function usage
5{
6 echo "usage: docker_run.sh [ -r|--release <RELEASE-NAME> ] [ -e|--environment <ENV-NAME> ] [ -p|--port <Docker-hub-port>] [ -h|--help ]"
7}
8
9
10RELEASE=1.0.0-SNAPSHOT
11[ -f /opt/config/env_name.txt ] && DEP_ENV=$(cat /opt/config/env_name.txt) || DEP_ENV=__ENV-NAME__
12PORT=51212
13
14while [ "$1" != "" ]; do
15 case $1 in
16 -r | --release )
17 shift
18 RELEASE=${1}
19 ;;
20 -e | --environment )
21 shift
22 DEP_ENV=${1}
23 ;;
24 -p | --port )
25 shift
26 PORT=${1}
27 ;;
28 -h | --help )
29 usage
30 exit
31 ;;
32 * )
33 usage
34 exit 1
35 esac
36 shift
37done
38
39[ -f /opt/config/nexus_username.txt ] && NEXUS_USERNAME=$(cat /opt/config/nexus_username.txt) || NEXUS_USERNAME=release
40[ -f /opt/config/nexus_password.txt ] && NEXUS_PASSWD=$(cat /opt/config/nexus_password.txt) || NEXUS_PASSWD=sfWU3DFVdBr7GVxB85mTYgAW
41[ -f /opt/config/nexus_docker_repo.txt ] && NEXUS_DOCKER_REPO=$(cat /opt/config/nexus_docker_repo.txt) || NEXUS_DOCKER_REPO=ecomp-nexus:${PORT}
42
43[ -f /opt/config/nexus_username.txt ] && docker login -u $NEXUS_USERNAME -p $NEXUS_PASSWD $NEXUS_DOCKER_REPO
44
45
46# cleanup
47echo "performing old dockers cleanup"
48docker_ids=`docker ps -a | egrep "ecomp-nexus:${PORT}/sdc|sdc|Exit" | awk '{print $1}'`
49for X in ${docker_ids}
50do
51 docker rm -f ${X}
52done
53
54export IP=`ifconfig eth0 | awk -F: '/inet addr/ {gsub(/ .*/,"",$2); print $2}'`
55
56echo ""
57
58# Elastic-Search
59echo "docker run sdc-elasticsearch..."
60docker pull ecomp-nexus:${PORT}/ecomp/sdc-elasticsearch:${RELEASE}
61docker run --detach --name sdc-es --env ENVNAME="${DEP_ENV}" --log-driver=json-file --log-opt max-size=100m --log-opt max-file=10 --memory 1g --memory-swap=1g --ulimit memlock=-1:-1 --ulimit nofile=4096:100000 --volume /etc/localtime:/etc/localtime:ro -e ES_HEAP_SIZE=1024M --volume /data/ES:/usr/share/elasticsearch/data --volume /data/environments:/root/chef-solo/environments --publish 9200:9200 --publish 9300:9300 ecomp-nexus:${PORT}/ecomp/sdc-elasticsearch:${RELEASE}
62
63
64# cassandra
65echo "docker run sdc-cassandra..."
66docker pull ecomp-nexus:${PORT}/ecomp/sdc-cassandra:${RELEASE}
67docker run --detach --name sdc-cs --env ENVNAME="${DEP_ENV}" --env HOST_IP=${IP} --log-driver=json-file --log-opt max-size=100m --log-opt max-file=10 --ulimit memlock=-1:-1 --ulimit nofile=4096:100000 --volume /etc/localtime:/etc/localtime:ro --volume /data/CS:/var/lib/cassandra --volume /data/environments:/root/chef-solo/environments --publish 9042:9042 --publish 9160:9160 ecomp-nexus:${PORT}/ecomp/sdc-cassandra:${RELEASE}
68
69
70echo "please wait while CS is starting..."
71echo ""
72c=25 # seconds to wait
73REWRITE="\e[25D\e[1A\e[K"
74while [ $c -gt 0 ]; do
75 c=$((c-1))
76 sleep 1
77 echo -e "${REWRITE}$c"
78done
79echo -e ""
80
81
82# kibana
83echo "docker run sdc-kibana..."
84docker pull ecomp-nexus:${PORT}/ecomp/sdc-kibana:${RELEASE}
85docker run --detach --name sdc-kbn --env ENVNAME="${DEP_ENV}" --log-driver=json-file --log-opt max-size=100m --log-opt max-file=10 --ulimit memlock=-1:-1 --memory 2g --memory-swap=2g --ulimit nofile=4096:100000 --volume /etc/localtime:/etc/localtime:ro --volume /data/environments:/root/chef-solo/environments --publish 5601:5601 ecomp-nexus:${PORT}/ecomp/sdc-kibana:${RELEASE}
86
87
88# Back-End
89echo "docker run sdc-backend..."
90docker pull ecomp-nexus:${PORT}/ecomp/sdc-backend:${RELEASE}
91docker run --detach --name sdc-BE --env HOST_IP=${IP} --env ENVNAME="${DEP_ENV}" --log-driver=json-file --log-opt max-size=100m --log-opt max-file=10 --ulimit memlock=-1:-1 --memory 4g --memory-swap=4g --ulimit nofile=4096:100000 --volume /etc/localtime:/etc/localtime:ro --volume /data/logs/BE/:/var/lib/jetty/logs --volume /data/environments:/root/chef-solo/environments --publish 8443:8443 --publish 8080:8080 ecomp-nexus:${PORT}/ecomp/sdc-backend:${RELEASE}
92
93echo "please wait while BE is starting..."
94echo ""
95c=45 # seconds to wait
96REWRITE="\e[45D\e[1A\e[K"
97while [ $c -gt 0 ]; do
98 c=$((c-1))
99 sleep 1
100 echo -e "${REWRITE}$c"
101done
102echo -e ""
103
104
105# Front-End
106echo "docker run sdc-frontend..."
107docker pull ecomp-nexus:${PORT}/ecomp/sdc-frontend:${RELEASE}
108docker run --detach --name sdc-FE --env HOST_IP=${IP} --env ENVNAME="${DEP_ENV}" --log-driver=json-file --log-opt max-size=100m --log-opt max-file=10 --ulimit memlock=-1:-1 --memory 2g --memory-swap=2g --ulimit nofile=4096:100000 --volume /etc/localtime:/etc/localtime:ro --volume /data/logs/FE/:/var/lib/jetty/logs --volume /data/environments:/root/chef-solo/environments --publish 9443:9443 --publish 8181:8181 ecomp-nexus:${PORT}/ecomp/sdc-frontend:${RELEASE}
109
110
111
112# running healthCheck scripts
113echo "Running health checks, please wait..."
114echo ""
115c=25 # seconds to wait
116REWRITE="\e[45D\e[1A\e[K"
117while [ $c -gt 0 ]; do
118 c=$((c-1))
119 sleep 1
120 echo -e "${REWRITE}$c"
121done
122echo -e ""
123
124/data/scripts/docker_health.sh
125
126if [ $? -ne 0 ]; then
127 exit 1
128fi