Michael Lando | 451a340 | 2017-02-19 10:28:42 +0200 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | |
Grinberg Moti | c3bda48 | 2017-02-23 11:24:34 +0200 | [diff] [blame] | 4 | function usage { |
Yuli Shlosberg | 9dde926 | 2017-09-12 14:11:48 +0300 | [diff] [blame] | 5 | 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 Lando | 451a340 | 2017-02-19 10:28:42 +0200 | [diff] [blame] | 6 | } |
| 7 | |
| 8 | |
Grinberg Moti | c3bda48 | 2017-02-23 11:24:34 +0200 | [diff] [blame] | 9 | function cleanup { |
| 10 | echo "performing old dockers cleanup" |
Idan Amit | c7f57ec | 2017-08-31 14:26:21 +0300 | [diff] [blame] | 11 | docker_ids=`docker ps -a | egrep -v "openecomp/sdc-simulator" | egrep "ecomp-nexus:${PORT}/sdc|sdc|Exit" | awk '{print $1}'` |
Grinberg Moti | c3bda48 | 2017-02-23 11:24:34 +0200 | [diff] [blame] | 12 | for X in ${docker_ids} |
| 13 | do |
| 14 | docker rm -f ${X} |
| 15 | done |
| 16 | } |
| 17 | |
| 18 | |
| 19 | function dir_perms { |
| 20 | mkdir -p /data/logs/BE/ASDC/ASDC-BE |
| 21 | mkdir -p /data/logs/FE/ASDC/ASDC-FE |
Michael Lando | 33d78d8 | 2017-02-27 19:48:33 +0200 | [diff] [blame] | 22 | chmod -R 777 /data/logs |
Grinberg Moti | c3bda48 | 2017-02-23 11:24:34 +0200 | [diff] [blame] | 23 | } |
| 24 | |
| 25 | |
Grinberg Moti | 9724621 | 2017-02-21 19:30:31 +0200 | [diff] [blame] | 26 | RELEASE=latest |
Idan Amit | c7f57ec | 2017-08-31 14:26:21 +0300 | [diff] [blame] | 27 | LOCAL=false |
Yuli Shlosberg | 9dde926 | 2017-09-12 14:11:48 +0300 | [diff] [blame] | 28 | SKIPTESTS=false |
Michael Lando | 451a340 | 2017-02-19 10:28:42 +0200 | [diff] [blame] | 29 | [ -f /opt/config/env_name.txt ] && DEP_ENV=$(cat /opt/config/env_name.txt) || DEP_ENV=__ENV-NAME__ |
Grinberg Moti | 53fbfb5 | 2017-02-21 14:22:40 +0200 | [diff] [blame] | 30 | [ -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 Lando | 451a340 | 2017-02-19 10:28:42 +0200 | [diff] [blame] | 33 | |
| 34 | while [ "$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 Amit | c7f57ec | 2017-08-31 14:26:21 +0300 | [diff] [blame] | 48 | -l | --local ) |
| 49 | shift |
| 50 | LOCAL=true |
| 51 | ;; |
Yuli Shlosberg | 9dde926 | 2017-09-12 14:11:48 +0300 | [diff] [blame] | 52 | -s | --skipTests ) |
| 53 | shift |
| 54 | SKIPTESTS=true |
| 55 | ;; |
Michael Lando | 451a340 | 2017-02-19 10:28:42 +0200 | [diff] [blame] | 56 | -h | --help ) |
| 57 | usage |
| 58 | exit |
| 59 | ;; |
| 60 | * ) |
| 61 | usage |
| 62 | exit 1 |
| 63 | esac |
| 64 | shift |
| 65 | done |
| 66 | |
Michael Lando | 451a340 | 2017-02-19 10:28:42 +0200 | [diff] [blame] | 67 | [ -f /opt/config/nexus_username.txt ] && docker login -u $NEXUS_USERNAME -p $NEXUS_PASSWD $NEXUS_DOCKER_REPO |
| 68 | |
| 69 | |
Grinberg Moti | c3bda48 | 2017-02-23 11:24:34 +0200 | [diff] [blame] | 70 | cleanup |
| 71 | |
Michael Lando | 451a340 | 2017-02-19 10:28:42 +0200 | [diff] [blame] | 72 | |
| 73 | export IP=`ifconfig eth0 | awk -F: '/inet addr/ {gsub(/ .*/,"",$2); print $2}'` |
Idan Amit | c7f57ec | 2017-08-31 14:26:21 +0300 | [diff] [blame] | 74 | export PREFIX=${NEXUS_DOCKER_REPO}'/openecomp' |
| 75 | |
| 76 | if [ ${LOCAL} = true ]; then |
| 77 | PREFIX='openecomp' |
| 78 | fi |
Michael Lando | 451a340 | 2017-02-19 10:28:42 +0200 | [diff] [blame] | 79 | |
| 80 | echo "" |
| 81 | |
| 82 | # Elastic-Search |
| 83 | echo "docker run sdc-elasticsearch..." |
Idan Amit | c7f57ec | 2017-08-31 14:26:21 +0300 | [diff] [blame] | 84 | if [ ${LOCAL} = false ]; then |
| 85 | echo "pulling code" |
| 86 | docker pull ${PREFIX}/sdc-elasticsearch:${RELEASE} |
| 87 | fi |
| 88 | docker 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 |
| 92 | echo "docker run sdc-cassandra..." |
| 93 | if [ ${LOCAL} = false ]; then |
| 94 | docker pull ${PREFIX}/sdc-cassandra:${RELEASE} |
| 95 | fi |
Idan Amit | 9409da0 | 2017-09-03 14:46:10 +0300 | [diff] [blame] | 96 | docker 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 Lando | 451a340 | 2017-02-19 10:28:42 +0200 | [diff] [blame] | 97 | |
| 98 | |
| 99 | echo "please wait while CS is starting..." |
| 100 | echo "" |
Michael Lando | ed64b5e | 2017-06-09 03:19:04 +0300 | [diff] [blame] | 101 | c=120 # seconds to wait |
Michael Lando | 451a340 | 2017-02-19 10:28:42 +0200 | [diff] [blame] | 102 | REWRITE="\e[25D\e[1A\e[K" |
| 103 | while [ $c -gt 0 ]; do |
| 104 | c=$((c-1)) |
| 105 | sleep 1 |
| 106 | echo -e "${REWRITE}$c" |
| 107 | done |
| 108 | echo -e "" |
| 109 | |
Michael Lando | 451a340 | 2017-02-19 10:28:42 +0200 | [diff] [blame] | 110 | # kibana |
| 111 | echo "docker run sdc-kibana..." |
Idan Amit | c7f57ec | 2017-08-31 14:26:21 +0300 | [diff] [blame] | 112 | if [ ${LOCAL} = false ]; then |
| 113 | docker pull ${PREFIX}/sdc-kibana:${RELEASE} |
| 114 | fi |
| 115 | docker 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 Lando | 451a340 | 2017-02-19 10:28:42 +0200 | [diff] [blame] | 116 | |
Grinberg Moti | c3bda48 | 2017-02-23 11:24:34 +0200 | [diff] [blame] | 117 | dir_perms |
Michael Lando | 451a340 | 2017-02-19 10:28:42 +0200 | [diff] [blame] | 118 | |
| 119 | # Back-End |
| 120 | echo "docker run sdc-backend..." |
Idan Amit | c7f57ec | 2017-08-31 14:26:21 +0300 | [diff] [blame] | 121 | if [ ${LOCAL} = false ]; then |
| 122 | docker pull ${PREFIX}/sdc-backend:${RELEASE} |
| 123 | fi |
| 124 | docker 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 Lando | 451a340 | 2017-02-19 10:28:42 +0200 | [diff] [blame] | 125 | |
| 126 | echo "please wait while BE is starting..." |
| 127 | echo "" |
| 128 | c=45 # seconds to wait |
| 129 | REWRITE="\e[45D\e[1A\e[K" |
| 130 | while [ $c -gt 0 ]; do |
| 131 | c=$((c-1)) |
| 132 | sleep 1 |
| 133 | echo -e "${REWRITE}$c" |
| 134 | done |
| 135 | echo -e "" |
| 136 | |
| 137 | |
| 138 | # Front-End |
| 139 | echo "docker run sdc-frontend..." |
Idan Amit | c7f57ec | 2017-08-31 14:26:21 +0300 | [diff] [blame] | 140 | if [ ${LOCAL} = false ]; then |
| 141 | docker pull ${PREFIX}/sdc-frontend:${RELEASE} |
| 142 | fi |
| 143 | docker 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 Lando | 451a340 | 2017-02-19 10:28:42 +0200 | [diff] [blame] | 144 | |
| 145 | |
| 146 | |
| 147 | # running healthCheck scripts |
| 148 | echo "Running health checks, please wait..." |
| 149 | echo "" |
Tal Gitelman | 0a92119 | 2017-10-03 15:03:25 +0300 | [diff] [blame] | 150 | c=30 # seconds to wait |
Michael Lando | 451a340 | 2017-02-19 10:28:42 +0200 | [diff] [blame] | 151 | REWRITE="\e[45D\e[1A\e[K" |
| 152 | while [ $c -gt 0 ]; do |
| 153 | c=$((c-1)) |
| 154 | sleep 1 |
| 155 | echo -e "${REWRITE}$c" |
| 156 | done |
| 157 | echo -e "" |
| 158 | |
| 159 | /data/scripts/docker_health.sh |
| 160 | |
| 161 | if [ $? -ne 0 ]; then |
| 162 | exit 1 |
| 163 | fi |
ml636r | 0649e65 | 2017-02-20 21:10:54 +0200 | [diff] [blame] | 164 | |
Yuli Shlosberg | 9dde926 | 2017-09-12 14:11:48 +0300 | [diff] [blame] | 165 | # sanityDocker |
| 166 | echo "docker run sdc-frontend..." |
| 167 | if [ ${SKIPTESTS} = false ]; then |
| 168 | echo "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} |
| 173 | fi |