Remove expired certs and key, use them from oom.
[aaf/sms.git] / sms-service / bin / build_sms_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="4.0.0"
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")
16 DUSER=aaf
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
29     pushd ../src/preload
30     make build
31     popd
32     cp ../target/sms .
33     cp ../target/preload .
34 }
35
36 function cleanup {
37     rm sms preload
38 }
39
40 function build_image {
41     echo "Start build docker image: ${IMAGE_NAME}"
42     docker build ${BUILD_ARGS} -t ${IMAGE_NAME}:latest -f smsdockerfile .
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 build_image
61 push_image
62 cleanup