mmis | 824a75e | 2018-03-02 18:04:48 +0000 | [diff] [blame] | 1 | #!/bin/bash |
Pamela Dragosh | 7bfe222 | 2018-04-16 09:40:04 -0400 | [diff] [blame] | 2 | # 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 | |
mmis | 824a75e | 2018-03-02 18:04:48 +0000 | [diff] [blame] | 16 | # |
| 17 | echo '============== STARTING SCRIPT TO BUILD DOCKER IMAGES =================' |
| 18 | # |
| 19 | # JUST VERIFY ONLY - NO PUSHING |
| 20 | # |
| 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) |
Jorge Hernandez | 3ad2775 | 2018-04-30 17:24:44 -0500 | [diff] [blame] | 25 | BUILD_ARGS="--build-arg BUILD_VERSION=${MVN_VERSION}" |
mmis | 824a75e | 2018-03-02 18:04:48 +0000 | [diff] [blame] | 26 | IMAGE=policy-drools |
| 27 | |
| 28 | if [ $HTTP_PROXY ]; then |
Jorge Hernandez | 3ad2775 | 2018-04-30 17:24:44 -0500 | [diff] [blame] | 29 | BUILD_ARGS+=" --build-arg HTTP_PROXY=${HTTP_PROXY}" |
mmis | 824a75e | 2018-03-02 18:04:48 +0000 | [diff] [blame] | 30 | fi |
| 31 | if [ $HTTPS_PROXY ]; then |
Jorge Hernandez | 3ad2775 | 2018-04-30 17:24:44 -0500 | [diff] [blame] | 32 | BUILD_ARGS+=" --build-arg HTTPS_PROXY=${HTTPS_PROXY}" |
mmis | 824a75e | 2018-03-02 18:04:48 +0000 | [diff] [blame] | 33 | fi |
| 34 | |
| 35 | echo $DOCKER_REPOSITORY |
| 36 | echo $MVN_VERSION |
| 37 | echo $MVN_MAJMIN_VERSION |
| 38 | echo $TIMESTAMP |
| 39 | |
| 40 | if [[ -z $MVN_VERSION ]] |
| 41 | then |
| 42 | echo "MVN_VERSION is empty" |
| 43 | exit 1 |
| 44 | fi |
| 45 | |
| 46 | if [[ -z $MVN_MAJMIN_VERSION ]] |
| 47 | then |
| 48 | echo "MVN_MAJMIN_VERSION is empty" |
| 49 | exit 1 |
| 50 | fi |
| 51 | |
| 52 | if [[ $MVN_VERSION == *"SNAPSHOT"* ]] |
| 53 | then |
| 54 | MVN_MAJMIN_VERSION="${MVN_MAJMIN_VERSION}-SNAPSHOT" |
| 55 | else |
| 56 | MVN_MAJMIN_VERSION="${MVN_MAJMIN_VERSION}-STAGING" |
| 57 | fi |
| 58 | |
| 59 | echo $MVN_MAJMIN_VERSION |
| 60 | |
| 61 | echo "Building $IMAGE" |
mmis | 824a75e | 2018-03-02 18:04:48 +0000 | [diff] [blame] | 62 | |
| 63 | # |
| 64 | # This is the local latest tagged image. The Dockerfile's need this to build images |
| 65 | # |
mmis | ac6780a | 2018-03-14 12:10:52 +0000 | [diff] [blame] | 66 | TAGS="--tag onap/${IMAGE}:latest" |
mmis | 824a75e | 2018-03-02 18:04:48 +0000 | [diff] [blame] | 67 | # |
| 68 | # This has the nexus repo prepended and only major/minor version with latest |
| 69 | # |
mmis | ac6780a | 2018-03-14 12:10:52 +0000 | [diff] [blame] | 70 | TAGS="${TAGS} --tag ${DOCKER_REPOSITORY}/onap/${IMAGE}:${MVN_MAJMIN_VERSION}-latest" |
mmis | 824a75e | 2018-03-02 18:04:48 +0000 | [diff] [blame] | 71 | # |
| 72 | # This has the nexus repo prepended and major/minor/patch version with timestamp |
| 73 | # |
mmis | 43380df | 2018-03-29 09:47:04 +0100 | [diff] [blame] | 74 | TAGS="${TAGS} --tag ${DOCKER_REPOSITORY}/onap/${IMAGE}:${MVN_VERSION}-${TIMESTAMP}Z" |
mmis | 824a75e | 2018-03-02 18:04:48 +0000 | [diff] [blame] | 75 | |
| 76 | echo $TAGS |
| 77 | |
Jorge Hernandez | 3ad2775 | 2018-04-30 17:24:44 -0500 | [diff] [blame] | 78 | docker build --quiet ${BUILD_ARGS} $TAGS packages/docker/target/$IMAGE |
mmis | 824a75e | 2018-03-02 18:04:48 +0000 | [diff] [blame] | 79 | |
| 80 | if [ $? -ne 0 ] |
| 81 | then |
| 82 | echo "Docker build failed" |
| 83 | docker images |
| 84 | exit 1 |
| 85 | fi |
| 86 | |
| 87 | docker images |
| 88 | |
| 89 | |