Merge "Rename actor from MSO 2 SO in vDNS policy creation"
[policy/docker.git] / docker_verify.sh
1 #!/bin/bash
2 #
3 echo '============== STARTING SCRIPT TO BUILD DOCKER IMAGES ================='
4 #
5 # JUST VERIFY ONLY - NO PUSHING
6 #
7 DOCKER_REPOSITORY=nexus3.onap.org:10003
8 MVN_VERSION=$(cat target/version)
9 MVN_MAJMIN_VERSION=$(cut -f 1,2 -d . target/version)
10 TIMESTAMP=$(date -u +%Y%m%dT%H%M%S)
11 PROXY_ARGS=""
12
13 if [ $HTTP_PROXY ]; then
14     PROXY_ARGS+="--build-arg HTTP_PROXY=${HTTP_PROXY}"
15 fi
16 if [ $HTTPS_PROXY ]; then
17     PROXY_ARGS+=" --build-arg HTTPS_PROXY=${HTTPS_PROXY}"
18 fi
19
20 echo $DOCKER_REPOSITORY
21 echo $MVN_VERSION
22 echo $MVN_MAJMIN_VERSION
23 echo $TIMESTAMP
24
25 if [[ -z $MVN_VERSION ]]
26 then
27     echo "MVN_VERSION is empty"
28     exit 1
29 fi
30
31 if [[ -z $MVN_MAJMIN_VERSION ]]
32 then
33     echo "MVN_MAJMIN_VERSION is empty"
34     exit 1
35 fi
36
37 if [[ $MVN_VERSION == *"SNAPSHOT"* ]]
38 then
39     MVN_MAJMIN_VERSION="${MVN_MAJMIN_VERSION}-SNAPSHOT"
40 else
41     MVN_MAJMIN_VERSION="${MVN_MAJMIN_VERSION}-STAGING"
42 fi
43
44 echo $MVN_MAJMIN_VERSION
45
46 cp policy-pe/* target/policy-pe/
47 cp policy-drools/* target/policy-drools/
48
49 for image in policy-os policy-nexus policy-db policy-base policy-drools policy-pe ; do
50     echo "Building $image"
51     mkdir -p target/$image
52     cp $image/* target/$image
53
54     #
55     # This is the local latest tagged image. The Dockerfile's need this to build images
56     #
57     TAGS="--tag onap/policy/${image}:latest"
58     #
59     # This has the nexus repo prepended and only major/minor version with latest
60     #
61     TAGS="${TAGS} --tag ${DOCKER_REPOSITORY}/onap/policy/${image}:${MVN_MAJMIN_VERSION}-latest"
62     #
63     # This has the nexus repo prepended and major/minor/patch version with timestamp
64     #
65     TAGS="${TAGS} --tag ${DOCKER_REPOSITORY}/onap/policy/${image}:${MVN_VERSION}-${TIMESTAMP}"
66
67     echo $TAGS
68
69     docker build --quiet ${PROXY_ARGS} $TAGS target/$image
70
71     if [ $? -ne 0 ]
72     then
73         echo "Docker build failed"
74         docker images
75         exit 1
76     fi
77 done
78
79 docker images
80