Michael Lando | 451a340 | 2017-02-19 10:28:42 +0200 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | |
| 4 | function 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 | |
| 10 | RELEASE=1.0.0-SNAPSHOT |
| 11 | [ -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^] | 12 | [ -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 Lando | 451a340 | 2017-02-19 10:28:42 +0200 | [diff] [blame] | 15 | |
| 16 | while [ "$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 |
| 39 | done |
| 40 | |
Michael Lando | 451a340 | 2017-02-19 10:28:42 +0200 | [diff] [blame] | 41 | [ -f /opt/config/nexus_username.txt ] && docker login -u $NEXUS_USERNAME -p $NEXUS_PASSWD $NEXUS_DOCKER_REPO |
| 42 | |
| 43 | |
| 44 | # cleanup |
| 45 | echo "performing old dockers cleanup" |
| 46 | docker_ids=`docker ps -a | egrep "ecomp-nexus:${PORT}/sdc|sdc|Exit" | awk '{print $1}'` |
| 47 | for X in ${docker_ids} |
| 48 | do |
| 49 | docker rm -f ${X} |
| 50 | done |
| 51 | |
| 52 | export IP=`ifconfig eth0 | awk -F: '/inet addr/ {gsub(/ .*/,"",$2); print $2}'` |
| 53 | |
| 54 | echo "" |
| 55 | |
| 56 | # Elastic-Search |
| 57 | echo "docker run sdc-elasticsearch..." |
Grinberg Moti | 53fbfb5 | 2017-02-21 14:22:40 +0200 | [diff] [blame^] | 58 | docker pull ${NEXUS_DOCKER_REPO}/openopenecomp/sdc-elasticsearch:${RELEASE} |
| 59 | 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] | 60 | |
| 61 | |
| 62 | # cassandra |
| 63 | echo "docker run sdc-cassandra..." |
Grinberg Moti | 53fbfb5 | 2017-02-21 14:22:40 +0200 | [diff] [blame^] | 64 | docker pull ${NEXUS_DOCKER_REPO}/openecomp/sdc-cassandra:${RELEASE} |
| 65 | 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] | 66 | |
| 67 | |
| 68 | echo "please wait while CS is starting..." |
| 69 | echo "" |
| 70 | c=25 # seconds to wait |
| 71 | REWRITE="\e[25D\e[1A\e[K" |
| 72 | while [ $c -gt 0 ]; do |
| 73 | c=$((c-1)) |
| 74 | sleep 1 |
| 75 | echo -e "${REWRITE}$c" |
| 76 | done |
| 77 | echo -e "" |
| 78 | |
| 79 | |
| 80 | # kibana |
| 81 | echo "docker run sdc-kibana..." |
Grinberg Moti | 53fbfb5 | 2017-02-21 14:22:40 +0200 | [diff] [blame^] | 82 | docker pull ${NEXUS_DOCKER_REPO}/openecomp/sdc-kibana:${RELEASE} |
| 83 | 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] | 84 | |
| 85 | |
| 86 | # Back-End |
| 87 | echo "docker run sdc-backend..." |
Grinberg Moti | 53fbfb5 | 2017-02-21 14:22:40 +0200 | [diff] [blame^] | 88 | docker pull ${NEXUS_DOCKER_REPO}/openecomp/sdc-backend:${RELEASE} |
| 89 | 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] | 90 | |
| 91 | echo "please wait while BE is starting..." |
| 92 | echo "" |
| 93 | c=45 # seconds to wait |
| 94 | REWRITE="\e[45D\e[1A\e[K" |
| 95 | while [ $c -gt 0 ]; do |
| 96 | c=$((c-1)) |
| 97 | sleep 1 |
| 98 | echo -e "${REWRITE}$c" |
| 99 | done |
| 100 | echo -e "" |
| 101 | |
| 102 | |
| 103 | # Front-End |
| 104 | echo "docker run sdc-frontend..." |
Grinberg Moti | 53fbfb5 | 2017-02-21 14:22:40 +0200 | [diff] [blame^] | 105 | docker pull ${NEXUS_DOCKER_REPO}/openecomp/sdc-frontend:${RELEASE} |
| 106 | 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] | 107 | |
| 108 | |
| 109 | |
| 110 | # running healthCheck scripts |
| 111 | echo "Running health checks, please wait..." |
| 112 | echo "" |
| 113 | c=25 # seconds to wait |
| 114 | REWRITE="\e[45D\e[1A\e[K" |
| 115 | while [ $c -gt 0 ]; do |
| 116 | c=$((c-1)) |
| 117 | sleep 1 |
| 118 | echo -e "${REWRITE}$c" |
| 119 | done |
| 120 | echo -e "" |
| 121 | |
| 122 | /data/scripts/docker_health.sh |
| 123 | |
| 124 | if [ $? -ne 0 ]; then |
| 125 | exit 1 |
| 126 | fi |
ml636r | 0649e65 | 2017-02-20 21:10:54 +0200 | [diff] [blame] | 127 | |