blob: 009fce4422c55c59e8d30e7831235b21ceab7f5f [file] [log] [blame]
mmis824a75e2018-03-02 18:04:48 +00001#!/bin/bash
Pamela Dragosh7bfe2222018-04-16 09:40:04 -04002# Copyright 2018 AT&T Intellectual Property. All rights reserved
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
mmis824a75e2018-03-02 18:04:48 +000016#
17echo '============== STARTING SCRIPT TO BUILD DOCKER IMAGES ================='
18#
19# JUST VERIFY ONLY - NO PUSHING
20#
21DOCKER_REPOSITORY=nexus3.onap.org:10003
22MVN_VERSION=$(cat packages/docker/target/version)
23MVN_MAJMIN_VERSION=$(cut -f 1,2 -d . packages/docker/target/version)
24TIMESTAMP=$(date -u +%Y%m%dT%H%M%S)
25PROXY_ARGS=""
26IMAGE=policy-drools
27
28if [ $HTTP_PROXY ]; then
29 PROXY_ARGS+="--build-arg HTTP_PROXY=${HTTP_PROXY}"
30fi
31if [ $HTTPS_PROXY ]; then
32 PROXY_ARGS+=" --build-arg HTTPS_PROXY=${HTTPS_PROXY}"
33fi
34
35echo $DOCKER_REPOSITORY
36echo $MVN_VERSION
37echo $MVN_MAJMIN_VERSION
38echo $TIMESTAMP
39
40if [[ -z $MVN_VERSION ]]
41then
42 echo "MVN_VERSION is empty"
43 exit 1
44fi
45
46if [[ -z $MVN_MAJMIN_VERSION ]]
47then
48 echo "MVN_MAJMIN_VERSION is empty"
49 exit 1
50fi
51
52if [[ $MVN_VERSION == *"SNAPSHOT"* ]]
53then
54 MVN_MAJMIN_VERSION="${MVN_MAJMIN_VERSION}-SNAPSHOT"
55else
56 MVN_MAJMIN_VERSION="${MVN_MAJMIN_VERSION}-STAGING"
57fi
58
59echo $MVN_MAJMIN_VERSION
60
61echo "Building $IMAGE"
mmis824a75e2018-03-02 18:04:48 +000062
63#
64# This is the local latest tagged image. The Dockerfile's need this to build images
65#
mmisac6780a2018-03-14 12:10:52 +000066TAGS="--tag onap/${IMAGE}:latest"
mmis824a75e2018-03-02 18:04:48 +000067#
68# This has the nexus repo prepended and only major/minor version with latest
69#
mmisac6780a2018-03-14 12:10:52 +000070TAGS="${TAGS} --tag ${DOCKER_REPOSITORY}/onap/${IMAGE}:${MVN_MAJMIN_VERSION}-latest"
mmis824a75e2018-03-02 18:04:48 +000071#
72# This has the nexus repo prepended and major/minor/patch version with timestamp
73#
mmis43380df2018-03-29 09:47:04 +010074TAGS="${TAGS} --tag ${DOCKER_REPOSITORY}/onap/${IMAGE}:${MVN_VERSION}-${TIMESTAMP}Z"
mmis824a75e2018-03-02 18:04:48 +000075
76echo $TAGS
77
78docker build --quiet ${PROXY_ARGS} $TAGS packages/docker/target/$IMAGE
79
80if [ $? -ne 0 ]
81then
82 echo "Docker build failed"
83 docker images
84 exit 1
85fi
86
87docker images
88
89