Lvbo163 | 29660c6 | 2017-11-09 10:26:43 +0800 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | |
| 4 | function usage { |
| 5 | echo "usage: docker_run.sh [ -r|--release <RELEASE-NAME> ] [ -e|--environment <ENV-NAME> ] [ -p|--port <Docker-hub-port>] [ -l|--local <Run-without-pull>] [ -h|--help ]" |
| 6 | } |
| 7 | |
| 8 | |
| 9 | function cleanup { |
| 10 | echo "performing old dockers cleanup" |
| 11 | docker_ids=`docker ps -a | egrep "sdc-workflow-designer" | awk '{print $1}'` |
| 12 | for X in ${docker_ids} |
| 13 | do |
| 14 | docker rm -f ${X} |
| 15 | done |
| 16 | } |
| 17 | |
| 18 | |
| 19 | RELEASE=latest |
| 20 | LOCAL=false |
| 21 | [ -f /opt/config/env_name.txt ] && DEP_ENV=$(cat /opt/config/env_name.txt) || DEP_ENV=__ENV-NAME__ |
| 22 | [ -f /opt/config/nexus_username.txt ] && NEXUS_USERNAME=$(cat /opt/config/nexus_username.txt) || NEXUS_USERNAME=release |
| 23 | [ -f /opt/config/nexus_password.txt ] && NEXUS_PASSWD=$(cat /opt/config/nexus_password.txt) || NEXUS_PASSWD=sfWU3DFVdBr7GVxB85mTYgAW |
| 24 | [ -f /opt/config/nexus_docker_repo.txt ] && NEXUS_DOCKER_REPO=$(cat /opt/config/nexus_docker_repo.txt) || NEXUS_DOCKER_REPO=ecomp-nexus:${PORT} |
| 25 | |
| 26 | while [ "$1" != "" ]; do |
| 27 | case $1 in |
| 28 | -r | --release ) |
| 29 | shift |
| 30 | RELEASE=${1} |
| 31 | ;; |
| 32 | -e | --environment ) |
| 33 | shift |
| 34 | DEP_ENV=${1} |
| 35 | ;; |
| 36 | -p | --port ) |
| 37 | shift |
| 38 | PORT=${1} |
| 39 | ;; |
| 40 | -l | --local ) |
| 41 | shift |
| 42 | LOCAL=true |
| 43 | ;; |
| 44 | -h | --help ) |
| 45 | usage |
| 46 | exit |
| 47 | ;; |
| 48 | * ) |
| 49 | usage |
| 50 | exit 1 |
| 51 | esac |
| 52 | shift |
| 53 | done |
| 54 | |
| 55 | [ -f /opt/config/nexus_username.txt ] && docker login -u $NEXUS_USERNAME -p $NEXUS_PASSWD $NEXUS_DOCKER_REPO |
| 56 | |
| 57 | |
| 58 | cleanup |
| 59 | |
| 60 | |
| 61 | export IP=`ifconfig eth0 | awk -F: '/inet addr/ {gsub(/ .*/,"",$2); print $2}'` |
| 62 | export PREFIX=${NEXUS_DOCKER_REPO}'/onap' |
| 63 | |
| 64 | # start docker |
| 65 | echo "docker run sdc-workflow-designer..." |
| 66 | if [ ${LOCAL} = false ]; then |
| 67 | docker pull ${PREFIX}/sdc/sdc-workflow-designer:${RELEASE} |
| 68 | fi |
| 69 | docker run --detach --name sdc-workflow-designer --ulimit memlock=-1:-1 --memory 1g --memory-swap=1g --ulimit nofile=4096:100000 --publish 9527:8080 ${PREFIX}/sdc/sdc-workflow-designer:${RELEASE} |
| 70 | |
| 71 | |