Use connection pooling for locking
[policy/drools-pdp.git] / docker_merge.sh
1 #!/bin/bash
2 # Copyright 2018 AT&T Intellectual Property. All rights reserved
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 #         http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15
16 #
17 echo '============== STARTING SCRIPT TO BUILD DOCKER IMAGES ================='
18 DOCKER_REPOSITORY=nexus3.onap.org:10003
19 MVN_VERSION=$(cat packages/docker/target/version)
20 MVN_MAJMIN_VERSION=$(cut -f 1,2 -d . packages/docker/target/version)
21 TIMESTAMP=$(date -u +%Y%m%dT%H%M%S)
22 BUILD_ARGS="--build-arg BUILD_VERSION=${MVN_VERSION}"
23 IMAGE=policy-drools
24
25 if [ $HTTP_PROXY ]; then
26     BUILD_ARGS+=" --build-arg HTTP_PROXY=${HTTP_PROXY}"
27 fi
28 if [ $HTTPS_PROXY ]; then
29     BUILD_ARGS+=" --build-arg HTTPS_PROXY=${HTTPS_PROXY}"
30 fi
31
32 echo $DOCKER_REPOSITORY
33 echo $MVN_VERSION
34 echo $MVN_MAJMIN_VERSION
35 echo $TIMESTAMP
36
37 if [[ -z $MVN_VERSION ]]
38 then
39     echo "MVN_VERSION is empty"
40     exit 1
41 fi
42
43 if [[ -z $MVN_MAJMIN_VERSION ]]
44 then
45     echo "MVN_MAJMIN_VERSION is empty"
46     exit 1
47 fi
48
49 if [[ $MVN_VERSION == *"SNAPSHOT"* ]]
50 then
51     MVN_MAJMIN_VERSION="${MVN_MAJMIN_VERSION}-SNAPSHOT"
52 else
53     MVN_MAJMIN_VERSION="${MVN_MAJMIN_VERSION}-STAGING"
54 fi
55
56 echo $MVN_MAJMIN_VERSION
57
58 echo "Building $IMAGE"
59
60 #
61 # This is the local latest tagged image. The Dockerfile's need this to build images
62 #
63 TAGS="--tag onap/${IMAGE}:latest"
64 #
65 # This has the nexus repo prepended and only major/minor version with latest
66 #
67 TAGS="${TAGS} --tag ${DOCKER_REPOSITORY}/onap/${IMAGE}:${MVN_MAJMIN_VERSION}-latest"
68 #
69 # This has the nexus repo prepended and major/minor/patch version with timestamp
70 #
71 TAGS="${TAGS} --tag ${DOCKER_REPOSITORY}/onap/${IMAGE}:${MVN_VERSION}-${TIMESTAMP}Z"
72
73 echo $TAGS
74
75 docker build --quiet ${BUILD_ARGS} $TAGS packages/docker/target/$IMAGE
76
77 if [ $? -ne 0 ]
78 then
79     echo "Docker build failed"
80     docker images
81     exit 1
82 fi
83
84 docker images
85
86 #
87 # Push image
88 #
89 echo "Pushing $IMAGE"
90 docker push ${DOCKER_REPOSITORY}/onap/$IMAGE:${MVN_MAJMIN_VERSION}-latest
91
92 if [ $? -ne 0 ]
93 then
94     echo "Docker push failed"
95     exit 1
96 fi
97
98 docker push ${DOCKER_REPOSITORY}/onap/$IMAGE:${MVN_VERSION}-${TIMESTAMP}Z
99
100 if [ $? -ne 0 ]
101 then
102     echo "Docker push failed"
103     exit 1
104 fi
105