blob: cc3cb0d62e5e3af31c12bb884165c4c7eac80b1d [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=""
12
13if [ $HTTP_PROXY ]; then
14 PROXY_ARGS+="--build-arg HTTP_PROXY=${HTTP_PROXY}"
15fi
16if [ $HTTPS_PROXY ]; then
17 PROXY_ARGS+=" --build-arg HTTPS_PROXY=${HTTPS_PROXY}"
18fi
Pamela Dragoshb1743392017-02-21 12:04:28 -050019
Pamela Dragosh3fe4d9c2017-03-07 15:39:48 -050020echo $DOCKER_REPOSITORY
21echo $MVN_VERSION
Pamela Dragoshe9f737a2017-03-23 07:44:56 -040022echo $MVN_MAJMIN_VERSION
Pamela Dragosh3fe4d9c2017-03-07 15:39:48 -050023echo $TIMESTAMP
Pamela Dragosh6f91e0b2017-02-23 10:37:49 -050024
Pamela Dragoshe9f737a2017-03-23 07:44:56 -040025if [[ -z $MVN_VERSION ]]
26then
27 echo "MVN_VERSION is empty"
28 exit 1
29fi
30
31if [[ -z $MVN_MAJMIN_VERSION ]]
32then
33 echo "MVN_MAJMIN_VERSION is empty"
34 exit 1
35fi
36
37if [[ $MVN_VERSION == *"SNAPSHOT"* ]]
38then
39 MVN_MAJMIN_VERSION="${MVN_MAJMIN_VERSION}-SNAPSHOT"
40else
41 MVN_MAJMIN_VERSION="${MVN_MAJMIN_VERSION}-STAGING"
42fi
43
44echo $MVN_MAJMIN_VERSION
45
Pamela Dragosh6f91e0b2017-02-23 10:37:49 -050046cp policy-pe/* target/policy-pe/
47cp policy-drools/* target/policy-drools/
48
Jorge Hernandezbd14de82018-02-27 11:41:54 -060049for image in policy-os policy-nexus policy-base policy-drools policy-pe ; do
Pamela Dragosh6f91e0b2017-02-23 10:37:49 -050050 echo "Building $image"
51 mkdir -p target/$image
52 cp $image/* target/$image
Pamela Dragosh3fe4d9c2017-03-07 15:39:48 -050053
Pamela Dragoshe9f737a2017-03-23 07:44:56 -040054 #
55 # This is the local latest tagged image. The Dockerfile's need this to build images
56 #
Pamela Dragosh18882a02017-03-30 10:50:45 -040057 TAGS="--tag onap/policy/${image}:latest"
Pamela Dragoshe9f737a2017-03-23 07:44:56 -040058 #
59 # This has the nexus repo prepended and only major/minor version with latest
60 #
Pamela Dragosh18882a02017-03-30 10:50:45 -040061 TAGS="${TAGS} --tag ${DOCKER_REPOSITORY}/onap/policy/${image}:${MVN_MAJMIN_VERSION}-latest"
Pamela Dragoshe9f737a2017-03-23 07:44:56 -040062 #
63 # This has the nexus repo prepended and major/minor/patch version with timestamp
64 #
Pamela Dragosh18882a02017-03-30 10:50:45 -040065 TAGS="${TAGS} --tag ${DOCKER_REPOSITORY}/onap/policy/${image}:${MVN_VERSION}-${TIMESTAMP}"
Pamela Dragosh3fe4d9c2017-03-07 15:39:48 -050066
67 echo $TAGS
Pamela Dragosh3311eb72017-03-16 11:30:29 -040068
Shashank Kumar Shankar6e36eec2017-06-29 12:52:59 -070069 docker build --quiet ${PROXY_ARGS} $TAGS target/$image
Pamela Dragosh9bd4bf62017-03-30 12:46:08 -040070
71 if [ $? -ne 0 ]
72 then
73 echo "Docker build failed"
74 docker images
75 exit 1
76 fi
Pamela Dragosh6f91e0b2017-02-23 10:37:49 -050077done
Pamela Dragosh3311eb72017-03-16 11:30:29 -040078
79docker images
80