7 WORKSPACE="${WORKSPACE:-}"
18 DCAE_BE_JAVA_OPTIONS="-XX:MaxPermSize=256m -Xmx1024m -Dconfig.home=config -Dlog.home=/var/lib/jetty/logs/ -Dlogging.config=config/dcae-be/logback-spring.xml"
19 DCAE_FE_JAVA_OPTIONS="-XX:MaxPermSize=256m -Xmx1024m -Dconfig.home=config -Dlog.home=/var/lib/jetty/logs/ -Dlogging.config=config/dcae-fe/logback-spring.xml"
20 DCAE_DT_JAVA_OPTIONS="-XX:MaxPermSize=256m -Xmx1024m -Dconfig.home=config -Dlog.home=/var/lib/jetty/logs/ -Dlogging.config=config/dcae-dt/logback-spring.xml"
21 DCAE_TOSCA_JAVA_OPTIONS="-XX:MaxPermSize=256m -Xmx1024m"
24 #Define this as variable, so it can be excluded in run commands on Docker for OSX, as /etc/localtime cant be mounted there.
25 LOCAL_TIME_MOUNT_CMD="--volume /etc/localtime:/etc/localtime:ro"
27 # If os is OSX, unset this, so /etc/localtime is not mounted, otherwise leave it be
28 if [[ "$OSTYPE" == "darwin"* ]]; then
29 LOCAL_TIME_MOUNT_CMD=""
33 DOCKER_RUN_MODE_BG="--detach"
34 DOCKER_RUN_MODE_FG="-dti"
42 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 ]"
43 echo "example: sudo bash dcae_docker_run.sh -e AUTO -r 1.2-STAGING-latest"
49 echo "Performing old dockers cleanup"
51 if [ "$1" == "all" ] ; then
52 docker_ids=$(docker ps -a | egrep "dcae" | awk '{print $1}')
53 for X in ${docker_ids}
58 echo "performing $1 docker cleanup"
59 tmp=$(docker ps -a -q --filter="name=$1")
60 if [[ -n "$tmp" ]]; then
69 mkdir -p "${WORKSPACE}/data/logs/DCAE-BE/DCAE"
70 mkdir -p "${WORKSPACE}/data/logs/DCAE-FE/DCAE"
71 mkdir -p "${WORKSPACE}/data/logs/DCAE-DT/DCAE"
72 mkdir -p "${WORKSPACE}/data/logs/DCAE-TOSCA/DCAE"
74 chmod -R 777 "${WORKSPACE}/data/logs"
79 function docker_logs {
80 docker logs "$1" > "${WORKSPACE}/data/logs/docker_logs/$1_docker.log"
89 function ready_probe {
90 docker exec "$1" /var/lib/ready-probe.sh > /dev/null 2>&1
92 if [[ ${rc} == 0 ]]; then
93 echo "DOCKER $1 start finished in $2 seconds"
101 function probe_docker {
102 MATCH=$(docker logs --tail 30 "$1" | grep "DOCKER STARTED")
103 echo MATCH is -- "${MATCH}"
105 if [ -n "$MATCH" ] ; then
106 echo "DOCKER start finished in $2 seconds"
113 function probe_dcae_tosca {
114 health_check_http_code=$(curl --noproxy "*" -i -o /dev/null -w '%{http_code}' "http://${IP}:8085/healthcheck")
115 if [[ "${health_check_http_code}" -eq 200 ]] ; then
116 echo "DOCKER start finished in $1 seconds"
123 function probe_dcae_be {
124 health_check_http_code=$(curl --noproxy "*" -i -o /dev/null -w '%{http_code}' "http://${IP}:8082/dcae/conf/composition")
125 if [[ "${health_check_http_code}" -eq 200 ]] ; then
126 echo "DOCKER start finished in $1 seconds"
133 function probe_dcae_fe {
134 health_check_http_code=$(curl --noproxy "*" -i -o /dev/null -w '%{http_code}' "http://${IP}:8183/dcaed/healthCheck")
135 if [[ "${health_check_http_code}" -eq 200 ]] ; then
136 echo "DOCKER start finished in $1 seconds"
143 function probe_dcae_dt {
144 health_check_http_code=$(curl --noproxy "*" -i -o /dev/null -w '%{http_code}' "http://${IP}:8186/dcae/healthCheckOld")
145 if [[ "${health_check_http_code}" -eq 200 ]] ; then
146 echo "DOCKER start finished in $1 seconds"
153 # Not applicable for current release. Return Success in any case
154 function probe_dcae_tools {
155 health_check_http_code=$(curl --noproxy "*" -i -o /dev/null -w '%{http_code}' "http://${IP}:8082/dcae/getResourcesByMonitoringTemplateCategory")
156 if [[ "${health_check_http_code}" -eq 200 ]] ; then
157 echo "DOCKER start finished in $1 seconds"
165 function monitor_docker {
167 echo "Monitor ${DOCKER_NAME} Docker"
173 while [ "$TIME" -lt "$TIME_OUT" ]; do
175 case ${DOCKER_NAME} in
178 probe_dcae_tosca ${TIME} ;
182 probe_dcae_be ${TIME} ;
186 probe_dcae_fe ${TIME} ;
190 probe_dcae_dt ${TIME} ;
198 probe_docker "${DOCKER_NAME}" ${TIME};
204 if [ ${status} == ${SUCCESS} ] ; then
208 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"
210 TIME=$(($TIME+$INTERVAL))
213 docker_logs "${DOCKER_NAME}"
215 if [ "$TIME" -ge "$TIME_OUT" ]; then
216 echo -e "\e[1;31mTIME OUT: DOCKER was NOT fully started in $TIME_OUT seconds... Could cause problems ...\e[0m"
222 function healthCheck {
224 echo "BE health-Check:"
225 curl --noproxy "*" "http://${IP}:8080/sdc2/rest/healthCheck"
229 echo "FE health-Check:"
230 curl --noproxy "*" "http://${IP}:8181/sdc1/rest/healthCheck"
235 function command_exit_status {
238 if [ "${status}" != "0" ] ; then
239 echo "[ ERROR ] Docker ${docker} run command exit with status [${status}]"
251 function dcae-tosca {
252 DOCKER_NAME="dcae-tosca-app"
253 echo "docker run ${DOCKER_NAME}..."
254 if [ ${LOCAL} == false ]; then
255 docker pull "${PREFIX}/${DOCKER_NAME}:${RELEASE}"
257 docker run ${DOCKER_RUN_MODE_FG} --name ${DOCKER_NAME} --env HOST_IP="${IP}" --env ENVNAME="${DEP_ENV}" --env JAVA_OPTIONS="${DCAE_TOSCA_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}"
258 command_exit_status $? ${DOCKER_NAME}
259 echo "please wait while ${DOCKER_NAME^^} is starting....."
260 monitor_docker ${DOCKER_NAME}
267 DOCKER_NAME="dcae-be"
268 echo "docker run ${DOCKER_NAME}..."
269 if [ ${LOCAL} == false ]; then
270 docker pull "${PREFIX}/${DOCKER_NAME}:${RELEASE}"
272 docker run ${DOCKER_RUN_MODE_FG} --name ${DOCKER_NAME} --env HOST_IP="${IP}" --env ENVNAME="${DEP_ENV}" --env JAVA_OPTIONS="${DCAE_BE_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:/var/opt/dcae-be/chef-solo/environments" --publish 8444:8444 --publish 8082:8082 "${PREFIX}/${DOCKER_NAME}:${RELEASE}" /bin/sh
273 command_exit_status $? ${DOCKER_NAME}
274 echo "please wait while ${DOCKER_NAME^^} is starting....."
275 monitor_docker ${DOCKER_NAME}
281 function dcae-tools {
282 DOCKER_NAME="dcae-tools"
283 echo "docker run ${DOCKER_NAME}..."
284 if [ ${LOCAL} == false ]; then
285 docker pull "${PREFIX}/${DOCKER_NAME}:${RELEASE}"
287 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}"
288 command_exit_status $? ${DOCKER_NAME}
289 echo "please wait while ${DOCKER_NAME^^} is starting....."
290 monitor_docker ${DOCKER_NAME}
297 DOCKER_NAME="dcae-fe"
298 echo "docker run ${DOCKER_NAME}..."
299 if [ ${LOCAL} == false ]; then
300 docker pull "${PREFIX}/${DOCKER_NAME}:${RELEASE}"
302 docker run ${DOCKER_RUN_MODE_FG} --name ${DOCKER_NAME} --env HOST_IP="${IP}" --env ENVNAME="${DEP_ENV}" --env JAVA_OPTIONS="${DCAE_FE_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:/var/opt/dcae-fe/chef-solo/environments/" --publish 9444:9444 --publish 8183:8183 "${PREFIX}/${DOCKER_NAME}:${RELEASE}" /bin/sh
303 command_exit_status $? ${DOCKER_NAME}
304 echo "please wait while ${DOCKER_NAME^^} is starting....."
305 monitor_docker ${DOCKER_NAME}
311 DOCKER_NAME="dcae-dt"
312 echo "docker run ${DOCKER_NAME}..."
313 if [ ${LOCAL} == false ]; then
314 docker pull "${PREFIX}/${DOCKER_NAME}:${RELEASE}"
316 docker run ${DOCKER_RUN_MODE_FG} --name ${DOCKER_NAME} --env HOST_IP="${IP}" --env ENVNAME="${DEP_ENV}" --env JAVA_OPTIONS="${DCAE_DT_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:/var/opt/dcae-dt/chef-solo/environments/" --publish 9446:9446 --publish 8186:8186 "${PREFIX}/${DOCKER_NAME}:${RELEASE}" /bin/sh
317 command_exit_status $? ${DOCKER_NAME}
318 echo "please wait while ${DOCKER_NAME^^} is starting....."
319 monitor_docker ${DOCKER_NAME}
329 # Handle command line arguments
331 if [ $# -eq 0 ]; then
336 while [ $# -gt 0 ]; do
339 # -r | --release - The specific docker version to pull and deploy
345 # -e | --environment - The environment name you want to deploy
351 # -p | --port - The port from which to connect to the docker nexus
357 # -l | --local - Use this for deploying your local dockers without pulling them first
362 # -d | --docker - The init specified docker
368 # -h | --help - Display the help message with all the available run options
380 #Prefix those with WORKSPACE so it can be set to something other then /opt
381 [ -f "${WORKSPACE}/opt/config/env_name.txt" ] && DEP_ENV=$(cat "${WORKSPACE}/opt/config/env_name.txt") || echo "${DEP_ENV}"
382 [ -f "${WORKSPACE}/opt/config/nexus_username.txt" ] && NEXUS_USERNAME=$(cat "${WORKSPACE}/opt/config/nexus_username.txt") || NEXUS_USERNAME="release"
383 [ -f "${WORKSPACE}/opt/config/nexus_password.txt" ] && NEXUS_PASSWD=$(cat "${WORKSPACE}/opt/config/nexus_password.txt") || NEXUS_PASSWD="sfWU3DFVdBr7GVxB85mTYgAW"
384 [ -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}"
385 [ -f "${WORKSPACE}/opt/config/nexus_username.txt" ] && docker login -u ${NEXUS_USERNAME} -p ${NEXUS_PASSWD} ${NEXUS_DOCKER_REPO}
389 export IP=`ip route get 8.8.8.8 | awk '/src/{ print $7 }'`
390 #If OSX, then use this to get IP
391 if [[ "$OSTYPE" == "darwin"* ]]; then
392 export IP=$(ipconfig getifaddr en0)
394 export PREFIX=${NEXUS_DOCKER_REPO}'/onap'
396 if [ ${LOCAL} == true ]; then
402 if [ -z "${DOCKER}" ]; then