2 # -------------------------------------------------------------------------
3 # Copyright (c) 2017 AT&T Intellectual Property
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
9 # http://www.apache.org/licenses/LICENSE-2.0
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.
17 # -------------------------------------------------------------------------
18 # In this example we are building a docker bridge network(music-net) for all
20 # Then we connect the host bridge network(bridge) to the internal network(music-net)
25 if [ -e /opt/config/nexus_docker_repo.txt ]
27 NEXUS_DOCKER_REPO=$(cat /opt/config/nexus_docker_repo.txt)
29 NEXUS_DOCKER_REPO=nexus3.onap.org:10001
31 echo "Using ${NEXUS_DOCKER_REPO} for docker Repo"
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
38 CASS_USERNAME=cassandra1
39 CASS_PASSWORD=cassandra1
41 if [ "$1" = "start" ]; then
43 # Create Volume for mapping war file and tomcat
44 docker volume create music-vol;
46 # Create a network for all the containers to run in.
47 docker network create music-net;
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} \
57 docker run -d --rm --name music-war \
62 docker run -d --rm --name music-zk --network music-net \
63 -p "2181:2181" -p "2888:2888" -p "3888:3888" \
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 \
76 # Connect tomcat to host bridge network so that its port can be seen.
77 docker network connect bridge music-tomcat;
82 # Shutdown and clean up.
83 if [ "$1" = "stop" ]; then
84 docker stop music-war;
87 docker stop music-tomcat;
88 docker network rm music-net;
90 docker volume rm music-vol;
95 echo "Please type ${0} start or ${0} stop"