aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarsten Lund <lund@research.att.com>2017-02-21 20:40:34 +0000
committerCarsten Lund <lund@research.att.com>2017-02-21 21:40:33 +0000
commitcc0805ae97200c365c6d6c3357593cd3873a092e (patch)
treecc80abb4a9a78d9d4d090a9b7f0cc6a145cb76f1
parentc6a6cad7b1aa9856c92b385bdcb6581e8d1a4677 (diff)
Added docker-build.sh script
Change-Id: I5384fb4279d5f9e7cdda4fc0f29ab736255ea502 Signed-off-by: Carsten Lund <lund@research.att.com>
-rwxr-xr-xdocker-build.sh132
1 files changed, 132 insertions, 0 deletions
diff --git a/docker-build.sh b/docker-build.sh
new file mode 100755
index 0000000..ad11375
--- /dev/null
+++ b/docker-build.sh
@@ -0,0 +1,132 @@
+#!/bin/bash
+#
+#
+# 1 build the docker image with both service manager and ves collector
+# 2 tag and then push to the remote repo if not verify
+#
+
+
+phase=$1
+
+case $phase in
+ verify|merge|release)
+ echo Running $phase job
+ ;;
+ *)
+ echo Unknown phase \'$phase\'
+ exit 1
+esac
+
+
+# DCAE Controller service manager for VES collector
+DCM_AR="${WORKSPACE}/manager.zip"
+if [ ! -f "${DCM_AR}" ]
+then
+ echo "FATAL error cannot locate ${DCM_AR}"
+ exit 2
+fi
+
+# unarchive the service manager
+TARGET="${WORKSPACE}/target"
+STAGE="${TARGET}/stage"
+DCM_DIR="${STAGE}/opt/app/manager"
+[ ! -d "${DCM_DIR}" ] && mkdir -p "${DCM_DIR}"
+unzip -qo -d "${DCM_DIR}" "${DCM_AR}"
+
+# unarchive the collector
+AR=${WORKSPACE}/target/OpenVESCollector-1.0.0-bundle.tar.gz
+APP_DIR=${STAGE}/opt/app/SEC
+
+[ -d ${STAGE}/opt/app/OpenVESCollector-1.0.0 ] && rm -rf ${STAGE}/opt/app/OpenVESCollector-1.0.0
+
+[ ! -f $APP_DIR ] && mkdir -p ${APP_DIR}
+
+gunzip -c ${AR} | tar xvf - -C ${APP_DIR} --strip-components=1
+
+#
+# generate the manager start-up.sh
+#
+## [ -f "${DCM_DIR}/start-manager.sh" ] && exit 0
+
+cat <<EOF > "${DCM_DIR}/start-manager.sh"
+#!/bin/bash
+
+MAIN='org.openecomp.dcae.controller.service.standardeventcollector.servers.manager.DcaeControllerServiceStandardeventcollectorManagerServer'
+ACTION='start'
+
+WORKDIR='/opt/app/manager'
+LOGS="${WORKDIR}/logs"
+
+[ ! -d "$LOGS" ] && mkdir -p "$LOGS"
+
+echo 10.0.4.102 $(hostname).dcae.simpledemo.openecomp.org >> /etc/hosts
+
+exec java -cp ./config:./lib:./lib/*:./bin "${MAIN}" "${ACTION}" \
+ > logs/manager.out 2>logs/manager.err
+EOF
+
+chmod 775 "${DCM_DIR}/start-manager.sh"
+
+
+#
+# generate docker file
+#
+cat <<EOF > "${STAGE}/Dockerfile"
+FROM ubuntu:14.04
+
+MAINTAINER dcae@lists.openecomp.org
+
+WORKDIR /opt/app/manager
+
+ENV HOME /opt/app/SEC
+ENV JAVA_HOME /usr
+
+RUN apt-get update && apt-get install -y \
+ bc \
+ curl \
+ telnet \
+ vim \
+ netcat \
+ openjdk-7-jdk
+
+COPY opt /opt
+
+EXPOSE 9999
+
+CMD [ '/opt/app/manager/start-manager.sh' ]
+EOF
+
+#
+# build the docker image. tag and then push to the remote repo
+#
+IMAGE='dcae-controller-common-event'
+TAG='1.0.0'
+LFQI="${IMAGE}:${TAG}"
+BUILD_PATH="${WORKSPACE}/target/stage"
+
+# build a docker image
+echo docker build --rm -t "${LFQI}" "${BUILD_PATH}"
+docker build --rm -t "${LFQI}" "${BUILD_PATH}"
+
+case $phase in
+ verify)
+ exit 0
+ ;;
+esac
+
+#
+# push the image
+#
+# io registry DOCKER_REPOSITORIES="nexus3.openecomp.org:10001 \
+# release registry nexus3.openecomp.org:10002 \
+# snapshot registry nexus3.openecomp.org:10003"
+REPO='nexus3.openecomp.org:10003'
+
+if [ ! -z "$REPO" ]; then
+ RFQI="${REPO}/${LFQI}"
+ # tag
+ docker tag "${LFQI}" "${RFQI}"
+
+ # push to remote repo
+ docker push "${RFQI}"
+fi