Update version to 3.0.1 for release
[aaf/sms.git] / sms-service / bin / build_quorum_image.sh
1 #!/bin/bash
2 set -e
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"
10 VERSION="3.0.1"
11 PROJECT="aaf"
12 IMAGE="smsquorumclient"
13 DOCKER_REPOSITORY="nexus3.onap.org:10003"
14 IMAGE_NAME="${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/${IMAGE}"
15 TIMESTAMP=$(date +"%Y%m%dT%H%M%S")
16
17 if [ $HTTP_PROXY ]; then
18     BUILD_ARGS+=" --build-arg HTTP_PROXY=${HTTP_PROXY}"
19 fi
20 if [ $HTTPS_PROXY ]; then
21     BUILD_ARGS+=" --build-arg HTTPS_PROXY=${HTTPS_PROXY}"
22 fi
23 #Need to create makefile
24 function generate_binary {
25     pushd ../src/quorumclient
26     make build
27     popd
28     cp ../target/quorumclient .
29 }
30
31 function copy_certificates {
32     cp ../src/sms/certs/aaf_root_ca.cer .
33 }
34
35 function cleanup {
36     rm quorumclient
37     rm aaf_root_ca.cer
38 }
39
40 function build_image {
41     echo "Start build docker image: ${IMAGE_NAME}"
42     docker build ${BUILD_ARGS} -t ${IMAGE_NAME}:latest -f quorumdockerfile .
43 }
44
45 function push_image_tag {
46     TAG_NAME=$1
47     echo "Start push ${TAG_NAME}"
48     docker tag ${IMAGE_NAME}:latest ${TAG_NAME}
49     docker push ${TAG_NAME}
50 }
51
52 function push_image {
53     echo "Start push ${IMAGE_NAME}:latest"
54     docker push ${IMAGE_NAME}:latest
55
56     push_image_tag ${IMAGE_NAME}:${VERSION}-SNAPSHOT-latest
57 }
58
59 generate_binary
60 copy_certificates
61 build_image
62 push_image
63 cleanup