blob: 53fb06e823f1f55d4e94f92bb40f267d5b1816d1 [file] [log] [blame]
lj14120555df32017-02-20 03:25:58 +00001#!/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
14GROUP_ID='org.openecomp.dcae.controller'
15ARTIFACT_ID='dcae-controller-service-standardeventcollector-manager'
16VERSION='0.1.0-SNAPSHOT'
17FORMAT='zip'
18SCOPE='runtime'
19ARTIFACT_FQID="${GROUP_ID}:${ARTIFACT_ID}:${VERSION}:${FORMAT}:${SCOPE}"
20ARTIFACT_FILENAME="${ARTIFACT_ID}-${VERSION}-${SCOPE}.${FORMAT}"
21mvn -s "$SETTINGS_FILE" \
22 org.apache.maven.plugins:maven-dependency-plugin:2.10:copy \
23 -Dartifact="${ARTIFACT_FQID}" -DoutputDirectory=/tmp
24DCM_AR="/tmp/${ARTIFACT_FILENAME}"
25if [ ! -f "${DCM_AR}" ]
26then
27 echo "FATAL error cannot locate ${DCM_AR}"
28 exit 2
29fi
30
31# unarchive the service manager
32TARGET="${WORKSPACE}/target"
33STAGE="${TARGET}/stage"
34DCM_DIR="${STAGE}/opt/app/manager"
35[ ! -d "${DCM_DIR}" ] && mkdir -p "${DCM_DIR}"
36unzip -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
43cat <<EOF > "${DCM_DIR}/start-manager.sh"
44#!/bin/bash
45
46MAIN='org.openecomp.dcae.controller.service.standardeventcollector.servers.manager.DcaeControllerServiceStandardeventcollectorManagerServer'
47ACTION='start'
48
49WORKDIR='/opt/app/manager'
50LOGS="${WORKDIR}/logs"
51
52[ ! -d "$LOGS" ] && mkdir -p "$LOGS"
53
54echo 10.0.4.102 $(hostname).dcae.simpledemo.openecomp.org >> /etc/hosts
55
56exec java -cp ./config:./lib:./lib/*:./bin "${MAIN}" "${ACTION}" \
57 > logs/manager.out 2>logs/manager.err
58EOF
59
60chmod 775 "${DCM_DIR}/start-manager.sh"
61
62
63#
64# generate docker file
65#
66cat <<EOF > "${STAGE}/Dockerfile"
67FROM ubuntu:14.04
68
69MAINTAINER dcae@lists.openecomp.org
70
71WORKDIR /opt/app/manager
72
73ENV HOME /opt/app/SEC
74ENV JAVA_HOME /usr
75
76RUN apt-get update && apt-get install -y \
77 bc \
78 curl \
79 telnet \
80 vim \
81 netcat \
82 openjdk-7-jdk
83
84COPY opt /opt
85
86EXPOSE 9999
87
88CMD [ '/opt/app/manager/start-manager.sh' ]
89EOF
90
91#
92# build the docker image. tag and then push to the remote repo
93#
94IMAGE='dcae-controller-common-event'
95TAG='1.0.0'
96LFQI="${IMAGE}:${TAG}"
97BUILD_PATH="${WORKSPACE}/target/stage"
98
99# build a docker image
100docker 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"
109REPO='nexus3.openecomp.org:10003'
110
111if [ ! -z "$REPO" ]; then
112 RFQI="${REPO}/${LFQI}"
113 # tag
114 docker tag "${LFQI}" "${RFQI}"
115
116 # push to remote repo
117 docker push "${RFQI}"
118fi