Kiran Kamineni | 468de91 | 2018-04-04 14:03:56 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | DIRNAME=`dirname $0` |
| 3 | DOCKER_BUILD_DIR=`cd $DIRNAME/; pwd` |
| 4 | echo "DOCKER_BUILD_DIR=${DOCKER_BUILD_DIR}" |
| 5 | cd ${DOCKER_BUILD_DIR} |
| 6 | |
| 7 | BUILD_ARGS="--no-cache" |
| 8 | ORG="onap" |
Kiran Kamineni | 74d37f1 | 2018-04-24 16:28:44 -0700 | [diff] [blame] | 9 | VERSION="2.0.0" |
Kiran Kamineni | 468de91 | 2018-04-04 14:03:56 -0700 | [diff] [blame] | 10 | PROJECT="aaf" |
| 11 | IMAGE="sms" |
| 12 | DOCKER_REPOSITORY="nexus3.onap.org:10003" |
| 13 | IMAGE_NAME="${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/${IMAGE}" |
| 14 | TIMESTAMP=$(date +"%Y%m%dT%H%M%S") |
| 15 | |
| 16 | if [ $HTTP_PROXY ]; then |
| 17 | BUILD_ARGS+=" --build-arg HTTP_PROXY=${HTTP_PROXY}" |
| 18 | fi |
| 19 | if [ $HTTPS_PROXY ]; then |
| 20 | BUILD_ARGS+=" --build-arg HTTPS_PROXY=${HTTPS_PROXY}" |
| 21 | fi |
| 22 | |
| 23 | function generate_binary { |
| 24 | pushd ../src/sms |
| 25 | make build |
| 26 | popd |
| 27 | cp ../target/sms . |
| 28 | } |
| 29 | |
Kiran Kamineni | 56a620d | 2018-04-26 17:31:07 -0700 | [diff] [blame] | 30 | function copy_certificates { |
Kiran Kamineni | 9b0c494 | 2018-04-26 21:57:47 -0700 | [diff] [blame^] | 31 | cp ../src/sms/auth/aaf_root_ca.cer . |
Kiran Kamineni | 56a620d | 2018-04-26 17:31:07 -0700 | [diff] [blame] | 32 | cp ../src/sms/auth/aaf-sms.api.simpledemo.onap.org.pem . |
| 33 | cp ../src/sms/auth/aaf-sms.api.simpledemo.onap.org.pr . |
| 34 | } |
| 35 | |
| 36 | function cleanup { |
Kiran Kamineni | 468de91 | 2018-04-04 14:03:56 -0700 | [diff] [blame] | 37 | rm sms |
Kiran Kamineni | 56a620d | 2018-04-26 17:31:07 -0700 | [diff] [blame] | 38 | rm aaf-sms.api.simpledemo.onap.org.pem |
Kiran Kamineni | 9b0c494 | 2018-04-26 21:57:47 -0700 | [diff] [blame^] | 39 | rm aaf-sms.api.simpledemo.onap.org.pr |
| 40 | rm aaf_root_ca.cer |
Kiran Kamineni | 468de91 | 2018-04-04 14:03:56 -0700 | [diff] [blame] | 41 | } |
| 42 | |
| 43 | function build_image { |
| 44 | echo "Start build docker image: ${IMAGE_NAME}" |
| 45 | docker build ${BUILD_ARGS} -t ${IMAGE_NAME}:latest -f smsdockerfile . |
| 46 | } |
| 47 | |
| 48 | function push_image_tag { |
| 49 | TAG_NAME=$1 |
| 50 | echo "Start push ${TAG_NAME}" |
| 51 | docker tag ${IMAGE_NAME}:latest ${TAG_NAME} |
| 52 | docker push ${TAG_NAME} |
| 53 | } |
| 54 | |
| 55 | function push_image { |
| 56 | echo "Start push ${IMAGE_NAME}:latest" |
| 57 | docker push ${IMAGE_NAME}:latest |
| 58 | |
| 59 | push_image_tag ${IMAGE_NAME}:${VERSION}-SNAPSHOT-latest |
Kiran Kamineni | 468de91 | 2018-04-04 14:03:56 -0700 | [diff] [blame] | 60 | } |
| 61 | |
| 62 | generate_binary |
Kiran Kamineni | 56a620d | 2018-04-26 17:31:07 -0700 | [diff] [blame] | 63 | copy_certificates |
Kiran Kamineni | 468de91 | 2018-04-04 14:03:56 -0700 | [diff] [blame] | 64 | build_image |
| 65 | push_image |
Kiran Kamineni | 9b0c494 | 2018-04-26 21:57:47 -0700 | [diff] [blame^] | 66 | cleanup |