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 { |
Michael Lando | 451a340 | 2017-02-19 10:28:42 +0200 | [diff] [blame] | 5 | echo "usage: docker_run.sh [ -r|--release <RELEASE-NAME> ] [ -e|--environment <ENV-NAME> ] [ -p|--port <Docker-hub-port>] [ -h|--help ]" |
| 6 | } |
| 7 | |
| 8 | |
Grinberg Moti | c3bda48 | 2017-02-23 11:24:34 +0200 | [diff] [blame] | 9 | function 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 | |
| 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 |
Michael Lando | 451a340 | 2017-02-19 10:28:42 +0200 | [diff] [blame] | 27 | [ -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] | 28 | [ -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 Lando | 451a340 | 2017-02-19 10:28:42 +0200 | [diff] [blame] | 31 | |
| 32 | while [ "$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 |
| 55 | done |
| 56 | |
Michael Lando | 451a340 | 2017-02-19 10:28:42 +0200 | [diff] [blame] | 57 | [ -f /opt/config/nexus_username.txt ] && docker login -u $NEXUS_USERNAME -p $NEXUS_PASSWD $NEXUS_DOCKER_REPO |
| 58 | |
| 59 | |
Grinberg Moti | c3bda48 | 2017-02-23 11:24:34 +0200 | [diff] [blame] | 60 | cleanup |
| 61 | |
Michael Lando | 451a340 | 2017-02-19 10:28:42 +0200 | [diff] [blame] | 62 | |
| 63 | export IP=`ifconfig eth0 | awk -F: '/inet addr/ {gsub(/ .*/,"",$2); print $2}'` |
| 64 | |
| 65 | echo "" |
| 66 | |
| 67 | # Elastic-Search |
| 68 | echo "docker run sdc-elasticsearch..." |
Grinberg Moti | cd6eeaa | 2017-02-23 14:26:04 +0200 | [diff] [blame] | 69 | docker pull ${NEXUS_DOCKER_REPO}/openecomp/sdc-elasticsearch:${RELEASE} |
Grinberg Moti | 53fbfb5 | 2017-02-21 14:22:40 +0200 | [diff] [blame] | 70 | 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 ${NEXUS_DOCKER_REPO}/openecomp/sdc-elasticsearch:${RELEASE} |
Michael Lando | 451a340 | 2017-02-19 10:28:42 +0200 | [diff] [blame] | 71 | |
| 72 | |
| 73 | # cassandra |
| 74 | echo "docker run sdc-cassandra..." |
Grinberg Moti | 53fbfb5 | 2017-02-21 14:22:40 +0200 | [diff] [blame] | 75 | docker pull ${NEXUS_DOCKER_REPO}/openecomp/sdc-cassandra:${RELEASE} |
| 76 | docker 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 Lando | 451a340 | 2017-02-19 10:28:42 +0200 | [diff] [blame] | 77 | |
| 78 | |
| 79 | echo "please wait while CS is starting..." |
| 80 | echo "" |
| 81 | c=25 # seconds to wait |
| 82 | REWRITE="\e[25D\e[1A\e[K" |
| 83 | while [ $c -gt 0 ]; do |
| 84 | c=$((c-1)) |
| 85 | sleep 1 |
| 86 | echo -e "${REWRITE}$c" |
| 87 | done |
| 88 | echo -e "" |
| 89 | |
| 90 | |
| 91 | # kibana |
| 92 | echo "docker run sdc-kibana..." |
Grinberg Moti | 53fbfb5 | 2017-02-21 14:22:40 +0200 | [diff] [blame] | 93 | docker pull ${NEXUS_DOCKER_REPO}/openecomp/sdc-kibana:${RELEASE} |
| 94 | 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 ${NEXUS_DOCKER_REPO}/openecomp/sdc-kibana:${RELEASE} |
Michael Lando | 451a340 | 2017-02-19 10:28:42 +0200 | [diff] [blame] | 95 | |
Grinberg Moti | c3bda48 | 2017-02-23 11:24:34 +0200 | [diff] [blame] | 96 | dir_perms |
Michael Lando | 451a340 | 2017-02-19 10:28:42 +0200 | [diff] [blame] | 97 | |
| 98 | # Back-End |
| 99 | echo "docker run sdc-backend..." |
Grinberg Moti | 53fbfb5 | 2017-02-21 14:22:40 +0200 | [diff] [blame] | 100 | docker pull ${NEXUS_DOCKER_REPO}/openecomp/sdc-backend:${RELEASE} |
| 101 | docker 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 Lando | 451a340 | 2017-02-19 10:28:42 +0200 | [diff] [blame] | 102 | |
| 103 | echo "please wait while BE is starting..." |
| 104 | echo "" |
| 105 | c=45 # seconds to wait |
| 106 | REWRITE="\e[45D\e[1A\e[K" |
| 107 | while [ $c -gt 0 ]; do |
| 108 | c=$((c-1)) |
| 109 | sleep 1 |
| 110 | echo -e "${REWRITE}$c" |
| 111 | done |
| 112 | echo -e "" |
| 113 | |
| 114 | |
| 115 | # Front-End |
| 116 | echo "docker run sdc-frontend..." |
Grinberg Moti | 53fbfb5 | 2017-02-21 14:22:40 +0200 | [diff] [blame] | 117 | docker pull ${NEXUS_DOCKER_REPO}/openecomp/sdc-frontend:${RELEASE} |
| 118 | docker 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 Lando | 451a340 | 2017-02-19 10:28:42 +0200 | [diff] [blame] | 119 | |
| 120 | |
| 121 | |
| 122 | # running healthCheck scripts |
| 123 | echo "Running health checks, please wait..." |
| 124 | echo "" |
| 125 | c=25 # seconds to wait |
| 126 | REWRITE="\e[45D\e[1A\e[K" |
| 127 | while [ $c -gt 0 ]; do |
| 128 | c=$((c-1)) |
| 129 | sleep 1 |
| 130 | echo -e "${REWRITE}$c" |
| 131 | done |
| 132 | echo -e "" |
| 133 | |
| 134 | /data/scripts/docker_health.sh |
| 135 | |
| 136 | if [ $? -ne 0 ]; then |
| 137 | exit 1 |
| 138 | fi |
ml636r | 0649e65 | 2017-02-20 21:10:54 +0200 | [diff] [blame] | 139 | |