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