blob: 11e2fefd2a6c06da839319926cbdb84b75ab1941 [file] [log] [blame]
mmis13368732018-03-01 16:50:11 +00001#!/bin/bash
2#
Jim Hahndaee9222018-04-19 11:28:41 -04003#============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#
mmis13368732018-03-01 16:50:11 +000023echo '============== STARTING SCRIPT TO BUILD DOCKER IMAGES ================='
24#
25# JUST VERIFY ONLY - NO PUSHING
26#
27DOCKER_REPOSITORY=nexus3.onap.org:10003
28MVN_VERSION=$(cat packages/docker/target/version)
29MVN_MAJMIN_VERSION=$(cut -f 1,2 -d . packages/docker/target/version)
30TIMESTAMP=$(date -u +%Y%m%dT%H%M%S)
Jorge Hernandez973929c2018-05-07 18:22:12 -050031BUILD_ARGS="--build-arg BUILD_VERSION=${MVN_VERSION}"
mmis13368732018-03-01 16:50:11 +000032IMAGE=policy-pe
33
34if [ $HTTP_PROXY ]; then
Jorge Hernandez973929c2018-05-07 18:22:12 -050035 BUILD_ARGS+=" --build-arg HTTP_PROXY=${HTTP_PROXY}"
mmis13368732018-03-01 16:50:11 +000036fi
37if [ $HTTPS_PROXY ]; then
Jorge Hernandez973929c2018-05-07 18:22:12 -050038 BUILD_ARGS+=" --build-arg HTTPS_PROXY=${HTTPS_PROXY}"
mmis13368732018-03-01 16:50:11 +000039fi
40
41echo $DOCKER_REPOSITORY
42echo $MVN_VERSION
43echo $MVN_MAJMIN_VERSION
44echo $TIMESTAMP
45
46if [[ -z $MVN_VERSION ]]
47then
48 echo "MVN_VERSION is empty"
49 exit 1
50fi
51
52if [[ -z $MVN_MAJMIN_VERSION ]]
53then
54 echo "MVN_MAJMIN_VERSION is empty"
55 exit 1
56fi
57
58if [[ $MVN_VERSION == *"SNAPSHOT"* ]]
59then
60 MVN_MAJMIN_VERSION="${MVN_MAJMIN_VERSION}-SNAPSHOT"
61else
62 MVN_MAJMIN_VERSION="${MVN_MAJMIN_VERSION}-STAGING"
63fi
64
65echo $MVN_MAJMIN_VERSION
66
67echo "Building $IMAGE"
mmis13368732018-03-01 16:50:11 +000068
69#
70# This is the local latest tagged image. The Dockerfile's need this to build images
71#
mmis4ea66782018-03-14 12:03:37 +000072TAGS="--tag onap/${IMAGE}:latest"
mmis13368732018-03-01 16:50:11 +000073#
74# This has the nexus repo prepended and only major/minor version with latest
75#
mmis4ea66782018-03-14 12:03:37 +000076TAGS="${TAGS} --tag ${DOCKER_REPOSITORY}/onap/${IMAGE}:${MVN_MAJMIN_VERSION}-latest"
mmis13368732018-03-01 16:50:11 +000077#
78# This has the nexus repo prepended and major/minor/patch version with timestamp
79#
mmisd7eac782018-03-29 09:37:45 +010080TAGS="${TAGS} --tag ${DOCKER_REPOSITORY}/onap/${IMAGE}:${MVN_VERSION}-${TIMESTAMP}Z"
mmis13368732018-03-01 16:50:11 +000081
82echo $TAGS
83
Jorge Hernandez973929c2018-05-07 18:22:12 -050084docker build --quiet ${BUILD_ARGS} $TAGS packages/docker/target/$IMAGE
mmis13368732018-03-01 16:50:11 +000085
86if [ $? -ne 0 ]
87then
88 echo "Docker build failed"
89 docker images
90 exit 1
91fi
92
93docker images
94