must be executable
[ci-management.git] / jjb / dcae / script-collectors-ves-daily-release.sh
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 DCM_AR="${WORKSPACE}/manager.zip"
15 if [ ! -f "${DCM_AR}" ]
16 then
17     echo "FATAL error cannot locate ${DCM_AR}"
18     exit 2
19 fi
20
21 # unarchive the service manager
22 TARGET="${WORKSPACE}/target"
23 STAGE="${TARGET}/stage"
24 DCM_DIR="${STAGE}/opt/app/manager"
25 [ ! -d "${DCM_DIR}" ] && mkdir -p "${DCM_DIR}"
26 unzip -qo -d "${DCM_DIR}" "${DCM_AR}"
27
28 #
29 # generate the manager start-up.sh
30 #
31 [ -f "${DCM_DIR}/start-manager.sh" ] && exit 0
32
33 cat <<EOF > "${DCM_DIR}/start-manager.sh"
34 #!/bin/bash
35
36 MAIN='org.openecomp.dcae.controller.service.standardeventcollector.servers.manager.DcaeControllerServiceStandardeventcollectorManagerServer'
37 ACTION='start'
38
39 WORKDIR='/opt/app/manager'
40 LOGS="${WORKDIR}/logs"
41
42 [ ! -d "$LOGS" ] && mkdir -p "$LOGS"
43
44 echo 10.0.4.102 $(hostname).dcae.simpledemo.openecomp.org >> /etc/hosts
45
46 exec java -cp ./config:./lib:./lib/*:./bin "${MAIN}" "${ACTION}" \
47     > logs/manager.out 2>logs/manager.err
48 EOF
49
50 chmod 775 "${DCM_DIR}/start-manager.sh"
51
52
53 #
54 # generate docker file
55 #
56 cat <<EOF > "${STAGE}/Dockerfile"
57 FROM ubuntu:14.04
58
59 MAINTAINER dcae@lists.openecomp.org
60
61 WORKDIR /opt/app/manager
62
63 ENV HOME /opt/app/SEC
64 ENV JAVA_HOME /usr
65
66 RUN apt-get update && apt-get install -y \
67         bc \
68         curl \
69         telnet \
70         vim \
71         netcat \
72         openjdk-7-jdk
73
74 COPY opt /opt
75
76 EXPOSE 9999
77
78 CMD [ '/opt/app/manager/start-manager.sh' ]
79 EOF
80
81 #
82 # build the docker image. tag and then push to the remote repo
83 #
84 IMAGE='dcae-controller-common-event'
85 TAG='1.0.0'
86 LFQI="${IMAGE}:${TAG}"
87 BUILD_PATH="${WORKSPACE}/target/stage"
88
89 # build a docker image
90 docker build --rm -t "${LFQI}" "${BUILD_PATH}"
91
92
93 #
94 # push the image
95 #
96 # io registry  DOCKER_REPOSITORIES="nexus3.openecomp.org:10001 \
97 # release registry                   nexus3.openecomp.org:10002 \
98 # snapshot registry                   nexus3.openecomp.org:10003"
99 REPO='nexus3.openecomp.org:10003'
100
101 if [ ! -z "$REPO" ]; then
102     RFQI="${REPO}/${LFQI}"
103     # tag
104     docker tag "${LFQI}" "${RFQI}"
105
106     # push to remote repo
107     docker push "${RFQI}"
108 fi