lj1412 | 0555df3 | 2017-02-20 03:25:58 +0000 | [diff] [blame^] | 1 | #!/bin/bash |
| 2 | # |
| 3 | # |
| 4 | # 1 fetch DCAE Controller service manager |
| 5 | # 2 build the docker imagei with both service manager and ves collector |
| 6 | # 3 tag and then push to the remote repo |
| 7 | # |
| 8 | # |
| 9 | # !!! make sure the yaml jjb file includes docker-login as a builder |
| 10 | # before calling this script |
| 11 | |
| 12 | |
| 13 | # downloading DCAE Controller service manager for VES collector |
| 14 | GROUP_ID='org.openecomp.dcae.controller' |
| 15 | ARTIFACT_ID='dcae-controller-service-standardeventcollector-manager' |
| 16 | VERSION='0.1.0-SNAPSHOT' |
| 17 | FORMAT='zip' |
| 18 | SCOPE='runtime' |
| 19 | ARTIFACT_FQID="${GROUP_ID}:${ARTIFACT_ID}:${VERSION}:${FORMAT}:${SCOPE}" |
| 20 | ARTIFACT_FILENAME="${ARTIFACT_ID}-${VERSION}-${SCOPE}.${FORMAT}" |
| 21 | mvn -s "$SETTINGS_FILE" \ |
| 22 | org.apache.maven.plugins:maven-dependency-plugin:2.10:copy \ |
| 23 | -Dartifact="${ARTIFACT_FQID}" -DoutputDirectory=/tmp |
| 24 | DCM_AR="/tmp/${ARTIFACT_FILENAME}" |
| 25 | if [ ! -f "${DCM_AR}" ] |
| 26 | then |
| 27 | echo "FATAL error cannot locate ${DCM_AR}" |
| 28 | exit 2 |
| 29 | fi |
| 30 | |
| 31 | # unarchive the service manager |
| 32 | TARGET="${WORKSPACE}/target" |
| 33 | STAGE="${TARGET}/stage" |
| 34 | DCM_DIR="${STAGE}/opt/app/manager" |
| 35 | [ ! -d "${DCM_DIR}" ] && mkdir -p "${DCM_DIR}" |
| 36 | unzip -qo -d "${DCM_DIR}" "${DCM_AR}" |
| 37 | |
| 38 | # |
| 39 | # generate the manager start-up.sh |
| 40 | # |
| 41 | [ -f "${DCM_DIR}/start-manager.sh" ] && exit 0 |
| 42 | |
| 43 | cat <<EOF > "${DCM_DIR}/start-manager.sh" |
| 44 | #!/bin/bash |
| 45 | |
| 46 | MAIN='org.openecomp.dcae.controller.service.standardeventcollector.servers.manager.DcaeControllerServiceStandardeventcollectorManagerServer' |
| 47 | ACTION='start' |
| 48 | |
| 49 | WORKDIR='/opt/app/manager' |
| 50 | LOGS="${WORKDIR}/logs" |
| 51 | |
| 52 | [ ! -d "$LOGS" ] && mkdir -p "$LOGS" |
| 53 | |
| 54 | echo 10.0.4.102 $(hostname).dcae.simpledemo.openecomp.org >> /etc/hosts |
| 55 | |
| 56 | exec java -cp ./config:./lib:./lib/*:./bin "${MAIN}" "${ACTION}" \ |
| 57 | > logs/manager.out 2>logs/manager.err |
| 58 | EOF |
| 59 | |
| 60 | chmod 775 "${DCM_DIR}/start-manager.sh" |
| 61 | |
| 62 | |
| 63 | # |
| 64 | # generate docker file |
| 65 | # |
| 66 | cat <<EOF > "${STAGE}/Dockerfile" |
| 67 | FROM ubuntu:14.04 |
| 68 | |
| 69 | MAINTAINER dcae@lists.openecomp.org |
| 70 | |
| 71 | WORKDIR /opt/app/manager |
| 72 | |
| 73 | ENV HOME /opt/app/SEC |
| 74 | ENV JAVA_HOME /usr |
| 75 | |
| 76 | RUN apt-get update && apt-get install -y \ |
| 77 | bc \ |
| 78 | curl \ |
| 79 | telnet \ |
| 80 | vim \ |
| 81 | netcat \ |
| 82 | openjdk-7-jdk |
| 83 | |
| 84 | COPY opt /opt |
| 85 | |
| 86 | EXPOSE 9999 |
| 87 | |
| 88 | CMD [ '/opt/app/manager/start-manager.sh' ] |
| 89 | EOF |
| 90 | |
| 91 | # |
| 92 | # build the docker image. tag and then push to the remote repo |
| 93 | # |
| 94 | IMAGE='dcae-controller-common-event' |
| 95 | TAG='1.0.0' |
| 96 | LFQI="${IMAGE}:${TAG}" |
| 97 | BUILD_PATH="${WORKSPACE}/target/stage" |
| 98 | |
| 99 | # build a docker image |
| 100 | docker build --rm -t "${LFQI}" "${BUILD_PATH}" |
| 101 | |
| 102 | |
| 103 | # |
| 104 | # push the image |
| 105 | # |
| 106 | # io registry DOCKER_REPOSITORIES="nexus3.openecomp.org:10001 \ |
| 107 | # release registry nexus3.openecomp.org:10002 \ |
| 108 | # snapshot registry nexus3.openecomp.org:10003" |
| 109 | REPO='nexus3.openecomp.org:10003' |
| 110 | |
| 111 | if [ ! -z "$REPO" ]; then |
| 112 | RFQI="${REPO}/${LFQI}" |
| 113 | # tag |
| 114 | docker tag "${LFQI}" "${RFQI}" |
| 115 | |
| 116 | # push to remote repo |
| 117 | docker push "${RFQI}" |
| 118 | fi |