2 # Copyright 2018 AT&T Intellectual Property. All rights reserved
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
8 # http://www.apache.org/licenses/LICENSE-2.0
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.
17 echo '============== STARTING SCRIPT TO BUILD DOCKER IMAGES ================='
19 # JUST VERIFY ONLY - NO PUSHING
21 DOCKER_REPOSITORY=nexus3.onap.org:10003
22 MVN_VERSION=$(cat packages/docker/target/version)
23 MVN_MAJMIN_VERSION=$(cut -f 1,2 -d . packages/docker/target/version)
24 TIMESTAMP=$(date -u +%Y%m%dT%H%M%S)
25 BUILD_ARGS="--build-arg BUILD_VERSION=${MVN_VERSION}"
28 if [ $HTTP_PROXY ]; then
29 BUILD_ARGS+=" --build-arg HTTP_PROXY=${HTTP_PROXY}"
31 if [ $HTTPS_PROXY ]; then
32 BUILD_ARGS+=" --build-arg HTTPS_PROXY=${HTTPS_PROXY}"
35 echo $DOCKER_REPOSITORY
37 echo $MVN_MAJMIN_VERSION
40 if [[ -z $MVN_VERSION ]]
42 echo "MVN_VERSION is empty"
46 if [[ -z $MVN_MAJMIN_VERSION ]]
48 echo "MVN_MAJMIN_VERSION is empty"
52 if [[ $MVN_VERSION == *"SNAPSHOT"* ]]
54 MVN_MAJMIN_VERSION="${MVN_MAJMIN_VERSION}-SNAPSHOT"
56 MVN_MAJMIN_VERSION="${MVN_MAJMIN_VERSION}-STAGING"
59 echo $MVN_MAJMIN_VERSION
61 echo "Building $IMAGE"
64 # This is the local latest tagged image. The Dockerfile's need this to build images
66 TAGS="--tag onap/${IMAGE}:latest"
68 # This has the nexus repo prepended and only major/minor version with latest
70 TAGS="${TAGS} --tag ${DOCKER_REPOSITORY}/onap/${IMAGE}:${MVN_MAJMIN_VERSION}-latest"
72 # This has the nexus repo prepended and major/minor/patch version with timestamp
74 TAGS="${TAGS} --tag ${DOCKER_REPOSITORY}/onap/${IMAGE}:${MVN_VERSION}-${TIMESTAMP}Z"
78 docker build --quiet ${BUILD_ARGS} $TAGS packages/docker/target/$IMAGE
82 echo "Docker build failed"