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=__SDC-RELEASE__ |
| 11 | [ -f /opt/config/env_name.txt ] && DEP_ENV=$(cat /opt/config/env_name.txt) || DEP_ENV=__ENV-NAME__ |
| 12 | PORT=51212 |
| 13 | |
| 14 | while [ "$1" != "" ]; do |
| 15 | case $1 in |
| 16 | -d | --docker ) |
| 17 | shift |
| 18 | DOCKER=${1} |
| 19 | ;; |
| 20 | -r | --release ) |
| 21 | shift |
| 22 | RELEASE=${1} |
| 23 | ;; |
| 24 | -e | --environment ) |
| 25 | shift |
| 26 | DEP_ENV=${1} |
| 27 | ;; |
| 28 | -p | --port ) |
| 29 | shift |
| 30 | PORT=${1} |
| 31 | ;; |
| 32 | -h | --help ) |
| 33 | usage |
| 34 | exit |
| 35 | ;; |
| 36 | * ) |
| 37 | usage |
| 38 | exit 1 |
| 39 | esac |
| 40 | shift |
| 41 | done |
| 42 | |
| 43 | [ -f /opt/config/nexus_username.txt ] && NEXUS_USERNAME=$(cat /opt/config/nexus_username.txt) || NEXUS_USERNAME=release |
| 44 | [ -f /opt/config/nexus_password.txt ] && NEXUS_PASSWD=$(cat /opt/config/nexus_password.txt) || NEXUS_PASSWD=sfWU3DFVdBr7GVxB85mTYgAW |
| 45 | [ -f /opt/config/nexus_docker_repo.txt ] && NEXUS_DOCKER_REPO=$(cat /opt/config/nexus_docker_repo.txt) || NEXUS_DOCKER_REPO=ecomp-nexus:${PORT} |
| 46 | |
| 47 | [ -f /opt/config/nexus_username.txt ] && docker login -u $NEXUS_USERNAME -p $NEXUS_PASSWD $NEXUS_DOCKER_REPO |
| 48 | |
| 49 | |
| 50 | # cleanup |
| 51 | echo "performing old dockers cleanup" |
| 52 | docker_ids=`docker ps -a | egrep "${DOCKER}|Exit" | awk '{print $1}'` |
| 53 | for X in ${docker_ids} |
| 54 | do |
| 55 | docker rm -f ${X} |
| 56 | done |
| 57 | |
| 58 | export IP=`ifconfig eth0 | awk -F: '/inet addr/ {gsub(/ .*/,"",$2); print $2}'` |
| 59 | |
| 60 | echo "" |
| 61 | |
| 62 | case ${DOCKER} in |
| 63 | elastic | es ) |
| 64 | # Elastic-Search |
| 65 | echo "docker run sdc-elasticsearch..." |
| 66 | docker pull ecomp-nexus:${PORT}/ecomp/sdc-elasticsearch:${RELEASE} |
| 67 | 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 ecomp-nexus:${PORT}/ecomp/sdc-elasticsearch:${RELEASE} |
| 68 | ;; |
| 69 | |
| 70 | cassandra | cs ) |
| 71 | # cassandra |
| 72 | echo "docker run sdc-cassandra..." |
| 73 | docker pull ecomp-nexus:${PORT}/ecomp/sdc-cassandra:${RELEASE} |
| 74 | 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 ecomp-nexus:${PORT}/ecomp/sdc-cassandra:${RELEASE} |
| 75 | ;; |
| 76 | |
| 77 | kibana | kbn ) |
| 78 | # kibana |
| 79 | echo "docker run sdc-kibana..." |
| 80 | docker pull ecomp-nexus:${PORT}/ecomp/sdc-kibana:${RELEASE} |
| 81 | 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 1g --memory-swap=1g --ulimit nofile=4096:100000 --volume /etc/localtime:/etc/localtime:ro --volume /data/environments:/root/chef-solo/environments --publish 5601:5601 ecomp-nexus:${PORT}/ecomp/sdc-kibana:${RELEASE} |
| 82 | ;; |
| 83 | |
| 84 | backend | be ) |
| 85 | # Back-End |
| 86 | echo "docker run sdc-backend..." |
| 87 | docker pull ecomp-nexus:${PORT}/ecomp/sdc-backend:${RELEASE} |
| 88 | 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 ecomp-nexus:${PORT}/ecomp/sdc-backend:${RELEASE} |
| 89 | ;; |
| 90 | |
| 91 | frontend | fe ) |
| 92 | # Front-End |
| 93 | echo "docker run sdc-frontend..." |
| 94 | docker pull ecomp-nexus:${PORT}/ecomp/sdc-frontend:${RELEASE} |
| 95 | 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 ecomp-nexus:${PORT}/ecomp/sdc-frontend:${RELEASE} |
| 96 | ;; |
| 97 | esac |
ml636r | 0649e65 | 2017-02-20 21:10:54 +0200 | [diff] [blame] | 98 | |