blob: 17cf553e54ef05a0a02625b98c02879b16cd670d [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"
48mkdir -p packages/docker/target/$IMAGE
49cp packages/docker/src/main/docker/* packages/docker/target/$IMAGE
50cp packages/install/target/install-drools-$MVN_VERSION.zip packages/docker/target/$IMAGE/install-drools.zip
51
52#
53# This is the local latest tagged image. The Dockerfile's need this to build images
54#
55TAGS="--tag onap/policy/${IMAGE}:latest"
56#
57# This has the nexus repo prepended and only major/minor version with latest
58#
59TAGS="${TAGS} --tag ${DOCKER_REPOSITORY}/onap/policy/${IMAGE}:${MVN_MAJMIN_VERSION}-latest"
60#
61# This has the nexus repo prepended and major/minor/patch version with timestamp
62#
63TAGS="${TAGS} --tag ${DOCKER_REPOSITORY}/onap/policy/${IMAGE}:${MVN_VERSION}-${TIMESTAMP}"
64
65echo $TAGS
66
67docker build --quiet ${PROXY_ARGS} $TAGS packages/docker/target/$IMAGE
68
69if [ $? -ne 0 ]
70then
71 echo "Docker build failed"
72 docker images
73 exit 1
74fi
75
76docker images
77
78