7 WORKSPACE="${WORKSPACE:-}"
18 JAVA_OPTIONS="-XX:MaxPermSize=256m -Xmx1024m"
21 #Define this as variable, so it can be excluded in run commands on Docker for OSX, as /etc/localtime cant be mounted there.
22 LOCAL_TIME_MOUNT_CMD="--volume /etc/localtime:/etc/localtime:ro"
24 # If os is OSX, unset this, so /etc/localtime is not mounted, otherwise leave it be
25 if [[ "$OSTYPE" == "darwin"* ]]; then
26 LOCAL_TIME_MOUNT_CMD=""
30 DOCKER_RUN_MODE_BG="--detach"
31 DOCKER_RUN_MODE_FG="-dti"
39 echo "usage: dcae_docker_run.sh [ -r|--release <RELEASE-NAME> ] [ -e|--environment <ENV-NAME> ] [ -p|--port <Docker-hub-port>] [ -l|--local <Run-without-pull>] [ -h|--help ]"
40 echo "example: sudo bash dcae_docker_run.sh -e AUTO -r 1.2-STAGING-latest"
46 echo "Performing old dockers cleanup"
48 if [ "$1" == "all" ] ; then
49 docker_ids=$(docker ps -a | egrep "dcae" | awk '{print $1}')
50 for X in ${docker_ids}
55 echo "performing $1 docker cleanup"
56 tmp=$(docker ps -a -q --filter="name=$1")
57 if [[ -n "$tmp" ]]; then
66 mkdir -p "${WORKSPACE}/data/logs/DCAE-BE/DCAE"
67 mkdir -p "${WORKSPACE}/data/logs/DCAE-FE/DCAE"
68 mkdir -p "${WORKSPACE}/data/logs/DCAE-DT/DCAE"
69 mkdir -p "${WORKSPACE}/data/logs/DCAE-TOSCA/DCAE"
71 chmod -R 777 "${WORKSPACE}/data/logs"
76 function docker_logs {
77 docker logs "$1" > "${WORKSPACE}/data/logs/docker_logs/$1_docker.log"
86 function ready_probe {
87 docker exec "$1" /var/lib/ready-probe.sh > /dev/null 2>&1
89 if [[ ${rc} == 0 ]]; then
90 echo "DOCKER $1 start finished in $2 seconds"
98 function probe_docker {
99 MATCH=$(docker logs --tail 30 "$1" | grep "DOCKER STARTED")
100 echo MATCH is -- "${MATCH}"
102 if [ -n "$MATCH" ] ; then
103 echo "DOCKER start finished in $2 seconds"
110 function probe_dcae_tosca {
111 health_check_http_code=$(curl --noproxy "*" -k -i -o /dev/null -w '%{http_code}' "http://${IP}:8085/healthcheck")
112 if [[ "${health_check_http_code}" -eq 200 ]] ; then
113 echo "DOCKER start finished in $1 seconds"
120 # probe script used the secure connection to do health check (https is always turn on)
121 function probe_dcae_be {
122 health_check_http_code=$(curl --noproxy "*" -k -i -o /dev/null -w '%{http_code}' "https://${IP}:8444/dcae/conf/composition")
123 if [[ "${health_check_http_code}" -eq 200 ]] ; then
124 echo "DOCKER start finished in $1 seconds"
131 function probe_dcae_fe {
132 health_check_http_code=$(curl --noproxy "*" -k -i -o /dev/null -w '%{http_code}' "https://${IP}:9444/dcaed/healthCheck")
133 if [[ "${health_check_http_code}" -eq 200 ]] ; then
134 echo "DOCKER start finished in $1 seconds"
141 function probe_dcae_dt {
142 health_check_http_code=$(curl --noproxy "*" -k -i -o /dev/null -w '%{http_code}' "https://${IP}:9446/dcae/healthCheckOld")
143 if [[ "${health_check_http_code}" -eq 200 ]] ; then
144 echo "DOCKER start finished in $1 seconds"
151 # Not applicable for current release. Return Success in any case
152 function probe_dcae_tools {
153 health_check_http_code=$(curl --noproxy "*" -k -i -o /dev/null -w '%{http_code}' "https://${IP}:8444/dcae/getResourcesByMonitoringTemplateCategory")
154 if [[ "${health_check_http_code}" -eq 200 ]] ; then
155 echo "DOCKER start finished in $1 seconds"
163 function monitor_docker {
165 echo "Monitor ${DOCKER_NAME} Docker"
171 while [ "$TIME" -lt "$TIME_OUT" ]; do
173 case ${DOCKER_NAME} in
176 probe_dcae_tosca ${TIME} ;
180 probe_dcae_be ${TIME} ;
184 probe_dcae_fe ${TIME} ;
188 probe_dcae_dt ${TIME} ;
196 probe_docker "${DOCKER_NAME}" ${TIME};
202 if [ ${status} == ${SUCCESS} ] ; then
206 echo "Sleep: ${INTERVAL} seconds before testing if ${DOCKER_NAME} DOCKER is up. Total wait time up now is: ${TIME} seconds. Timeout is: ${TIME_OUT} seconds"
208 TIME=$(($TIME+$INTERVAL))
211 docker_logs "${DOCKER_NAME}"
213 if [ "$TIME" -ge "$TIME_OUT" ]; then
214 echo -e "\e[1;31mTIME OUT: DOCKER was NOT fully started in $TIME_OUT seconds... Could cause problems ...\e[0m"
219 # healthCheck script used the secure connection to send request (https is always turn on)
220 function healthCheck {
222 echo "BE health-Check:"
223 curl -k --noproxy "*" "https://${IP}:8443/sdc2/rest/healthCheck"
227 echo "FE health-Check:"
228 curl -k --noproxy "*" "https://${IP}:9443/sdc1/rest/healthCheck"
233 function command_exit_status {
236 if [ "${status}" != "0" ] ; then
237 echo "[ ERROR ] Docker ${docker} run command exit with status [${status}]"
249 function dcae-tosca {
250 DOCKER_NAME="dcae-tosca-app"
251 echo "docker run ${DOCKER_NAME}..."
252 if [ ${LOCAL} == false ]; then
253 docker pull "${PREFIX}/${DOCKER_NAME}:${RELEASE}"
255 docker run ${DOCKER_RUN_MODE_FG} --name ${DOCKER_NAME} --env HOST_IP="${IP}" --env ENVNAME="${DEP_ENV}" --env JAVA_OPTIONS="${JAVA_OPTIONS}" --log-driver=json-file --log-opt max-size=100m --log-opt max-file=10 --ulimit memlock=-1:-1 --ulimit nofile=4096:100000 ${LOCAL_TIME_MOUNT_CMD} --volume "${WORKSPACE}/data/logs/DCAE-TOSCA/:/var/logs/dcae" --publish 8085:8085 "${PREFIX}/${DOCKER_NAME}:${RELEASE}"
256 command_exit_status $? ${DOCKER_NAME}
257 echo "please wait while ${DOCKER_NAME^^} is starting....."
258 monitor_docker ${DOCKER_NAME}
265 DOCKER_NAME="dcae-be"
266 echo "docker run ${DOCKER_NAME}..."
267 if [ ${LOCAL} == false ]; then
268 docker pull "${PREFIX}/${DOCKER_NAME}:${RELEASE}"
270 docker run ${DOCKER_RUN_MODE_FG} --name ${DOCKER_NAME} --env HOST_IP="${IP}" --env ENVNAME="${DEP_ENV}" --env JAVA_OPTIONS="${JAVA_OPTIONS}" --log-driver=json-file --log-opt max-size=100m --log-opt max-file=10 --ulimit memlock=-1:-1 --ulimit nofile=4096:100000 ${LOCAL_TIME_MOUNT_CMD} --volume "${WORKSPACE}/data/logs/DCAE-BE/:/var/lib/jetty/logs" --volume "${WORKSPACE}/data/environments:/root/chef-solo/environments" --publish 8444:8444 --publish 8082:8082 "${PREFIX}/${DOCKER_NAME}:${RELEASE}" /bin/sh
271 command_exit_status $? ${DOCKER_NAME}
272 echo "please wait while ${DOCKER_NAME^^} is starting....."
273 monitor_docker ${DOCKER_NAME}
279 function dcae-tools {
280 DOCKER_NAME="dcae-tools"
281 echo "docker run ${DOCKER_NAME}..."
282 if [ ${LOCAL} == false ]; then
283 docker pull "${PREFIX}/${DOCKER_NAME}:${RELEASE}"
285 docker run ${DOCKER_RUN_MODE_BG} --name ${DOCKER_NAME} --env HOST_IP="${IP}" --env ENVNAME="${DEP_ENV}" ${LOCAL_TIME_MOUNT_CMD} --volume "${WORKSPACE}/data/logs/BE/:/var/lib/jetty/logs" --volume "${WORKSPACE}/data/environments:/var/opt/dcae-tools/chef-solo/environments" "${PREFIX}/${DOCKER_NAME}:${RELEASE}"
286 command_exit_status $? ${DOCKER_NAME}
287 echo "please wait while ${DOCKER_NAME^^} is starting....."
288 monitor_docker ${DOCKER_NAME}
295 DOCKER_NAME="dcae-fe"
296 echo "docker run ${DOCKER_NAME}..."
297 if [ ${LOCAL} == false ]; then
298 docker pull "${PREFIX}/${DOCKER_NAME}:${RELEASE}"
300 docker run ${DOCKER_RUN_MODE_FG} --name ${DOCKER_NAME} --env HOST_IP="${IP}" --env ENVNAME="${DEP_ENV}" --env JAVA_OPTIONS="${JAVA_OPTIONS}" --log-driver=json-file --log-opt max-size=100m --log-opt max-file=10 --ulimit memlock=-1:-1 --ulimit nofile=4096:100000 ${LOCAL_TIME_MOUNT_CMD} --volume "${WORKSPACE}/data/logs/DCAE-FE/:/var/lib/jetty/logs" --volume "${WORKSPACE}/data/environments:/root/chef-solo/environments" --publish 9444:9444 --publish 8183:8183 "${PREFIX}/${DOCKER_NAME}:${RELEASE}" /bin/sh
301 command_exit_status $? ${DOCKER_NAME}
302 echo "please wait while ${DOCKER_NAME^^} is starting....."
303 monitor_docker ${DOCKER_NAME}
309 DOCKER_NAME="dcae-dt"
310 echo "docker run ${DOCKER_NAME}..."
311 if [ ${LOCAL} == false ]; then
312 docker pull "${PREFIX}/${DOCKER_NAME}:${RELEASE}"
314 docker run ${DOCKER_RUN_MODE_FG} --name ${DOCKER_NAME} --env HOST_IP="${IP}" --env ENVNAME="${DEP_ENV}" --env JAVA_OPTIONS="${JAVA_OPTIONS}" --log-driver=json-file --log-opt max-size=100m --log-opt max-file=10 --ulimit memlock=-1:-1 --ulimit nofile=4096:100000 ${LOCAL_TIME_MOUNT_CMD} --volume "${WORKSPACE}/data/logs/DCAE-DT/:/var/lib/jetty/logs" --volume "${WORKSPACE}/data/environments:/root/chef-solo/environments/" --publish 9446:9446 --publish 8186:8186 "${PREFIX}/${DOCKER_NAME}:${RELEASE}" /bin/sh
315 command_exit_status $? ${DOCKER_NAME}
316 echo "please wait while ${DOCKER_NAME^^} is starting....."
317 monitor_docker ${DOCKER_NAME}
327 # Handle command line arguments
329 if [ $# -eq 0 ]; then
334 while [ $# -gt 0 ]; do
337 # -r | --release - The specific docker version to pull and deploy
343 # -e | --environment - The environment name you want to deploy
349 # -p | --port - The port from which to connect to the docker nexus
355 # -l | --local - Use this for deploying your local dockers without pulling them first
360 # -d | --docker - The init specified docker
366 # -h | --help - Display the help message with all the available run options
378 #Prefix those with WORKSPACE so it can be set to something other then /opt
379 [ -f "${WORKSPACE}/opt/config/env_name.txt" ] && DEP_ENV=$(cat "${WORKSPACE}/opt/config/env_name.txt") || echo "${DEP_ENV}"
380 [ -f "${WORKSPACE}/opt/config/nexus_username.txt" ] && NEXUS_USERNAME=$(cat "${WORKSPACE}/opt/config/nexus_username.txt") || NEXUS_USERNAME="release"
381 [ -f "${WORKSPACE}/opt/config/nexus_password.txt" ] && NEXUS_PASSWD=$(cat "${WORKSPACE}/opt/config/nexus_password.txt") || NEXUS_PASSWD="sfWU3DFVdBr7GVxB85mTYgAW"
382 [ -f "${WORKSPACE}/opt/config/nexus_docker_repo.txt" ] && NEXUS_DOCKER_REPO=$(cat "${WORKSPACE}/opt/config/nexus_docker_repo.txt") || NEXUS_DOCKER_REPO="nexus3.onap.org:${PORT}"
383 [ -f "${WORKSPACE}/opt/config/nexus_username.txt" ] && docker login -u ${NEXUS_USERNAME} -p ${NEXUS_PASSWD} ${NEXUS_DOCKER_REPO}
387 export IP=`ip route get 8.8.8.8 | awk '/src/{ print $7 }'`
388 #If OSX, then use this to get IP
389 if [[ "$OSTYPE" == "darwin"* ]]; then
390 export IP=$(ipconfig getifaddr en0)
392 export PREFIX=${NEXUS_DOCKER_REPO}'/onap'
394 if [ ${LOCAL} == true ]; then
400 if [ -z "${DOCKER}" ]; then