blob: 03c922ee7700666085fc99ae63e59dd8ab77a1a1 [file] [log] [blame]
Michael Landoed64b5e2017-06-09 03:19:04 +03001#!/bin/bash
2#set -x
3
4
5function usage
6{
7 echo "usage: docker_run.sh [ -r|--release <RELEASE-NAME> ] [ -e|--environment <ENV-NAME> ] [ -p|--port <Docker-hub-port>] [ -h|--help ]"
8}
9
10
11function print_log () {
12 funcname=$1
13 lineno=$2
14 sev=$3
15 msg=$4
16 dd=`date +"%Y-%m-%d %H:%M:%S"`
17 case ${sev} in
18 "INFO")
19 COLOR="\033[1;32m" # GREEN
20 ;;
21 "ERROR")
22 COLOR="\033[1;31m" # RED
23 ;;
24 esac
25 echo -e "$dd: $fname, $funcname:$lineno --- ${COLOR} $msg\e[0m" |tee -a $LOG
26
27}
28
29
30
31function 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
33}
34
35###################################
36######### Parameters #########
37###################################
38
39WORKSPACE=$1
40WORK_DIR=/data/sdc-os-chef
41LOGFILE=`basename $0|awk -F. '{print $1".log"}'`
42LOG=$WORK_DIR/$LOGFILE
43DOCKER_REP=dockercentral.it.att.com:5100
44ECOMP_REP=${DOCKER_REP}/com.att.sdc/openecomp
45REL=`/usr/bin/xml_grep --text_only parent/version /data/sdc-os-chef/pom.xml`
46DOX_VER=` /bin/grep AMDOCS /data/sdc-os-chef/versions.properties | awk '{print $2}' | awk -F"." '{print $1}'`
47DOX_NUM=` /bin/grep AMDOCS /data/sdc-os-chef/versions.properties | awk '{print $2}' | awk -F"." '{print substr($NF,1,4)}' `
48VERSION=` /bin/grep ASDC /data/sdc-os-chef/versions.properties | awk '{print $2}' `
49MAVEN_REPO=mavencentral.it.att.com:8084/nexus/content/repositories
50ONBOARD_GR=com/att/asdc/onboarding/${DOX_VER}/${DOX_NUM}
51
52
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}
57
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
60
61
62###################################
63######## MAIN ########
64###################################
65print_log Main $LINENO INFO "##### $0 completed #####"
66
67###################################
68######## sdc-elasticsearch ########
69###################################
70cd /data/sdc-os-chef/sdc-elasticsearch
71print_log Main $LINENO INFO "start creating sdc-elasticsearch ..."
72conf_proxy
73
74docker build -t ${ECOMP_REP}/sdc-elasticsearch:${VERSION} .
75docker tag ${ECOMP_REP}/sdc-elasticsearch:${VERSION} ${ECOMP_REP}/sdc-elasticsearch
76docker push ${ECOMP_REP}/sdc-elasticsearch:${VERSION}
77res=$?
78if [ ${res} -eq 0 ]; then
79 print_log Main $LINENO INFO "${ECOMP_REP}/sdc-elasticsearch:${VERSION} pushed successfully"
80else
81 print_log Main $LINENO ERROR "Error pushing ${ECOMP_REP}/sdc-elasticsearch:${VERSION}"
82fi
83
84
85###################################
86######## sdc-cassandra ########
87###################################
88cd /data/sdc-os-chef/sdc-cassandra
89print_log Main $LINENO INFO "start creating sdc-cassandra ..."
90
91conf_proxy
92
93docker build -t ${ECOMP_REP}/sdc-cassandra:${VERSION} .
94docker tag ${ECOMP_REP}/sdc-cassandra:$VERSION ${ECOMP_REP}/sdc-cassandra
95docker push ${ECOMP_REP}/sdc-cassandra:$VERSION
96res=$?
97if [ ${res} -eq 0 ]; then
98 print_log Main $LINENO INFO "${ECOMP_REP}/sdc-cassandra:${VERSION} pushed successfully"
99else
100 print_log Main $LINENO ERROR "Error pushing ${ECOMP_REP}/sdc-cassandra:${VERSION}"
101fi
102
103
104
105###################################
106######## sdc-kibana ########
107###################################
108cd /data/sdc-os-chef/sdc-kibana
109print_log Main $LINENO INFO "start creating sdc-kibana ..."
110
111conf_proxy
112
113docker build -t ${ECOMP_REP}/sdc-kibana:$VERSION .
114docker tag ${ECOMP_REP}/sdc-kibana:$VERSION ${ECOMP_REP}/sdc-kibana
115docker push ${ECOMP_REP}/sdc-kibana:$VERSION
116res=$?
117if [ ${res} -eq 0 ]; then
118 print_log Main $LINENO INFO "${ECOMP_REP}/sdc-kibana:${VERSION} pushed successfully"
119else
120 print_log Main $LINENO ERROR "Error pushing ${ECOMP_REP}/sdc-kibana:${VERSION}"
121fi
122
123
124###################################
125######## sdc-sanity ########
126###################################
127cd /data/sdc-os-chef/sdc-sanity
128print_log Main $LINENO INFO "start creating sdc-sanity ..."
129
130conf_proxy
131
132docker build -t ${ECOMP_REP}/sdc-sanity:$VERSION .
133docker tag ${ECOMP_REP}/sdc-sanity:$VERSION ${ECOMP_REP}/sdc-sanity
134docker push ${ECOMP_REP}/sdc-sanity:$VERSION
135res=$?
136if [ ${res} -eq 0 ]; then
137 print_log Main $LINENO INFO "${ECOMP_REP}/sdc-sanity:${VERSION} pushed successfully"
138else
139 print_log Main $LINENO ERROR "Error pushing ${ECOMP_REP}/sdc-sanity:${VERSION}"
140fi
141
142
143###################################
144######## sdc-backend ########
145###################################
146cd /data/sdc-os-chef/sdc-backend
147print_log Main $LINENO INFO "start creating sdc-backend ..."
148
149conf_proxy
150/bin/sed -i "s/__SDC-RELEASE__/${REL}/g" Dockerfile
151
152wget -q -nd -r --no-parent -A 'onboard-main*.tar' http://${MAVEN_REPO}/att-repository-snapshots/${ONBOARD_GR}/onboard-main
153if [ $? -ne 0 ] ; then
154 wget -q -nd -r --no-parent -A 'onboard-main*.tar' http://${MAVEN_REPO}/att-repository-releases/${ONBOARD_GR}/onboard-main
155fi
156/bin/tar -xf onboard-main-${DOX_VER}.*.tar --wildcards --no-anchored "onboarding-be-${DOX_VER}.*.war"
157rm onboard-main*.tar
158
159docker build -t ${ECOMP_REP}/sdc-backend:$VERSION .
160docker tag ${ECOMP_REP}/sdc-backend:$VERSION ${ECOMP_REP}/sdc-backend
161docker push ${ECOMP_REP}/sdc-backend:$VERSION
162res=$?
163if [ ${res} -eq 0 ]; then
164 print_log Main $LINENO INFO "${ECOMP_REP}/sdc-backend:${VERSION} pushed successfully"
165else
166 print_log Main $LINENO ERROR "Error pushing ${ECOMP_REP}/sdc-backend:${VERSION}"
167fi
168
169
170###################################
171######## sdc-frontend ########
172###################################
173cd /data/sdc-os-chef/sdc-frontend
174print_log Main $LINENO INFO "start creating sdc-frontend ..."
175
176conf_proxy
177
178/bin/sed -i "s/__SDC-RELEASE__/${REL}/g" Dockerfile
179wget -q -nd -r --no-parent -A 'onboard-main*.tar' http://${MAVEN_REPO}/att-repository-snapshots/${ONBOARD_GR}/onboard-main
180if [ $? -ne 0 ] ; then
181 wget -q -nd -r --no-parent -A 'onboard-main*.tar' http://${MAVEN_REPO}/att-repository-releases/${ONBOARD_GR}/onboard-main
182fi
183/bin/tar -xf onboard-main-${DOX_VER}.*.tar --wildcards --no-anchored "onboarding-fe-${DOX_VER}.*.war"
184rm onboard-main*.tar
185
186docker build -t ${ECOMP_REP}/sdc-frontend:$VERSION .
187docker tag ${ECOMP_REP}/sdc-frontend:$VERSION ${ECOMP_REP}/sdc-frontend
188docker push ${ECOMP_REP}/sdc-frontend:$VERSION
189res=$?
190if [ ${res} -eq 0 ]; then
191 print_log Main $LINENO INFO "${ECOMP_REP}/sdc-frontend:${VERSION} pushed successfully"
192else
193 print_log Main $LINENO ERROR "Error pushing ${ECOMP_REP}/sdc-frontend:${VERSION}"
194fi
195
196print_log Main $LINENO INFO "##### $0 completed #####"