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) |
Pamela Dragosh | b174339 | 2017-02-21 12:04:28 -0500 | [diff] [blame] | 11 | |
Pamela Dragosh | 3fe4d9c | 2017-03-07 15:39:48 -0500 | [diff] [blame] | 12 | echo $DOCKER_REPOSITORY |
| 13 | echo $MVN_VERSION |
Pamela Dragosh | e9f737a | 2017-03-23 07:44:56 -0400 | [diff] [blame] | 14 | echo $MVN_MAJMIN_VERSION |
Pamela Dragosh | 3fe4d9c | 2017-03-07 15:39:48 -0500 | [diff] [blame] | 15 | echo $TIMESTAMP |
Pamela Dragosh | 6f91e0b | 2017-02-23 10:37:49 -0500 | [diff] [blame] | 16 | |
Pamela Dragosh | e9f737a | 2017-03-23 07:44:56 -0400 | [diff] [blame] | 17 | if [[ -z $MVN_VERSION ]] |
| 18 | then |
| 19 | echo "MVN_VERSION is empty" |
| 20 | exit 1 |
| 21 | fi |
| 22 | |
| 23 | if [[ -z $MVN_MAJMIN_VERSION ]] |
| 24 | then |
| 25 | echo "MVN_MAJMIN_VERSION is empty" |
| 26 | exit 1 |
| 27 | fi |
| 28 | |
| 29 | if [[ $MVN_VERSION == *"SNAPSHOT"* ]] |
| 30 | then |
| 31 | MVN_MAJMIN_VERSION="${MVN_MAJMIN_VERSION}-SNAPSHOT" |
| 32 | else |
| 33 | MVN_MAJMIN_VERSION="${MVN_MAJMIN_VERSION}-STAGING" |
| 34 | fi |
| 35 | |
| 36 | echo $MVN_MAJMIN_VERSION |
| 37 | |
Pamela Dragosh | 6f91e0b | 2017-02-23 10:37:49 -0500 | [diff] [blame] | 38 | cp policy-pe/* target/policy-pe/ |
| 39 | cp policy-drools/* target/policy-drools/ |
| 40 | |
| 41 | for image in policy-os policy-nexus policy-db policy-base policy-drools policy-pe ; do |
| 42 | echo "Building $image" |
| 43 | mkdir -p target/$image |
| 44 | cp $image/* target/$image |
Pamela Dragosh | 3fe4d9c | 2017-03-07 15:39:48 -0500 | [diff] [blame] | 45 | |
Pamela Dragosh | e9f737a | 2017-03-23 07:44:56 -0400 | [diff] [blame] | 46 | # |
| 47 | # This is the local latest tagged image. The Dockerfile's need this to build images |
| 48 | # |
Pamela Dragosh | 18882a0 | 2017-03-30 10:50:45 -0400 | [diff] [blame^] | 49 | TAGS="--tag onap/policy/${image}:latest" |
Pamela Dragosh | e9f737a | 2017-03-23 07:44:56 -0400 | [diff] [blame] | 50 | # |
| 51 | # This has the nexus repo prepended and only major/minor version with latest |
| 52 | # |
Pamela Dragosh | 18882a0 | 2017-03-30 10:50:45 -0400 | [diff] [blame^] | 53 | TAGS="${TAGS} --tag ${DOCKER_REPOSITORY}/onap/policy/${image}:${MVN_MAJMIN_VERSION}-latest" |
Pamela Dragosh | e9f737a | 2017-03-23 07:44:56 -0400 | [diff] [blame] | 54 | # |
| 55 | # This has the nexus repo prepended and major/minor/patch version with timestamp |
| 56 | # |
Pamela Dragosh | 18882a0 | 2017-03-30 10:50:45 -0400 | [diff] [blame^] | 57 | TAGS="${TAGS} --tag ${DOCKER_REPOSITORY}/onap/policy/${image}:${MVN_VERSION}-${TIMESTAMP}" |
Pamela Dragosh | 3fe4d9c | 2017-03-07 15:39:48 -0500 | [diff] [blame] | 58 | |
| 59 | echo $TAGS |
Pamela Dragosh | 3311eb7 | 2017-03-16 11:30:29 -0400 | [diff] [blame] | 60 | |
| 61 | docker build --quiet $TAGS target/$image |
Pamela Dragosh | 6f91e0b | 2017-02-23 10:37:49 -0500 | [diff] [blame] | 62 | done |
Pamela Dragosh | 3311eb7 | 2017-03-16 11:30:29 -0400 | [diff] [blame] | 63 | |
| 64 | docker images |
| 65 | |