blob: 02eff2375f3ff8fa3957efe5081981237c9e73f2 [file] [log] [blame]
Michael Lando451a3402017-02-19 10:28:42 +02001#!/bin/bash
2
3
Grinberg Motic3bda482017-02-23 11:24:34 +02004function usage {
Yuli Shlosberg9dde9262017-09-12 14:11:48 +03005 echo "usage: docker_run.sh [ -r|--release <RELEASE-NAME> ] [ -e|--environment <ENV-NAME> ] [ -p|--port <Docker-hub-port>] [ -l|--local <Run-without-pull>] [ -s|--skipTests <Run-without-sanityDocker>] [ -h|--help ]"
Michael Lando451a3402017-02-19 10:28:42 +02006}
7
8
Grinberg Motic3bda482017-02-23 11:24:34 +02009function cleanup {
10 echo "performing old dockers cleanup"
Idan Amitc7f57ec2017-08-31 14:26:21 +030011 docker_ids=`docker ps -a | egrep -v "openecomp/sdc-simulator" | egrep "ecomp-nexus:${PORT}/sdc|sdc|Exit" | awk '{print $1}'`
Grinberg Motic3bda482017-02-23 11:24:34 +020012 for X in ${docker_ids}
13 do
14 docker rm -f ${X}
15 done
16}
17
18
19function dir_perms {
20 mkdir -p /data/logs/BE/ASDC/ASDC-BE
21 mkdir -p /data/logs/FE/ASDC/ASDC-FE
Michael Lando33d78d82017-02-27 19:48:33 +020022 chmod -R 777 /data/logs
Grinberg Motic3bda482017-02-23 11:24:34 +020023}
24
25
Grinberg Moti97246212017-02-21 19:30:31 +020026RELEASE=latest
Idan Amitc7f57ec2017-08-31 14:26:21 +030027LOCAL=false
Yuli Shlosberg9dde9262017-09-12 14:11:48 +030028SKIPTESTS=false
Michael Lando451a3402017-02-19 10:28:42 +020029[ -f /opt/config/env_name.txt ] && DEP_ENV=$(cat /opt/config/env_name.txt) || DEP_ENV=__ENV-NAME__
Grinberg Moti53fbfb52017-02-21 14:22:40 +020030[ -f /opt/config/nexus_username.txt ] && NEXUS_USERNAME=$(cat /opt/config/nexus_username.txt) || NEXUS_USERNAME=release
31[ -f /opt/config/nexus_password.txt ] && NEXUS_PASSWD=$(cat /opt/config/nexus_password.txt) || NEXUS_PASSWD=sfWU3DFVdBr7GVxB85mTYgAW
32[ -f /opt/config/nexus_docker_repo.txt ] && NEXUS_DOCKER_REPO=$(cat /opt/config/nexus_docker_repo.txt) || NEXUS_DOCKER_REPO=ecomp-nexus:${PORT}
Michael Lando451a3402017-02-19 10:28:42 +020033
34while [ "$1" != "" ]; do
35 case $1 in
36 -r | --release )
37 shift
38 RELEASE=${1}
39 ;;
40 -e | --environment )
41 shift
42 DEP_ENV=${1}
43 ;;
44 -p | --port )
45 shift
46 PORT=${1}
47 ;;
Idan Amitc7f57ec2017-08-31 14:26:21 +030048 -l | --local )
49 shift
50 LOCAL=true
51 ;;
Yuli Shlosberg9dde9262017-09-12 14:11:48 +030052 -s | --skipTests )
53 shift
54 SKIPTESTS=true
55 ;;
Michael Lando451a3402017-02-19 10:28:42 +020056 -h | --help )
57 usage
58 exit
59 ;;
60 * )
61 usage
62 exit 1
63 esac
64 shift
65done
66
Michael Lando451a3402017-02-19 10:28:42 +020067[ -f /opt/config/nexus_username.txt ] && docker login -u $NEXUS_USERNAME -p $NEXUS_PASSWD $NEXUS_DOCKER_REPO
68
69
Grinberg Motic3bda482017-02-23 11:24:34 +020070cleanup
71
Michael Lando451a3402017-02-19 10:28:42 +020072
73export IP=`ifconfig eth0 | awk -F: '/inet addr/ {gsub(/ .*/,"",$2); print $2}'`
Idan Amitc7f57ec2017-08-31 14:26:21 +030074export PREFIX=${NEXUS_DOCKER_REPO}'/openecomp'
75
76if [ ${LOCAL} = true ]; then
77 PREFIX='openecomp'
78fi
Michael Lando451a3402017-02-19 10:28:42 +020079
80echo ""
81
82# Elastic-Search
83echo "docker run sdc-elasticsearch..."
Idan Amitc7f57ec2017-08-31 14:26:21 +030084if [ ${LOCAL} = false ]; then
85 echo "pulling code"
86 docker pull ${PREFIX}/sdc-elasticsearch:${RELEASE}
87fi
88docker 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 ${PREFIX}/sdc-elasticsearch:${RELEASE}
89
90
91# cassandra
92echo "docker run sdc-cassandra..."
93if [ ${LOCAL} = false ]; then
94 docker pull ${PREFIX}/sdc-cassandra:${RELEASE}
95fi
Idan Amit9409da02017-09-03 14:46:10 +030096docker run --detach --name sdc-cs --env RELEASE="${RELEASE}" --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 ${PREFIX}/sdc-cassandra:${RELEASE}
Michael Lando451a3402017-02-19 10:28:42 +020097
98
99echo "please wait while CS is starting..."
100echo ""
Michael Landoed64b5e2017-06-09 03:19:04 +0300101c=120 # seconds to wait
Michael Lando451a3402017-02-19 10:28:42 +0200102REWRITE="\e[25D\e[1A\e[K"
103while [ $c -gt 0 ]; do
104 c=$((c-1))
105 sleep 1
106 echo -e "${REWRITE}$c"
107done
108echo -e ""
109
Michael Lando451a3402017-02-19 10:28:42 +0200110# kibana
111echo "docker run sdc-kibana..."
Idan Amitc7f57ec2017-08-31 14:26:21 +0300112if [ ${LOCAL} = false ]; then
113 docker pull ${PREFIX}/sdc-kibana:${RELEASE}
114fi
115docker 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 ${PREFIX}/sdc-kibana:${RELEASE}
Michael Lando451a3402017-02-19 10:28:42 +0200116
Grinberg Motic3bda482017-02-23 11:24:34 +0200117dir_perms
Michael Lando451a3402017-02-19 10:28:42 +0200118
119# Back-End
120echo "docker run sdc-backend..."
Idan Amitc7f57ec2017-08-31 14:26:21 +0300121if [ ${LOCAL} = false ]; then
122 docker pull ${PREFIX}/sdc-backend:${RELEASE}
123fi
124docker run --detach --name sdc-BE --env HOST_IP=${IP} --env ENVNAME="${DEP_ENV}" --env http_proxy=${http_proxy} --env https_proxy=${https_proxy} --env no_proxy=${no_proxy} --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 ${PREFIX}/sdc-backend:${RELEASE}
Michael Lando451a3402017-02-19 10:28:42 +0200125
126echo "please wait while BE is starting..."
127echo ""
128c=45 # seconds to wait
129REWRITE="\e[45D\e[1A\e[K"
130while [ $c -gt 0 ]; do
131 c=$((c-1))
132 sleep 1
133 echo -e "${REWRITE}$c"
134done
135echo -e ""
136
137
138# Front-End
139echo "docker run sdc-frontend..."
Idan Amitc7f57ec2017-08-31 14:26:21 +0300140if [ ${LOCAL} = false ]; then
141 docker pull ${PREFIX}/sdc-frontend:${RELEASE}
142fi
143docker run --detach --name sdc-FE --env HOST_IP=${IP} --env ENVNAME="${DEP_ENV}" --env http_proxy=${http_proxy} --env https_proxy=${https_proxy} --env no_proxy=${no_proxy} --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 ${PREFIX}/sdc-frontend:${RELEASE}
Michael Lando451a3402017-02-19 10:28:42 +0200144
145
146
147# running healthCheck scripts
148echo "Running health checks, please wait..."
149echo ""
Tal Gitelman0a921192017-10-03 15:03:25 +0300150c=30 # seconds to wait
Michael Lando451a3402017-02-19 10:28:42 +0200151REWRITE="\e[45D\e[1A\e[K"
152while [ $c -gt 0 ]; do
153 c=$((c-1))
154 sleep 1
155 echo -e "${REWRITE}$c"
156done
157echo -e ""
158
159/data/scripts/docker_health.sh
160
161if [ $? -ne 0 ]; then
162 exit 1
163fi
ml636r0649e652017-02-20 21:10:54 +0200164
Yuli Shlosberg9dde9262017-09-12 14:11:48 +0300165# sanityDocker
166echo "docker run sdc-frontend..."
167if [ ${SKIPTESTS} = false ]; then
168echo "Triger sanity docker, please wait..."
169 if [ ${LOCAL} = false ]; then
170 docker pull ${PREFIX}/sdc-sanity:${RELEASE}
171 fi
172 docker run --detach --name sdc-sanity --env HOST_IP=${IP} --env ENVNAME="${DEP_ENV}" --env http_proxy=${http_proxy} --env https_proxy=${https_proxy} --env no_proxy=${no_proxy} --log-driver=json-file --log-opt max-size=100m --log-opt max-file=10 --ulimit memlock=-1:-1 --memory 512m --memory-swap=512m --ulimit nofile=4096:100000 --volume /etc/localtime:/etc/localtime:ro --volume /data/logs/sdc-sanity/target:/var/lib/tests/target --volume /data/logs/sdc-sanity/ExtentReport:/var/lib/tests/ExtentReport --volume /data/environments:/root/chef-solo/environments --publish 9560:9560 ${PREFIX}/sdc-sanity:${RELEASE}
173fi