blob: 0f77a61e7e1d1aa303f1e766c1232b141e62123c [file] [log] [blame]
mmisef24b052018-07-10 10:50:05 +01001#!/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/apex-pdp-docker/target/version)
9MVN_MAJMIN_VERSION=$(cut -f 1,2 -d . packages/apex-pdp-docker/target/version)
10TIMESTAMP=$(date -u +%Y%m%dT%H%M%S)
11PROXY_ARGS=""
12IMAGE=policy-apex-pdp
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"
48
49#
50# This is the local latest tagged image. The Dockerfile's need this to build images
51#
52TAGS="--tag onap/${IMAGE}:latest"
53#
54# This has the nexus repo prepended and only major/minor version with latest
55#
56TAGS="${TAGS} --tag ${DOCKER_REPOSITORY}/onap/${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/${IMAGE}:${MVN_VERSION}-${TIMESTAMP}Z"
61
62echo $TAGS
63
64docker build ${PROXY_ARGS} $TAGS packages/apex-pdp-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