blob: 5dead3f0e21d2f5ca54e26dcf23098cb7924504f [file] [log] [blame]
Kiran Kamineni468de912018-04-04 14:03:56 -07001#!/bin/bash
Kiran Kaminenic351f2e2018-06-05 17:19:12 -07002set -e
Kiran Kamineni468de912018-04-04 14:03:56 -07003DIRNAME=`dirname $0`
4DOCKER_BUILD_DIR=`cd $DIRNAME/; pwd`
5echo "DOCKER_BUILD_DIR=${DOCKER_BUILD_DIR}"
6cd ${DOCKER_BUILD_DIR}
7
8BUILD_ARGS="--no-cache"
9ORG="onap"
Manjunath Ranganathaiahc0b515d2019-04-10 10:57:46 -070010VERSION="4.0.0"
Kiran Kamineni468de912018-04-04 14:03:56 -070011PROJECT="aaf"
12IMAGE="sms"
13DOCKER_REPOSITORY="nexus3.onap.org:10003"
14IMAGE_NAME="${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/${IMAGE}"
15TIMESTAMP=$(date +"%Y%m%dT%H%M%S")
ChrisC172045b2020-03-17 14:18:38 +010016DUSER=aaf
Kiran Kamineni468de912018-04-04 14:03:56 -070017
18if [ $HTTP_PROXY ]; then
19 BUILD_ARGS+=" --build-arg HTTP_PROXY=${HTTP_PROXY}"
20fi
21if [ $HTTPS_PROXY ]; then
22 BUILD_ARGS+=" --build-arg HTTPS_PROXY=${HTTPS_PROXY}"
23fi
24
25function generate_binary {
26 pushd ../src/sms
27 make build
28 popd
Kiran Kamineni513d6ba2018-10-05 11:33:50 -070029 pushd ../src/preload
30 make build
31 popd
Kiran Kamineni468de912018-04-04 14:03:56 -070032 cp ../target/sms .
Kiran Kamineni513d6ba2018-10-05 11:33:50 -070033 cp ../target/preload .
Kiran Kamineni468de912018-04-04 14:03:56 -070034}
35
Kiran Kamineni56a620d2018-04-26 17:31:07 -070036function copy_certificates {
Kiran Kamineni30cd3842018-05-14 14:40:03 -070037 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 Kamineni56a620d2018-04-26 17:31:07 -070040}
41
42function cleanup {
Kiran Kamineni513d6ba2018-10-05 11:33:50 -070043 rm sms preload
Kiran Kamineni30cd3842018-05-14 14:40:03 -070044 rm aaf-sms.pub
45 rm aaf-sms.pr
46 rm aaf_root_ca.cer
Kiran Kamineni468de912018-04-04 14:03:56 -070047}
48
49function build_image {
50 echo "Start build docker image: ${IMAGE_NAME}"
51 docker build ${BUILD_ARGS} -t ${IMAGE_NAME}:latest -f smsdockerfile .
52}
53
54function 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
61function 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 Kamineni468de912018-04-04 14:03:56 -070066}
67
68generate_binary
Kiran Kamineni56a620d2018-04-26 17:31:07 -070069copy_certificates
Kiran Kamineni468de912018-04-04 14:03:56 -070070build_image
71push_image
Kiran Kamineni9b0c4942018-04-26 21:57:47 -070072cleanup