Add docker file for all simulators
[policy/models.git] / models-sim / policy-models-simulators / src / main / package / docker / docker_build.sh
1 #!/bin/bash
2 #
3 # ============LICENSE_START=======================================================
4 # ONAP
5 # ================================================================================
6 # Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
7 # ================================================================================
8 # Licensed under the Apache License, Version 2.0 (the "License");
9 # you may not use this file except in compliance with the License.
10 # You may obtain a copy of the License at
11 #
12 #      http://www.apache.org/licenses/LICENSE-2.0
13 #
14 # Unless required by applicable law or agreed to in writing, software
15 # distributed under the License is distributed on an "AS IS" BASIS,
16 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 # See the License for the specific language governing permissions and
18 # limitations under the License.
19 #
20 # SPDX-License-Identifier: Apache-2.0
21 # ============LICENSE_END=========================================================
22 #
23
24 #
25 # Script to build a Docker file for the simulators. The docker image
26 # generated by this script should NOT be placed in the ONAP nexus, it is
27 # only for testing purposes.
28 #
29
30 if [ -z "$SIMULATOR_HOME" ]
31 then
32     SIMULATOR_HOME=$PWD
33 fi
34
35 # Check for the dockerfile
36 if [ ! -f "$SIMULATOR_HOME/src/main/package/docker/Dockerfile" ]
37 then
38     echo docker file "$SIMULATOR_HOME/src/main/package/docker/Dockerfile" not found
39     exit 1
40 fi
41
42 # Check for the start script
43 if [ ! -f "$SIMULATOR_HOME/src/main/package/docker/simulators.sh" ]
44 then
45     echo start script "$SIMULATOR_HOME/src/main/package/docker/simulators.sh" not found
46     exit 1
47 fi
48
49 # Check for the tarball
50 tarball_count=`ls $SIMULATOR_HOME/target/policy-models-simulators-*tarball.tar.gz 2> /dev/null | wc | awk '{print $1}'`
51 if [ "$tarball_count" -ne "1" ]
52 then
53     echo one and only one tarball should exist in the target directory
54     exit 2
55 fi
56
57 # Set up the docker build
58 rm -fr $SIMULATOR_HOME/target/docker
59 mkdir $SIMULATOR_HOME/target/docker
60 cp $SIMULATOR_HOME/src/main/package/docker/Dockerfile $SIMULATOR_HOME/target/docker
61 cp $SIMULATOR_HOME/src/main/package/docker/simulators.sh $SIMULATOR_HOME/target/docker
62 cp $SIMULATOR_HOME/target/policy-models-simulators-*tarball.tar.gz \
63     $SIMULATOR_HOME/target/docker/policy-models-simulators-tarball.tar.gz
64
65 # Run the docker build
66 cd $SIMULATOR_HOME/target
67 docker build -t policy/simulators docker