469106742f4fe67f209f388abfe7606ccfe9bf4b
[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 remove_binary {
31     rm quorumclient
32 }
33
34 function build_image {
35     echo "Start build docker image: ${IMAGE_NAME}"
36     docker build ${BUILD_ARGS} -t ${IMAGE_NAME}:latest -f quorumdockerfile .
37 }
38
39 function push_image_tag {
40     TAG_NAME=$1
41     echo "Start push ${TAG_NAME}"
42     docker tag ${IMAGE_NAME}:latest ${TAG_NAME}
43     docker push ${TAG_NAME}
44 }
45
46 function push_image {
47     echo "Start push ${IMAGE_NAME}:latest"
48     docker push ${IMAGE_NAME}:latest
49
50     push_image_tag ${IMAGE_NAME}:${VERSION}-SNAPSHOT-latest
51 }
52
53 generate_binary
54 build_image
55 push_image
56 remove_binary