blob: bb26b81f671fe09f2a70d1ea29835fbeec5fdeb1 [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__
Grinberg Moti53fbfb52017-02-21 14:22:40 +020012[ -f /opt/config/nexus_username.txt ] && NEXUS_USERNAME=$(cat /opt/config/nexus_username.txt) || NEXUS_USERNAME=release
13[ -f /opt/config/nexus_password.txt ] && NEXUS_PASSWD=$(cat /opt/config/nexus_password.txt) || NEXUS_PASSWD=sfWU3DFVdBr7GVxB85mTYgAW
14[ -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 +020015
16while [ "$1" != "" ]; do
17 case $1 in
18 -r | --release )
19 shift
20 RELEASE=${1}
21 ;;
22 -e | --environment )
23 shift
24 DEP_ENV=${1}
25 ;;
26 -p | --port )
27 shift
28 PORT=${1}
29 ;;
30 -h | --help )
31 usage
32 exit
33 ;;
34 * )
35 usage
36 exit 1
37 esac
38 shift
39done
40
Michael Lando451a3402017-02-19 10:28:42 +020041[ -f /opt/config/nexus_username.txt ] && docker login -u $NEXUS_USERNAME -p $NEXUS_PASSWD $NEXUS_DOCKER_REPO
42
43
44# cleanup
45echo "performing old dockers cleanup"
46docker_ids=`docker ps -a | egrep "ecomp-nexus:${PORT}/sdc|sdc|Exit" | awk '{print $1}'`
47for X in ${docker_ids}
48do
49 docker rm -f ${X}
50done
51
52export IP=`ifconfig eth0 | awk -F: '/inet addr/ {gsub(/ .*/,"",$2); print $2}'`
53
54echo ""
55
56# Elastic-Search
57echo "docker run sdc-elasticsearch..."
Grinberg Moti53fbfb52017-02-21 14:22:40 +020058docker pull ${NEXUS_DOCKER_REPO}/openopenecomp/sdc-elasticsearch:${RELEASE}
59docker 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 +020060
61
62# cassandra
63echo "docker run sdc-cassandra..."
Grinberg Moti53fbfb52017-02-21 14:22:40 +020064docker pull ${NEXUS_DOCKER_REPO}/openecomp/sdc-cassandra:${RELEASE}
65docker 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 ${NEXUS_DOCKER_REPO}/openecomp/sdc-cassandra:${RELEASE}
Michael Lando451a3402017-02-19 10:28:42 +020066
67
68echo "please wait while CS is starting..."
69echo ""
70c=25 # seconds to wait
71REWRITE="\e[25D\e[1A\e[K"
72while [ $c -gt 0 ]; do
73 c=$((c-1))
74 sleep 1
75 echo -e "${REWRITE}$c"
76done
77echo -e ""
78
79
80# kibana
81echo "docker run sdc-kibana..."
Grinberg Moti53fbfb52017-02-21 14:22:40 +020082docker pull ${NEXUS_DOCKER_REPO}/openecomp/sdc-kibana:${RELEASE}
83docker 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 +020084
85
86# Back-End
87echo "docker run sdc-backend..."
Grinberg Moti53fbfb52017-02-21 14:22:40 +020088docker pull ${NEXUS_DOCKER_REPO}/openecomp/sdc-backend:${RELEASE}
89docker 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 +020090
91echo "please wait while BE is starting..."
92echo ""
93c=45 # seconds to wait
94REWRITE="\e[45D\e[1A\e[K"
95while [ $c -gt 0 ]; do
96 c=$((c-1))
97 sleep 1
98 echo -e "${REWRITE}$c"
99done
100echo -e ""
101
102
103# Front-End
104echo "docker run sdc-frontend..."
Grinberg Moti53fbfb52017-02-21 14:22:40 +0200105docker pull ${NEXUS_DOCKER_REPO}/openecomp/sdc-frontend:${RELEASE}
106docker 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 +0200107
108
109
110# running healthCheck scripts
111echo "Running health checks, please wait..."
112echo ""
113c=25 # seconds to wait
114REWRITE="\e[45D\e[1A\e[K"
115while [ $c -gt 0 ]; do
116 c=$((c-1))
117 sleep 1
118 echo -e "${REWRITE}$c"
119done
120echo -e ""
121
122/data/scripts/docker_health.sh
123
124if [ $? -ne 0 ]; then
125 exit 1
126fi
ml636r0649e652017-02-20 21:10:54 +0200127