db33cefd0a436a5853c9076672b628445175db95
[policy/models.git] / models-sim / policy-models-sim-pdp / 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 # Script to build a Docker file for the PDP simulator. The docker image
23 # generated by this script should NOT be placed in the ONAP nexus, it is
24 # only for testing purposes.
25 #
26
27 if [ -z "$PDP_SIM_HOME" ]
28 then
29         PDP_SIM_HOME=`pwd`
30 fi
31
32 # Check for the dockerfile
33 if [ ! -f "$PDP_SIM_HOME/src/main/package/docker/Dockerfile" ]
34 then
35         echo docker file "$PDP_SIM_HOME/src/main/package/docker/Dockerfile" not found
36         exit 1
37 fi
38
39 # Check for the start script
40 if [ ! -f "$PDP_SIM_HOME/src/main/package/docker/pdp-sim.sh" ]
41 then
42         echo start script "$PDP_SIM_HOME/src/main/package/docker/pdp-sim.sh" not found
43         exit 1
44 fi
45
46 # Check for the tarball
47 tarball_count=`ls $PDP_SIM_HOME/target/policy-models-sim-pdp-*tarball.tar.gz 2> /dev/null | wc | awk '{print $1}'`
48 if [ "$tarball_count" -ne "1" ]
49 then
50         echo one and only one tarball should exist in the target directory
51         exit 2
52 fi
53
54 # Set up the docker build
55 rm -fr $PDP_SIM_HOME/target/docker
56 mkdir $PDP_SIM_HOME/target/docker
57 cp $PDP_SIM_HOME/src/main/package/docker/Dockerfile $PDP_SIM_HOME/target/docker
58 cp $PDP_SIM_HOME/src/main/package/docker/pdp-sim.sh $PDP_SIM_HOME/target/docker
59 cp $PDP_SIM_HOME/target/policy-models-sim-pdp-*tarball.tar.gz $PDP_SIM_HOME/target/docker/policy-models-sim-pdp-tarball.tar.gz
60
61 # Run the docker build
62 cd $PDP_SIM_HOME/target
63 docker build -t pdp/simulator docker
64
65