mmis | 1336873 | 2018-03-01 16:50:11 +0000 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # |
| 3 | echo '============== STARTING SCRIPT TO BUILD DOCKER IMAGES =================' |
| 4 | # |
| 5 | # JUST VERIFY ONLY - NO PUSHING |
| 6 | # |
| 7 | DOCKER_REPOSITORY=nexus3.onap.org:10003 |
| 8 | MVN_VERSION=$(cat packages/docker/target/version) |
| 9 | MVN_MAJMIN_VERSION=$(cut -f 1,2 -d . packages/docker/target/version) |
| 10 | TIMESTAMP=$(date -u +%Y%m%dT%H%M%S) |
| 11 | PROXY_ARGS="" |
| 12 | IMAGE=policy-pe |
| 13 | |
| 14 | if [ $HTTP_PROXY ]; then |
| 15 | PROXY_ARGS+="--build-arg HTTP_PROXY=${HTTP_PROXY}" |
| 16 | fi |
| 17 | if [ $HTTPS_PROXY ]; then |
| 18 | PROXY_ARGS+=" --build-arg HTTPS_PROXY=${HTTPS_PROXY}" |
| 19 | fi |
| 20 | |
| 21 | echo $DOCKER_REPOSITORY |
| 22 | echo $MVN_VERSION |
| 23 | echo $MVN_MAJMIN_VERSION |
| 24 | echo $TIMESTAMP |
| 25 | |
| 26 | if [[ -z $MVN_VERSION ]] |
| 27 | then |
| 28 | echo "MVN_VERSION is empty" |
| 29 | exit 1 |
| 30 | fi |
| 31 | |
| 32 | if [[ -z $MVN_MAJMIN_VERSION ]] |
| 33 | then |
| 34 | echo "MVN_MAJMIN_VERSION is empty" |
| 35 | exit 1 |
| 36 | fi |
| 37 | |
| 38 | if [[ $MVN_VERSION == *"SNAPSHOT"* ]] |
| 39 | then |
| 40 | MVN_MAJMIN_VERSION="${MVN_MAJMIN_VERSION}-SNAPSHOT" |
| 41 | else |
| 42 | MVN_MAJMIN_VERSION="${MVN_MAJMIN_VERSION}-STAGING" |
| 43 | fi |
| 44 | |
| 45 | echo $MVN_MAJMIN_VERSION |
| 46 | |
| 47 | echo "Building $IMAGE" |
mmis | 1336873 | 2018-03-01 16:50:11 +0000 | [diff] [blame] | 48 | |
| 49 | # |
| 50 | # This is the local latest tagged image. The Dockerfile's need this to build images |
| 51 | # |
mmis | 4ea6678 | 2018-03-14 12:03:37 +0000 | [diff] [blame] | 52 | TAGS="--tag onap/${IMAGE}:latest" |
mmis | 1336873 | 2018-03-01 16:50:11 +0000 | [diff] [blame] | 53 | # |
| 54 | # This has the nexus repo prepended and only major/minor version with latest |
| 55 | # |
mmis | 4ea6678 | 2018-03-14 12:03:37 +0000 | [diff] [blame] | 56 | TAGS="${TAGS} --tag ${DOCKER_REPOSITORY}/onap/${IMAGE}:${MVN_MAJMIN_VERSION}-latest" |
mmis | 1336873 | 2018-03-01 16:50:11 +0000 | [diff] [blame] | 57 | # |
| 58 | # This has the nexus repo prepended and major/minor/patch version with timestamp |
| 59 | # |
mmis | d7eac78 | 2018-03-29 09:37:45 +0100 | [diff] [blame] | 60 | TAGS="${TAGS} --tag ${DOCKER_REPOSITORY}/onap/${IMAGE}:${MVN_VERSION}-${TIMESTAMP}Z" |
mmis | 1336873 | 2018-03-01 16:50:11 +0000 | [diff] [blame] | 61 | |
| 62 | echo $TAGS |
| 63 | |
| 64 | docker build --quiet ${PROXY_ARGS} $TAGS packages/docker/target/$IMAGE |
| 65 | |
| 66 | if [ $? -ne 0 ] |
| 67 | then |
| 68 | echo "Docker build failed" |
| 69 | docker images |
| 70 | exit 1 |
| 71 | fi |
| 72 | |
| 73 | docker images |
| 74 | |