Pamela Dragosh | b174339 | 2017-02-21 12:04:28 -0500 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # |
| 3 | echo '============== STARTING SCRIPT TO BUILD DOCKER IMAGES =================' |
Pamela Dragosh | ceba3d8 | 2017-03-16 11:02:05 -0400 | [diff] [blame] | 4 | # |
| 5 | # JUST VERIFY ONLY - NO PUSHING |
| 6 | # |
Pamela Dragosh | 18882a0 | 2017-03-30 10:50:45 -0400 | [diff] [blame] | 7 | DOCKER_REPOSITORY=nexus3.onap.org:10003 |
Pamela Dragosh | 3fe4d9c | 2017-03-07 15:39:48 -0500 | [diff] [blame] | 8 | MVN_VERSION=$(cat target/version) |
Pamela Dragosh | e9f737a | 2017-03-23 07:44:56 -0400 | [diff] [blame] | 9 | MVN_MAJMIN_VERSION=$(cut -f 1,2 -d . target/version) |
Pamela Dragosh | 3fe4d9c | 2017-03-07 15:39:48 -0500 | [diff] [blame] | 10 | TIMESTAMP=$(date -u +%Y%m%dT%H%M%S) |
Shashank Kumar Shankar | 6e36eec | 2017-06-29 12:52:59 -0700 | [diff] [blame] | 11 | PROXY_ARGS="" |
| 12 | |
| 13 | if [ $HTTP_PROXY ]; then |
| 14 | PROXY_ARGS+="--build-arg HTTP_PROXY=${HTTP_PROXY}" |
| 15 | fi |
| 16 | if [ $HTTPS_PROXY ]; then |
| 17 | PROXY_ARGS+=" --build-arg HTTPS_PROXY=${HTTPS_PROXY}" |
| 18 | fi |
Pamela Dragosh | b174339 | 2017-02-21 12:04:28 -0500 | [diff] [blame] | 19 | |
Pamela Dragosh | 3fe4d9c | 2017-03-07 15:39:48 -0500 | [diff] [blame] | 20 | echo $DOCKER_REPOSITORY |
| 21 | echo $MVN_VERSION |
Pamela Dragosh | e9f737a | 2017-03-23 07:44:56 -0400 | [diff] [blame] | 22 | echo $MVN_MAJMIN_VERSION |
Pamela Dragosh | 3fe4d9c | 2017-03-07 15:39:48 -0500 | [diff] [blame] | 23 | echo $TIMESTAMP |
Pamela Dragosh | 6f91e0b | 2017-02-23 10:37:49 -0500 | [diff] [blame] | 24 | |
Pamela Dragosh | e9f737a | 2017-03-23 07:44:56 -0400 | [diff] [blame] | 25 | if [[ -z $MVN_VERSION ]] |
| 26 | then |
| 27 | echo "MVN_VERSION is empty" |
| 28 | exit 1 |
| 29 | fi |
| 30 | |
| 31 | if [[ -z $MVN_MAJMIN_VERSION ]] |
| 32 | then |
| 33 | echo "MVN_MAJMIN_VERSION is empty" |
| 34 | exit 1 |
| 35 | fi |
| 36 | |
| 37 | if [[ $MVN_VERSION == *"SNAPSHOT"* ]] |
| 38 | then |
| 39 | MVN_MAJMIN_VERSION="${MVN_MAJMIN_VERSION}-SNAPSHOT" |
| 40 | else |
| 41 | MVN_MAJMIN_VERSION="${MVN_MAJMIN_VERSION}-STAGING" |
| 42 | fi |
| 43 | |
| 44 | echo $MVN_MAJMIN_VERSION |
| 45 | |
Pamela Dragosh | 6f91e0b | 2017-02-23 10:37:49 -0500 | [diff] [blame] | 46 | cp policy-pe/* target/policy-pe/ |
| 47 | cp policy-drools/* target/policy-drools/ |
| 48 | |
| 49 | for image in policy-os policy-nexus policy-db policy-base policy-drools policy-pe ; do |
| 50 | echo "Building $image" |
| 51 | mkdir -p target/$image |
| 52 | cp $image/* target/$image |
Pamela Dragosh | 3fe4d9c | 2017-03-07 15:39:48 -0500 | [diff] [blame] | 53 | |
Pamela Dragosh | e9f737a | 2017-03-23 07:44:56 -0400 | [diff] [blame] | 54 | # |
| 55 | # This is the local latest tagged image. The Dockerfile's need this to build images |
| 56 | # |
Pamela Dragosh | 18882a0 | 2017-03-30 10:50:45 -0400 | [diff] [blame] | 57 | TAGS="--tag onap/policy/${image}:latest" |
Pamela Dragosh | e9f737a | 2017-03-23 07:44:56 -0400 | [diff] [blame] | 58 | # |
| 59 | # This has the nexus repo prepended and only major/minor version with latest |
| 60 | # |
Pamela Dragosh | 18882a0 | 2017-03-30 10:50:45 -0400 | [diff] [blame] | 61 | TAGS="${TAGS} --tag ${DOCKER_REPOSITORY}/onap/policy/${image}:${MVN_MAJMIN_VERSION}-latest" |
Pamela Dragosh | e9f737a | 2017-03-23 07:44:56 -0400 | [diff] [blame] | 62 | # |
| 63 | # This has the nexus repo prepended and major/minor/patch version with timestamp |
| 64 | # |
Pamela Dragosh | 18882a0 | 2017-03-30 10:50:45 -0400 | [diff] [blame] | 65 | TAGS="${TAGS} --tag ${DOCKER_REPOSITORY}/onap/policy/${image}:${MVN_VERSION}-${TIMESTAMP}" |
Pamela Dragosh | 3fe4d9c | 2017-03-07 15:39:48 -0500 | [diff] [blame] | 66 | |
| 67 | echo $TAGS |
Pamela Dragosh | 3311eb7 | 2017-03-16 11:30:29 -0400 | [diff] [blame] | 68 | |
Shashank Kumar Shankar | 6e36eec | 2017-06-29 12:52:59 -0700 | [diff] [blame] | 69 | docker build --quiet ${PROXY_ARGS} $TAGS target/$image |
Pamela Dragosh | 9bd4bf6 | 2017-03-30 12:46:08 -0400 | [diff] [blame] | 70 | |
| 71 | if [ $? -ne 0 ] |
| 72 | then |
| 73 | echo "Docker build failed" |
| 74 | docker images |
| 75 | exit 1 |
| 76 | fi |
Pamela Dragosh | 6f91e0b | 2017-02-23 10:37:49 -0500 | [diff] [blame] | 77 | done |
Pamela Dragosh | 3311eb7 | 2017-03-16 11:30:29 -0400 | [diff] [blame] | 78 | |
| 79 | docker images |
| 80 | |