blob: b5acdd87033f090eac700002256a4446672f50ea [file] [log] [blame]
mmis13368732018-03-01 16:50:11 +00001#!/bin/bash
2#
3echo '============== STARTING SCRIPT TO BUILD DOCKER IMAGES ================='
4#
5# JUST VERIFY ONLY - NO PUSHING
6#
7DOCKER_REPOSITORY=nexus3.onap.org:10003
8MVN_VERSION=$(cat packages/docker/target/version)
9MVN_MAJMIN_VERSION=$(cut -f 1,2 -d . packages/docker/target/version)
10TIMESTAMP=$(date -u +%Y%m%dT%H%M%S)
11PROXY_ARGS=""
12IMAGE=policy-pe
13
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
20
21echo $DOCKER_REPOSITORY
22echo $MVN_VERSION
23echo $MVN_MAJMIN_VERSION
24echo $TIMESTAMP
25
26if [[ -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
47echo "Building $IMAGE"
mmis13368732018-03-01 16:50:11 +000048
49#
50# This is the local latest tagged image. The Dockerfile's need this to build images
51#
mmis4ea66782018-03-14 12:03:37 +000052TAGS="--tag onap/${IMAGE}:latest"
mmis13368732018-03-01 16:50:11 +000053#
54# This has the nexus repo prepended and only major/minor version with latest
55#
mmis4ea66782018-03-14 12:03:37 +000056TAGS="${TAGS} --tag ${DOCKER_REPOSITORY}/onap/${IMAGE}:${MVN_MAJMIN_VERSION}-latest"
mmis13368732018-03-01 16:50:11 +000057#
58# This has the nexus repo prepended and major/minor/patch version with timestamp
59#
mmisd7eac782018-03-29 09:37:45 +010060TAGS="${TAGS} --tag ${DOCKER_REPOSITORY}/onap/${IMAGE}:${MVN_VERSION}-${TIMESTAMP}Z"
mmis13368732018-03-01 16:50:11 +000061
62echo $TAGS
63
64docker build --quiet ${PROXY_ARGS} $TAGS packages/docker/target/$IMAGE
65
66if [ $? -ne 0 ]
67then
68 echo "Docker build failed"
69 docker images
70 exit 1
71fi
72
73docker images
74