blob: 99043f62ede3c36a03621d9857186e37c12dee13 [file] [log] [blame]
mmis824a75e2018-03-02 18:04:48 +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-drools
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"
mmis824a75e2018-03-02 18:04:48 +000048
49#
50# This is the local latest tagged image. The Dockerfile's need this to build images
51#
mmisac6780a2018-03-14 12:10:52 +000052TAGS="--tag onap/${IMAGE}:latest"
mmis824a75e2018-03-02 18:04:48 +000053#
54# This has the nexus repo prepended and only major/minor version with latest
55#
mmisac6780a2018-03-14 12:10:52 +000056TAGS="${TAGS} --tag ${DOCKER_REPOSITORY}/onap/${IMAGE}:${MVN_MAJMIN_VERSION}-latest"
mmis824a75e2018-03-02 18:04:48 +000057#
58# This has the nexus repo prepended and major/minor/patch version with timestamp
59#
mmisac6780a2018-03-14 12:10:52 +000060TAGS="${TAGS} --tag ${DOCKER_REPOSITORY}/onap/${IMAGE}:${MVN_VERSION}-${TIMESTAMP}"
mmis824a75e2018-03-02 18:04:48 +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
75