Adding cert files to support https
[aaf/sms.git] / sms-service / bin / build_quorum_image.sh
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"
9 VERSION="2.0.0"
10 PROJECT="aaf"
11 IMAGE="smsquorumclient"
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 #Need to create makefile
23 function generate_binary {
24     pushd ../src/quorumclient
25     make build
26     popd
27     cp ../target/quorumclient .
28 }
29
30 function copy_certificates {
31     cp ../src/sms/auth/aaf_root_ca.cer .
32 }
33
34 function cleanup {
35     rm quorumclient
36     rm aaf_root_ca.cer
37 }
38
39 function build_image {
40     echo "Start build docker image: ${IMAGE_NAME}"
41     docker build ${BUILD_ARGS} -t ${IMAGE_NAME}:latest -f quorumdockerfile .
42 }
43
44 function push_image_tag {
45     TAG_NAME=$1
46     echo "Start push ${TAG_NAME}"
47     docker tag ${IMAGE_NAME}:latest ${TAG_NAME}
48     docker push ${TAG_NAME}
49 }
50
51 function push_image {
52     echo "Start push ${IMAGE_NAME}:latest"
53     docker push ${IMAGE_NAME}:latest
54
55     push_image_tag ${IMAGE_NAME}:${VERSION}-SNAPSHOT-latest
56 }
57
58 generate_binary
59 copy_certificates
60 build_image
61 push_image
62 cleanup