fix bug for vfc-nfvo-driver-vnfm-svnfm sanity check
[vfc/nfvo/driver/vnfm/svnfm.git] / nokia / vnfmdriver / vfcadaptorservice / docker / build_image.sh
1 #!/bin/bash
2 #
3 # Copyright 2017, Nokia Corporation
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 #     http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16 #
17
18 DIRNAME=`dirname $0`
19 DOCKER_BUILD_DIR=`cd $DIRNAME/; pwd`
20 echo "DOCKER_BUILD_DIR=${DOCKER_BUILD_DIR}"
21 cd ${DOCKER_BUILD_DIR}
22
23 BUILD_ARGS="--no-cache"
24 ORG="onap"
25 VERSION="1.3.4"
26 PROJECT="vfc"
27 IMAGE="nfvo/svnfm/nokia"
28 DOCKER_REPOSITORY="nexus3.onap.org:10003"
29 IMAGE_NAME="${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/${IMAGE}"
30 TIMESTAMP=$(date +"%Y%m%dT%H%M%S")
31
32 BUILD_ARGS+=" --build-arg PKG_VERSION=${VERSION}"
33
34 if [ $HTTP_PROXY ]; then
35     BUILD_ARGS+=" --build-arg HTTP_PROXY=${HTTP_PROXY}"
36 fi
37 if [ $HTTPS_PROXY ]; then
38     BUILD_ARGS+=" --build-arg HTTPS_PROXY=${HTTPS_PROXY}"
39 fi
40
41 function build_image {
42     echo "Start build docker image: ${IMAGE_NAME}"
43     docker build ${BUILD_ARGS} -t ${IMAGE_NAME}:latest .
44 }
45
46 function push_image_tag {
47     TAG_NAME=$1
48     echo "Start push ${TAG_NAME}"
49     docker tag ${IMAGE_NAME}:latest ${TAG_NAME}
50     docker push ${TAG_NAME}
51 }
52
53 function push_image {
54     echo "Start push ${IMAGE_NAME}:latest"
55     docker push ${IMAGE_NAME}:latest
56     
57     push_image_tag ${IMAGE_NAME}:${VERSION}-SNAPSHOT-latest
58     push_image_tag ${IMAGE_NAME}:${VERSION}-STAGING-latest
59     push_image_tag ${IMAGE_NAME}:${VERSION}-STAGING-${TIMESTAMP}
60 }
61
62 build_image
63 push_image