blob: 23c443e22deba4200bc7e5d2a48a8c645989d49a [file] [log] [blame]
Michael Lando451a3402017-02-19 10:28:42 +02001#!/bin/bash
2
3
Grinberg Motic3bda482017-02-23 11:24:34 +02004function usage {
Michael Lando451a3402017-02-19 10:28:42 +02005 echo "usage: docker_run.sh [ -r|--release <RELEASE-NAME> ] [ -e|--environment <ENV-NAME> ] [ -p|--port <Docker-hub-port>] [ -h|--help ]"
6}
7
8
Grinberg Motic3bda482017-02-23 11:24:34 +02009function cleanup {
10 echo "performing old dockers cleanup"
11 docker_ids=`docker ps -a | egrep "ecomp-nexus:${PORT}/sdc|sdc|Exit" | awk '{print $1}'`
12 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
Michael Lando451a3402017-02-19 10:28:42 +020027[ -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 +020028[ -f /opt/config/nexus_username.txt ] && NEXUS_USERNAME=$(cat /opt/config/nexus_username.txt) || NEXUS_USERNAME=release
29[ -f /opt/config/nexus_password.txt ] && NEXUS_PASSWD=$(cat /opt/config/nexus_password.txt) || NEXUS_PASSWD=sfWU3DFVdBr7GVxB85mTYgAW
30[ -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 +020031
32while [ "$1" != "" ]; do
33 case $1 in
34 -r | --release )
35 shift
36 RELEASE=${1}
37 ;;
38 -e | --environment )
39 shift
40 DEP_ENV=${1}
41 ;;
42 -p | --port )
43 shift
44 PORT=${1}
45 ;;
46 -h | --help )
47 usage
48 exit
49 ;;
50 * )
51 usage
52 exit 1
53 esac
54 shift
55done
56
Michael Lando451a3402017-02-19 10:28:42 +020057[ -f /opt/config/nexus_username.txt ] && docker login -u $NEXUS_USERNAME -p $NEXUS_PASSWD $NEXUS_DOCKER_REPO
58
59
Grinberg Motic3bda482017-02-23 11:24:34 +020060cleanup
61
Michael Lando451a3402017-02-19 10:28:42 +020062
63export IP=`ifconfig eth0 | awk -F: '/inet addr/ {gsub(/ .*/,"",$2); print $2}'`
64
65echo ""
66
67# Elastic-Search
68echo "docker run sdc-elasticsearch..."
Grinberg Moticd6eeaa2017-02-23 14:26:04 +020069docker pull ${NEXUS_DOCKER_REPO}/openecomp/sdc-elasticsearch:${RELEASE}
Grinberg Moti53fbfb52017-02-21 14:22:40 +020070docker 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 ${NEXUS_DOCKER_REPO}/openecomp/sdc-elasticsearch:${RELEASE}
Michael Lando451a3402017-02-19 10:28:42 +020071
72
73# cassandra
74echo "docker run sdc-cassandra..."
Grinberg Moti53fbfb52017-02-21 14:22:40 +020075docker pull ${NEXUS_DOCKER_REPO}/openecomp/sdc-cassandra:${RELEASE}
Michael Landoed64b5e2017-06-09 03:19:04 +030076docker 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 ${NEXUS_DOCKER_REPO}/openecomp/sdc-cassandra:${RELEASE}
Michael Lando451a3402017-02-19 10:28:42 +020077
78
79echo "please wait while CS is starting..."
80echo ""
Michael Landoed64b5e2017-06-09 03:19:04 +030081c=120 # seconds to wait
Michael Lando451a3402017-02-19 10:28:42 +020082REWRITE="\e[25D\e[1A\e[K"
83while [ $c -gt 0 ]; do
84 c=$((c-1))
85 sleep 1
86 echo -e "${REWRITE}$c"
87done
88echo -e ""
89
90
91# kibana
92echo "docker run sdc-kibana..."
Grinberg Moti53fbfb52017-02-21 14:22:40 +020093docker pull ${NEXUS_DOCKER_REPO}/openecomp/sdc-kibana:${RELEASE}
94docker 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 ${NEXUS_DOCKER_REPO}/openecomp/sdc-kibana:${RELEASE}
Michael Lando451a3402017-02-19 10:28:42 +020095
Grinberg Motic3bda482017-02-23 11:24:34 +020096dir_perms
Michael Lando451a3402017-02-19 10:28:42 +020097
98# Back-End
99echo "docker run sdc-backend..."
Grinberg Moti53fbfb52017-02-21 14:22:40 +0200100docker pull ${NEXUS_DOCKER_REPO}/openecomp/sdc-backend:${RELEASE}
101docker 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 ${NEXUS_DOCKER_REPO}/openecomp/sdc-backend:${RELEASE}
Michael Lando451a3402017-02-19 10:28:42 +0200102
103echo "please wait while BE is starting..."
104echo ""
105c=45 # seconds to wait
106REWRITE="\e[45D\e[1A\e[K"
107while [ $c -gt 0 ]; do
108 c=$((c-1))
109 sleep 1
110 echo -e "${REWRITE}$c"
111done
112echo -e ""
113
114
115# Front-End
116echo "docker run sdc-frontend..."
Grinberg Moti53fbfb52017-02-21 14:22:40 +0200117docker pull ${NEXUS_DOCKER_REPO}/openecomp/sdc-frontend:${RELEASE}
118docker 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 ${NEXUS_DOCKER_REPO}/openecomp/sdc-frontend:${RELEASE}
Michael Lando451a3402017-02-19 10:28:42 +0200119
120
121
122# running healthCheck scripts
123echo "Running health checks, please wait..."
124echo ""
125c=25 # seconds to wait
126REWRITE="\e[45D\e[1A\e[K"
127while [ $c -gt 0 ]; do
128 c=$((c-1))
129 sleep 1
130 echo -e "${REWRITE}$c"
131done
132echo -e ""
133
134/data/scripts/docker_health.sh
135
136if [ $? -ne 0 ]; then
137 exit 1
138fi
ml636r0649e652017-02-20 21:10:54 +0200139