Merge "Handle numRecords default setting when built as 0."
[policy/models.git] / models-sim / models-sim-dmaap / src / main / package / docker / docker_build.sh
1 #!/bin/bash
2 #
3 # ============LICENSE_START=======================================================
4 #  Copyright (C) 2019 Nordix Foundation.
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 #
18 # SPDX-License-Identifier: Apache-2.0
19 # ============LICENSE_END=========================================================
20 #
21
22 #
23 # Script to build a Docker file for the DMaaP simulator. The docker image
24 # generated by this script should NOT be placed in the ONAP nexus, it is
25 # only for testing purposes.
26 #
27
28 if [ -z "$DMAAP_SIM_HOME" ]
29 then
30         DMAAP_SIM_HOME=`pwd`
31 fi
32
33 # Check for the dockerfile
34 if [ ! -f "$DMAAP_SIM_HOME/src/main/package/docker/Dockerfile" ]
35 then
36         echo docker file "$DMAAP_SIM_HOME/src/main/package/docker/Dockerfile" not found
37         exit 1
38 fi
39
40 # Check for the start script
41 if [ ! -f "$DMAAP_SIM_HOME/src/main/package/docker/dmaap-sim.sh" ]
42 then
43         echo start script "$DMAAP_SIM_HOME/src/main/package/docker/dmaap-sim.sh" not found
44         exit 1
45 fi
46
47 # Check for the tarball
48 tarball_count=`ls $DMAAP_SIM_HOME/target/policy-models-sim-dmaap-*tarball.tar.gz 2> /dev/null | wc | awk '{print $1}'`
49 if [ "$tarball_count" -ne "1" ]
50 then
51         echo one and only one tarball should exist in the target directory
52         exit 2
53 fi
54
55 # Set up the docker build
56 rm -fr $DMAAP_SIM_HOME/target/docker
57 mkdir $DMAAP_SIM_HOME/target/docker
58 cp $DMAAP_SIM_HOME/src/main/package/docker/Dockerfile $DMAAP_SIM_HOME/target/docker
59 cp $DMAAP_SIM_HOME/src/main/package/docker/dmaap-sim.sh $DMAAP_SIM_HOME/target/docker
60 cp $DMAAP_SIM_HOME/target/policy-models-sim-dmaap-*tarball.tar.gz $DMAAP_SIM_HOME/target/docker/policy-models-sim-dmaap-tarball.tar.gz
61
62 # Run the docker build
63 cd $DMAAP_SIM_HOME/target
64 docker build -t dmaap/simulator docker
65
66