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 { |
| 31 | cp ../src/sms/auth/aaf-sms.api.simpledemo.onap.org.pem . |
| 32 | cp ../src/sms/auth/aaf-sms.api.simpledemo.onap.org.pr . |
| 33 | } |
| 34 | |
| 35 | function cleanup { |
Kiran Kamineni | 468de91 | 2018-04-04 14:03:56 -0700 | [diff] [blame] | 36 | rm sms |
Kiran Kamineni | 56a620d | 2018-04-26 17:31:07 -0700 | [diff] [blame^] | 37 | rm aaf-sms.api.simpledemo.onap.org.pem |
| 38 | rm af-sms.api.simpledemo.onap.org.pr |
Kiran Kamineni | 468de91 | 2018-04-04 14:03:56 -0700 | [diff] [blame] | 39 | } |
| 40 | |
| 41 | function build_image { |
| 42 | echo "Start build docker image: ${IMAGE_NAME}" |
| 43 | docker build ${BUILD_ARGS} -t ${IMAGE_NAME}:latest -f smsdockerfile . |
| 44 | } |
| 45 | |
| 46 | function push_image_tag { |
| 47 | TAG_NAME=$1 |
| 48 | echo "Start push ${TAG_NAME}" |
| 49 | docker tag ${IMAGE_NAME}:latest ${TAG_NAME} |
| 50 | docker push ${TAG_NAME} |
| 51 | } |
| 52 | |
| 53 | function push_image { |
| 54 | echo "Start push ${IMAGE_NAME}:latest" |
| 55 | docker push ${IMAGE_NAME}:latest |
| 56 | |
| 57 | push_image_tag ${IMAGE_NAME}:${VERSION}-SNAPSHOT-latest |
Kiran Kamineni | 468de91 | 2018-04-04 14:03:56 -0700 | [diff] [blame] | 58 | } |
| 59 | |
| 60 | generate_binary |
Kiran Kamineni | 56a620d | 2018-04-26 17:31:07 -0700 | [diff] [blame^] | 61 | copy_certificates |
Kiran Kamineni | 468de91 | 2018-04-04 14:03:56 -0700 | [diff] [blame] | 62 | build_image |
| 63 | push_image |
Kiran Kamineni | 56a620d | 2018-04-26 17:31:07 -0700 | [diff] [blame^] | 64 | cleanup |