Update oparent version
[music.git] / distribution / dockermusic / music.sh
1 #
2 # -------------------------------------------------------------------------
3 #   Copyright (c) 2017 AT&T Intellectual Property
4 #
5 #   Licensed under the Apache License, Version 2.0 (the "License");
6 #   you may not use this file except in compliance with the License.
7 #   You may obtain a copy of the License at
8 #
9 #       http://www.apache.org/licenses/LICENSE-2.0
10 #
11 #   Unless required by applicable law or agreed to in writing, software
12 #   distributed under the License is distributed on an "AS IS" BASIS,
13 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 #   See the License for the specific language governing permissions and
15 #   limitations under the License.
16 #
17 # -------------------------------------------------------------------------
18 # In this example we are building a docker bridge network(music-net) for all
19 # the containers
20 # Then we connect the host bridge network(bridge) to the internal network(music-net) 
21
22 #
23 #
24 SS=0
25 if [ -e /opt/config/nexus_docker_repo.txt ]
26 then
27     NEXUS_DOCKER_REPO=$(cat /opt/config/nexus_docker_repo.txt)
28 else
29     NEXUS_DOCKER_REPO=nexus3.onap.org:10001
30 fi
31 echo "Using ${NEXUS_DOCKER_REPO} for docker Repo"
32
33 CASS_IMG=${NEXUS_DOCKER_REPO}/onap/music/cassandra_music:latest
34 MUSIC_IMG=${NEXUS_DOCKER_REPO}/onap/music/music:latest
35 TOMCAT_IMG=library/tomcat:8.5
36 ZK_IMG=library/zookeeper:3.4
37 WORK_DIR=${PWD}
38 CASS_USERNAME=cassandra1
39 CASS_PASSWORD=cassandra1
40
41 if [ "$1" = "start" ]; then
42
43 # Create Volume for mapping war file and tomcat
44 docker volume create music-vol;
45
46 # Create a network for all the containers to run in.
47 docker network create music-net;
48
49 # Start Cassandra
50 docker run -d --rm --name music-db --network music-net \
51 -p "7000:7000" -p "7001:7001" -p "7199:7199" -p "9042:9042" -p "9160:9160" \
52 -e CASSUSER=${CASS_USERNAME} \
53 -e CASSPASS=${CASS_PASSWORD} \
54 ${CASS_IMG};
55
56 # Start Music war
57 docker run -d --rm --name music-war \
58 -v music-vol:/app \
59 ${MUSIC_IMG};
60
61 # Start Zookeeper
62 docker run -d --rm --name music-zk --network music-net \
63 -p "2181:2181" -p "2888:2888" -p "3888:3888" \
64 ${ZK_IMG};
65
66 # Delay for Cassandra
67 sleep 20;
68
69 # Start Up tomcat - Needs to have properties,logs dir and war file volume mapped.
70 docker run -d --rm --name music-tomcat --network music-net -p "8080:8080" \
71 -v music-vol:/usr/local/tomcat/webapps \
72 -v ${WORK_DIR}/properties:/opt/app/music/etc:ro \
73 -v ${WORK_DIR}/logs:/opt/app/music/logs \
74 ${TOMCAT_IMG};
75
76 # Connect tomcat to host bridge network so that its port can be seen. 
77 docker network connect bridge music-tomcat;
78 SS=1;
79 fi
80
81
82 # Shutdown and clean up. 
83 if [ "$1" = "stop" ]; then
84 docker stop music-war;
85 docker stop music-db;
86 docker stop music-zk;
87 docker stop music-tomcat;
88 docker network rm music-net;
89 sleep 5;
90 docker volume rm music-vol;
91 SS=1
92 fi
93
94 if [ $SS = 0 ]; then
95     echo "Please type ${0} start or ${0} stop"
96 fi
97
98
99
100
101