Update version number in container-tag for F Maintenance Release
[sim/a1-interface.git] / near-rt-ric-simulator / test / KAFKA_DISPATCHER_TEST / build_and_start.sh
1 #!/bin/bash
2
3 #  ============LICENSE_START===============================================
4 #  Copyright (C) 2022 Nordix Foundation. All rights reserved.
5 #  ========================================================================
6 #  Licensed under the Apache License, Version 2.0 (the "License");
7 #  you may not use this file except in compliance with the License.
8 #  You may obtain a copy of the License at
9 #
10 #       http://www.apache.org/licenses/LICENSE-2.0
11 #
12 #  Unless required by applicable law or agreed to in writing, software
13 #  distributed under the License is distributed on an "AS IS" BASIS,
14 #  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 #  See the License for the specific language governing permissions and
16 #  limitations under the License.
17 #  ============LICENSE_END=================================================
18 #
19
20 # Script to build and start the kafka dispatcher container
21 # Make sure to run the simulator including args as is this script
22
23 print_usage() {
24     echo "Usage: ./build_and_start.sh publish-resp|ignore-publish"
25     exit 1
26 }
27
28 if [ $# -ne 1 ]; then
29     print_usage
30 fi
31
32 if [ $1 == "publish-resp" ]; then
33     PUBLISH_RESP="-e PUBLISH_RESP=1"
34 elif  [ $1 == "ignore-publish" ]; then
35     PUBLISH_RESP=""
36 else
37     print_usage
38 fi
39
40 echo "Building Kafka message dispatcher image..."
41 cd ../KAFKA_DISPATCHER/
42
43 #Build the image
44 docker build -t kafka_dispatcher .
45
46 docker stop kafkamessagedispatcher > /dev/null 2>&1
47 docker rm -f kafkamessagedispatcher > /dev/null 2>&1
48
49 echo "Starting Kafka message dispatcher..."
50 echo "PWD path: "$PWD
51
52 #Run the container in interactive mode with host networking driver which allows docker to access localhost, unsecure port 7075, secure port 7175, TIME_OUT must be in seconds, PUBLISH_RESP decides auto responding for testing that run by A1 sim
53 docker run --network host --rm -it -p 7075:7075 -p 7175:7175 -e ALLOW_HTTP=true -e MSG_BROKER_URL=localhost:9092 -e TIME_OUT=30 $PUBLISH_RESP --volume "$PWD/certificate:/usr/src/app/cert" --name kafkamessagedispatcher kafka_dispatcher