blob: 5e84871101312308f382328917924abf1bf2923f [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#
52TAGS="--tag onap/policy/${IMAGE}:latest"
53#
54# This has the nexus repo prepended and only major/minor version with latest
55#
56TAGS="${TAGS} --tag ${DOCKER_REPOSITORY}/onap/policy/${IMAGE}:${MVN_MAJMIN_VERSION}-latest"
57#
58# This has the nexus repo prepended and major/minor/patch version with timestamp
59#
60TAGS="${TAGS} --tag ${DOCKER_REPOSITORY}/onap/policy/${IMAGE}:${MVN_VERSION}-${TIMESTAMP}"
61
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