blob: a458873f08a343dd0bb1a3d3059befe0f3701572 [file] [log] [blame]
Pamela Dragoshb1743392017-02-21 12:04:28 -05001#!/bin/bash
2#
3echo '============== STARTING SCRIPT TO BUILD DOCKER IMAGES ================='
Pamela Dragoshceba3d82017-03-16 11:02:05 -04004#
5# JUST VERIFY ONLY - NO PUSHING
6#
Pamela Dragosh18882a02017-03-30 10:50:45 -04007DOCKER_REPOSITORY=nexus3.onap.org:10003
Pamela Dragosh3fe4d9c2017-03-07 15:39:48 -05008MVN_VERSION=$(cat target/version)
Pamela Dragoshe9f737a2017-03-23 07:44:56 -04009MVN_MAJMIN_VERSION=$(cut -f 1,2 -d . target/version)
Pamela Dragosh3fe4d9c2017-03-07 15:39:48 -050010TIMESTAMP=$(date -u +%Y%m%dT%H%M%S)
Shashank Kumar Shankar6e36eec2017-06-29 12:52:59 -070011PROXY_ARGS=""
mmis0d856912018-03-05 18:23:39 +000012IMAGE=policy-nexus
Shashank Kumar Shankar6e36eec2017-06-29 12:52:59 -070013
14if [ $HTTP_PROXY ]; then
15 PROXY_ARGS+="--build-arg HTTP_PROXY=${HTTP_PROXY}"
16fi
17if [ $HTTPS_PROXY ]; then
18 PROXY_ARGS+=" --build-arg HTTPS_PROXY=${HTTPS_PROXY}"
19fi
Pamela Dragoshb1743392017-02-21 12:04:28 -050020
Pamela Dragosh3fe4d9c2017-03-07 15:39:48 -050021echo $DOCKER_REPOSITORY
22echo $MVN_VERSION
Pamela Dragoshe9f737a2017-03-23 07:44:56 -040023echo $MVN_MAJMIN_VERSION
Pamela Dragosh3fe4d9c2017-03-07 15:39:48 -050024echo $TIMESTAMP
Pamela Dragosh6f91e0b2017-02-23 10:37:49 -050025
Pamela Dragoshe9f737a2017-03-23 07:44:56 -040026if [[ -z $MVN_VERSION ]]
27then
28 echo "MVN_VERSION is empty"
29 exit 1
30fi
31
32if [[ -z $MVN_MAJMIN_VERSION ]]
33then
34 echo "MVN_MAJMIN_VERSION is empty"
35 exit 1
36fi
37
38if [[ $MVN_VERSION == *"SNAPSHOT"* ]]
39then
40 MVN_MAJMIN_VERSION="${MVN_MAJMIN_VERSION}-SNAPSHOT"
41else
42 MVN_MAJMIN_VERSION="${MVN_MAJMIN_VERSION}-STAGING"
43fi
44
45echo $MVN_MAJMIN_VERSION
46
mmis0d856912018-03-05 18:23:39 +000047echo "Building $IMAGE"
48mkdir -p target/$IMAGE
49cp $IMAGE/* target/$IMAGE
Pamela Dragosh6f91e0b2017-02-23 10:37:49 -050050
mmis0d856912018-03-05 18:23:39 +000051#
52# This is the local latest tagged image. The Dockerfile's need this to build images
53#
mmis6dc5a242018-03-14 12:35:35 +000054TAGS="--tag onap/${IMAGE}:latest"
mmis0d856912018-03-05 18:23:39 +000055#
56# This has the nexus repo prepended and only major/minor version with latest
57#
mmis6dc5a242018-03-14 12:35:35 +000058TAGS="${TAGS} --tag ${DOCKER_REPOSITORY}/onap/${IMAGE}:${MVN_MAJMIN_VERSION}-latest"
mmis0d856912018-03-05 18:23:39 +000059#
60# This has the nexus repo prepended and major/minor/patch version with timestamp
61#
mmis6dc5a242018-03-14 12:35:35 +000062TAGS="${TAGS} --tag ${DOCKER_REPOSITORY}/onap/${IMAGE}:${MVN_VERSION}-${TIMESTAMP}"
Pamela Dragosh3fe4d9c2017-03-07 15:39:48 -050063
mmis0d856912018-03-05 18:23:39 +000064echo $TAGS
Pamela Dragosh3fe4d9c2017-03-07 15:39:48 -050065
mmis0d856912018-03-05 18:23:39 +000066docker build --quiet ${PROXY_ARGS} $TAGS target/$IMAGE
Pamela Dragosh3311eb72017-03-16 11:30:29 -040067
mmis0d856912018-03-05 18:23:39 +000068if [ $? -ne 0 ]
69then
70 echo "Docker build failed"
71 docker images
72 exit 1
73fi
Pamela Dragosh3311eb72017-03-16 11:30:29 -040074
75docker images
76