Merge "Improve security release notes"
[policy/engine.git] / docker_verify.sh
1 #!/bin/bash
2 #
3 #============LICENSE_START==================================================
4 #  ONAP Policy Engine
5 #===========================================================================
6 #  Copyright (C) 2017-2018 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 #============LICENSE_END==================================================
20 #
21
22 #
23 echo '============== STARTING SCRIPT TO BUILD DOCKER IMAGES ================='
24 #
25 # JUST VERIFY ONLY - NO PUSHING
26 #
27 DOCKER_REPOSITORY=nexus3.onap.org:10003
28 MVN_VERSION=$(cat packages/docker/target/version)
29 MVN_MAJMIN_VERSION=$(cut -f 1,2 -d . packages/docker/target/version)
30 TIMESTAMP=$(date -u +%Y%m%dT%H%M%S)
31 BUILD_ARGS="--build-arg BUILD_VERSION_ENGINE=${MVN_VERSION}"
32 IMAGE=policy-pe
33
34 if [ $HTTP_PROXY ]; then
35     BUILD_ARGS+=" --build-arg HTTP_PROXY=${HTTP_PROXY}"
36 fi
37 if [ $HTTPS_PROXY ]; then
38     BUILD_ARGS+=" --build-arg HTTPS_PROXY=${HTTPS_PROXY}"
39 fi
40
41 echo $DOCKER_REPOSITORY
42 echo $MVN_VERSION
43 echo $MVN_MAJMIN_VERSION
44 echo $TIMESTAMP
45
46 if [[ -z $MVN_VERSION ]]
47 then
48     echo "MVN_VERSION is empty"
49     exit 1
50 fi
51
52 if [[ -z $MVN_MAJMIN_VERSION ]]
53 then
54     echo "MVN_MAJMIN_VERSION is empty"
55     exit 1
56 fi
57
58 if [[ $MVN_VERSION == *"SNAPSHOT"* ]]
59 then
60     MVN_MAJMIN_VERSION="${MVN_MAJMIN_VERSION}-SNAPSHOT"
61 else
62     MVN_MAJMIN_VERSION="${MVN_MAJMIN_VERSION}-STAGING"
63 fi
64
65 echo $MVN_MAJMIN_VERSION
66
67 echo "Building $IMAGE"
68
69 docker login -u docker -p docker nexus3.onap.org:10001
70 docker pull nexus3.onap.org:10001/onap/policy-common-alpine:1.4.0
71 docker tag nexus3.onap.org:10001/onap/policy-common-alpine:1.4.0 onap/policy-common-alpine:1.4.0
72
73 #
74 # This is the local latest tagged image. The Dockerfile's need this to build images
75 #
76 TAGS="--tag onap/${IMAGE}:latest"
77 #
78 # This has the nexus repo prepended and only major/minor version with latest
79 #
80 TAGS="${TAGS} --tag ${DOCKER_REPOSITORY}/onap/${IMAGE}:${MVN_MAJMIN_VERSION}-latest"
81 #
82 # This has the nexus repo prepended and major/minor/patch version with timestamp
83 #
84 TAGS="${TAGS} --tag ${DOCKER_REPOSITORY}/onap/${IMAGE}:${MVN_VERSION}-${TIMESTAMP}Z"
85
86 echo $TAGS
87
88 docker build --quiet ${BUILD_ARGS} $TAGS packages/docker/target/$IMAGE
89
90 if [ $? -ne 0 ]
91 then
92     echo "Docker build failed"
93     docker images
94     exit 1
95 fi
96
97 docker images
98