Add huawei vnfmdriver build docker shell 71/10271/1
authorluxin <luxin7@huawei.com>
Tue, 5 Sep 2017 03:42:23 +0000 (11:42 +0800)
committerluxin <luxin7@huawei.com>
Tue, 5 Sep 2017 03:42:23 +0000 (11:42 +0800)
Change-Id: I9b2fd18791cffee595741f8a7760fa51a45c737a
Issue-Id:VFC-273
Signed-off-by: luxin <luxin7@huawei.com>
huawei/vnfmadapter/VnfmadapterService/deployment/src/main/release/docker/build_image.sh [new file with mode: 0644]
huawei/vnfmadapter/VnfmadapterService/deployment/src/main/release/docker/docker-entrypoint.sh [new file with mode: 0644]
huawei/vnfmadapter/VnfmadapterService/deployment/src/main/release/docker/instance-run.sh [new file with mode: 0644]
huawei/vnfmadapter/VnfmadapterService/deployment/src/main/release/docker/instance-workaround.sh [new file with mode: 0644]

diff --git a/huawei/vnfmadapter/VnfmadapterService/deployment/src/main/release/docker/build_image.sh b/huawei/vnfmadapter/VnfmadapterService/deployment/src/main/release/docker/build_image.sh
new file mode 100644 (file)
index 0000000..b83cf6c
--- /dev/null
@@ -0,0 +1,34 @@
+#!/bin/bash
+DIRNAME=`dirname $0`
+DOCKER_BUILD_DIR=`cd $DIRNAME/; pwd`
+echo "DOCKER_BUILD_DIR=${DOCKER_BUILD_DIR}"
+cd ${DOCKER_BUILD_DIR}
+
+BUILD_ARGS="--no-cache"
+ORG="onap"
+VERSION="1.0.0-SNAPSHOT"
+PROJECT="vfc"
+IMAGE="nfvo/svnfm/huawei"
+DOCKER_REPOSITORY="nexus3.onap.org:10003"
+IMAGE_NAME="${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/${IMAGE}"
+
+if [ $HTTP_PROXY ]; then
+    BUILD_ARGS+=" --build-arg HTTP_PROXY=${HTTP_PROXY}"
+fi
+if [ $HTTPS_PROXY ]; then
+    BUILD_ARGS+=" --build-arg HTTPS_PROXY=${HTTPS_PROXY}"
+fi
+
+function build_image {
+    echo "Start build docker image: ${IMAGE_NAME}"
+    docker build ${BUILD_ARGS} -t ${IMAGE_NAME}:${VERSION} -t ${IMAGE_NAME}:latest .
+}
+
+function push_image {
+    echo "Start push docker image: ${IMAGE_NAME}"
+    docker push ${IMAGE_NAME}:${VERSION}
+    docker push ${IMAGE_NAME}:latest
+}
+
+build_image
+push_image
diff --git a/huawei/vnfmadapter/VnfmadapterService/deployment/src/main/release/docker/docker-entrypoint.sh b/huawei/vnfmadapter/VnfmadapterService/deployment/src/main/release/docker/docker-entrypoint.sh
new file mode 100644 (file)
index 0000000..756024c
--- /dev/null
@@ -0,0 +1,68 @@
+#!/bin/bash
+#
+# Copyright 2017 Huawei Technologies Co., Ltd.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#
+# This file was auto-generated by gen-all-dockerfiles.sh; do not modify manually.
+#
+# nfvo-driver-vnfm-huawei/target/docker-entrypoint.sh
+#
+
+if [ -z "$SERVICE_IP" ]; then
+    export SERVICE_IP=`hostname -i`
+fi
+echo
+echo Environment Variables:
+echo "SERVICE_IP=$SERVICE_IP"
+
+#if [ -z "$MSB_ADDR" ]; then
+#    echo "Missing required variable MSB_ADDR: Microservices Service Bus address <ip>:<port>"
+#    exit 1
+#fi
+#echo "MSB_ADDR=$MSB_ADDR"
+#echo
+
+## Wait for MSB initialization
+#echo Wait for MSB initialization
+#for i in {1..20}; do
+#    curl -sS -m 1 $MSB_ADDR > /dev/null && break
+#    sleep $i
+#done
+
+echo
+
+# Configure service based on docker environment variables
+./instance-config.sh
+
+# Start mysql
+su mysql -c /usr/bin/mysqld_safe &
+
+# Perform one-time config
+if [ ! -e init.log ]; then
+    # Perform workarounds due to defects in release binary
+    ./instance-workaround.sh
+
+    # Init mysql; set root password
+    ./init-mysql.sh
+
+    # microservice-specific one-time initialization
+    ./instance-init.sh
+
+    date > init.log
+fi
+
+# Start the microservice
+./instance-run.sh
+
diff --git a/huawei/vnfmadapter/VnfmadapterService/deployment/src/main/release/docker/instance-run.sh b/huawei/vnfmadapter/VnfmadapterService/deployment/src/main/release/docker/instance-run.sh
new file mode 100644 (file)
index 0000000..2c77db9
--- /dev/null
@@ -0,0 +1,23 @@
+#!/bin/bash
+#
+# Copyright 2016-2017 Huawei Technologies Co., Ltd.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# Start microservice
+cd bin
+./start.sh
+while [ ! -e ../logs/vnfmadapterservice.log ]; do
+    sleep 1
+done
+tail -F ../logs/vnfmadapterservice.log
diff --git a/huawei/vnfmadapter/VnfmadapterService/deployment/src/main/release/docker/instance-workaround.sh b/huawei/vnfmadapter/VnfmadapterService/deployment/src/main/release/docker/instance-workaround.sh
new file mode 100644 (file)
index 0000000..40058f5
--- /dev/null
@@ -0,0 +1,16 @@
+#!/bin/bash
+#
+# Copyright 2017 Huawei Technologies Co., Ltd.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#