7 echo "usage: docker_run.sh [ -r|--release <RELEASE-NAME> ] [ -e|--environment <ENV-NAME> ] [ -p|--port <Docker-hub-port>] [ -h|--help ]"
11 function print_log () {
16 dd=`date +"%Y-%m-%d %H:%M:%S"`
19 COLOR="\033[1;32m" # GREEN
22 COLOR="\033[1;31m" # RED
25 echo -e "$dd: $fname, $funcname:$lineno --- ${COLOR} $msg\e[0m" |tee -a $LOG
31 function conf_proxy () {
32 grep http_proxy Dockerfile || /bin/sed -i '/FROM/a ARG http_proxy=http://one.proxy.att.com:8080\nARG https_proxy=http://one.proxy.att.com:8080' Dockerfile
35 ###################################
36 ######### Parameters #########
37 ###################################
40 WORK_DIR=/data/sdc-os-chef
41 LOGFILE=`basename $0|awk -F. '{print $1".log"}'`
42 LOG=$WORK_DIR/$LOGFILE
43 DOCKER_REP=dockercentral.it.att.com:5100
44 ECOMP_REP=${DOCKER_REP}/com.att.sdc/openecomp
45 REL=`/usr/bin/xml_grep --text_only parent/version /data/sdc-os-chef/pom.xml`
46 DOX_VER=` /bin/grep ONBOARDING /data/sdc-os-chef/versions.properties | awk '{print $2}' | awk -F"." '{print $1}'`
47 DOX_NUM=` /bin/grep ONBOARDING /data/sdc-os-chef/versions.properties | awk '{print $2}' | awk -F"." '{print substr($NF,1,4)}' `
48 VERSION=` /bin/grep ASDC /data/sdc-os-chef/versions.properties | awk '{print $2}' `
49 MAVEN_REPO=mavencentral.it.att.com:8084/nexus/content/repositories
50 ONBOARD_GR=com/att/asdc/onboarding/${DOX_VER}/${DOX_NUM}
53 [ -f /opt/config/env_name.txt ] && DEP_ENV=$(cat /opt/config/env_name.txt) || DEP_ENV=__ENV-NAME__
54 [ -f /opt/config/nexus_username.txt ] && NEXUS_USERNAME=$(cat /opt/config/nexus_username.txt) || NEXUS_USERNAME=release
55 [ -f /opt/config/nexus_password.txt ] && NEXUS_PASSWD=$(cat /opt/config/nexus_password.txt) || NEXUS_PASSWD=sfWU3DFVdBr7GVxB85mTYgAW
56 [ -f /opt/config/nexus_docker_repo.txt ] && NEXUS_DOCKER_REPO=$(cat /opt/config/nexus_docker_repo.txt) || NEXUS_DOCKER_REPO=ecomp-nexus:${PORT}
58 [ -f /opt/config/nexus_username.txt ] && docker login -u $NEXUS_USERNAME -p $NEXUS_PASSWD $NEXUS_DOCKER_REPO
59 #docker login -u m09875@sdc.att.com -p Aa1234%^! -e mg877n@att.com dockercentral.it.att.com:5100
62 ###################################
63 ######## MAIN ########
64 ###################################
65 print_log Main $LINENO INFO "##### $0 completed #####"
67 ###################################
68 ######## sdc-elasticsearch ########
69 ###################################
70 cd /data/sdc-os-chef/sdc-elasticsearch
71 print_log Main $LINENO INFO "start creating sdc-elasticsearch ..."
74 docker build -t ${ECOMP_REP}/sdc-elasticsearch:${VERSION} .
75 docker tag ${ECOMP_REP}/sdc-elasticsearch:${VERSION} ${ECOMP_REP}/sdc-elasticsearch
76 docker push ${ECOMP_REP}/sdc-elasticsearch:${VERSION}
78 if [ ${res} -eq 0 ]; then
79 print_log Main $LINENO INFO "${ECOMP_REP}/sdc-elasticsearch:${VERSION} pushed successfully"
81 print_log Main $LINENO ERROR "Error pushing ${ECOMP_REP}/sdc-elasticsearch:${VERSION}"
85 ###################################
86 ######## sdc-cassandra ########
87 ###################################
88 cd /data/sdc-os-chef/sdc-cassandra
89 print_log Main $LINENO INFO "start creating sdc-cassandra ..."
93 docker build -t ${ECOMP_REP}/sdc-cassandra:${VERSION} .
94 docker tag ${ECOMP_REP}/sdc-cassandra:$VERSION ${ECOMP_REP}/sdc-cassandra
95 docker push ${ECOMP_REP}/sdc-cassandra:$VERSION
97 if [ ${res} -eq 0 ]; then
98 print_log Main $LINENO INFO "${ECOMP_REP}/sdc-cassandra:${VERSION} pushed successfully"
100 print_log Main $LINENO ERROR "Error pushing ${ECOMP_REP}/sdc-cassandra:${VERSION}"
105 ###################################
106 ######## sdc-kibana ########
107 ###################################
108 cd /data/sdc-os-chef/sdc-kibana
109 print_log Main $LINENO INFO "start creating sdc-kibana ..."
113 docker build -t ${ECOMP_REP}/sdc-kibana:$VERSION .
114 docker tag ${ECOMP_REP}/sdc-kibana:$VERSION ${ECOMP_REP}/sdc-kibana
115 docker push ${ECOMP_REP}/sdc-kibana:$VERSION
117 if [ ${res} -eq 0 ]; then
118 print_log Main $LINENO INFO "${ECOMP_REP}/sdc-kibana:${VERSION} pushed successfully"
120 print_log Main $LINENO ERROR "Error pushing ${ECOMP_REP}/sdc-kibana:${VERSION}"
124 ###################################
125 ######## sdc-sanity ########
126 ###################################
127 cd /data/sdc-os-chef/sdc-sanity
128 print_log Main $LINENO INFO "start creating sdc-sanity ..."
132 docker build -t ${ECOMP_REP}/sdc-sanity:$VERSION .
133 docker tag ${ECOMP_REP}/sdc-sanity:$VERSION ${ECOMP_REP}/sdc-sanity
134 docker push ${ECOMP_REP}/sdc-sanity:$VERSION
136 if [ ${res} -eq 0 ]; then
137 print_log Main $LINENO INFO "${ECOMP_REP}/sdc-sanity:${VERSION} pushed successfully"
139 print_log Main $LINENO ERROR "Error pushing ${ECOMP_REP}/sdc-sanity:${VERSION}"
143 ###################################
144 ######## sdc-backend ########
145 ###################################
146 cd /data/sdc-os-chef/sdc-backend
147 print_log Main $LINENO INFO "start creating sdc-backend ..."
150 /bin/sed -i "s/__SDC-RELEASE__/${REL}/g" Dockerfile
152 wget -q -nd -r --no-parent -A 'onboard-main*.tar' http://${MAVEN_REPO}/att-repository-snapshots/${ONBOARD_GR}/onboard-main
153 if [ $? -ne 0 ] ; then
154 wget -q -nd -r --no-parent -A 'onboard-main*.tar' http://${MAVEN_REPO}/att-repository-releases/${ONBOARD_GR}/onboard-main
156 /bin/tar -xf onboard-main-${DOX_VER}.*.tar --wildcards --no-anchored "onboarding-be-${DOX_VER}.*.war"
159 docker build -t ${ECOMP_REP}/sdc-backend:$VERSION .
160 docker tag ${ECOMP_REP}/sdc-backend:$VERSION ${ECOMP_REP}/sdc-backend
161 docker push ${ECOMP_REP}/sdc-backend:$VERSION
163 if [ ${res} -eq 0 ]; then
164 print_log Main $LINENO INFO "${ECOMP_REP}/sdc-backend:${VERSION} pushed successfully"
166 print_log Main $LINENO ERROR "Error pushing ${ECOMP_REP}/sdc-backend:${VERSION}"
170 ###################################
171 ######## sdc-frontend ########
172 ###################################
173 cd /data/sdc-os-chef/sdc-frontend
174 print_log Main $LINENO INFO "start creating sdc-frontend ..."
178 /bin/sed -i "s/__SDC-RELEASE__/${REL}/g" Dockerfile
179 wget -q -nd -r --no-parent -A 'onboard-main*.tar' http://${MAVEN_REPO}/att-repository-snapshots/${ONBOARD_GR}/onboard-main
180 if [ $? -ne 0 ] ; then
181 wget -q -nd -r --no-parent -A 'onboard-main*.tar' http://${MAVEN_REPO}/att-repository-releases/${ONBOARD_GR}/onboard-main
183 /bin/tar -xf onboard-main-${DOX_VER}.*.tar --wildcards --no-anchored "onboarding-fe-${DOX_VER}.*.war"
186 docker build -t ${ECOMP_REP}/sdc-frontend:$VERSION .
187 docker tag ${ECOMP_REP}/sdc-frontend:$VERSION ${ECOMP_REP}/sdc-frontend
188 docker push ${ECOMP_REP}/sdc-frontend:$VERSION
190 if [ ${res} -eq 0 ]; then
191 print_log Main $LINENO INFO "${ECOMP_REP}/sdc-frontend:${VERSION} pushed successfully"
193 print_log Main $LINENO ERROR "Error pushing ${ECOMP_REP}/sdc-frontend:${VERSION}"
196 print_log Main $LINENO INFO "##### $0 completed #####"