3 echo '============== STARTING SCRIPT TO BUILD DOCKER IMAGES ================='
4 DOCKER_REPOSITORY=nexus3.onap.org:10003
5 MVN_VERSION=$(cat target/version)
6 MVN_MAJMIN_VERSION=$(cut -f 1,2 -d . target/version)
7 TIMESTAMP=$(date -u +%Y%m%dT%H%M%S)
10 if [ $HTTP_PROXY ]; then
11 PROXY_ARGS+="--build-arg HTTP_PROXY=${HTTP_PROXY}"
13 if [ $HTTPS_PROXY ]; then
14 PROXY_ARGS+=" --build-arg HTTPS_PROXY=${HTTPS_PROXY}"
17 echo $DOCKER_REPOSITORY
19 echo $MVN_MAJMIN_VERSION
22 if [[ -z $MVN_VERSION ]]
24 echo "MVN_VERSION is empty"
28 if [[ -z $MVN_MAJMIN_VERSION ]]
30 echo "MVN_MAJMIN_VERSION is empty"
34 if [[ $MVN_VERSION == *"SNAPSHOT"* ]]
36 MVN_MAJMIN_VERSION="${MVN_MAJMIN_VERSION}-SNAPSHOT"
38 MVN_MAJMIN_VERSION="${MVN_MAJMIN_VERSION}-STAGING"
41 echo $MVN_MAJMIN_VERSION
43 cp policy-pe/* target/policy-pe/
44 cp policy-drools/* target/policy-drools/
46 for image in policy-os policy-nexus policy-db policy-base policy-drools policy-pe ; do
47 echo "Building $image"
48 mkdir -p target/$image
49 cp $image/* target/$image
52 # This is the local latest tagged image. The Dockerfile's need this to build images
54 TAGS="--tag onap/policy/${image}:latest"
56 # This is the nexus repo prepended for latest tagged image.
58 TAGS="${TAGS} --tag ${DOCKER_REPOSITORY}/onap/policy/${image}:latest"
60 # This has the nexus repo prepended and only major/minor version with latest
62 TAGS="${TAGS} --tag ${DOCKER_REPOSITORY}/onap/policy/${image}:${MVN_MAJMIN_VERSION}-latest"
64 # This has the nexus repo prepended and major/minor/patch version with timestamp
66 TAGS="${TAGS} --tag ${DOCKER_REPOSITORY}/onap/policy/${image}:${MVN_VERSION}-STAGING-${TIMESTAMP}"
70 docker build --quiet ${PROXY_ARGS} $TAGS target/$image
74 echo "Docker build failed"
82 for image in policy-nexus policy-db policy-drools policy-pe; do
85 docker push ${DOCKER_REPOSITORY}/onap/policy/$image:latest
89 echo "Docker push failed"
94 docker push ${DOCKER_REPOSITORY}/onap/policy/$image:${MVN_MAJMIN_VERSION}-latest
98 echo "Docker push failed"
102 docker push ${DOCKER_REPOSITORY}/onap/policy/$image:${MVN_VERSION}-STAGING-${TIMESTAMP}
106 echo "Docker push failed"