summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfujinhua <fu.jinhua@zte.com.cn>2017-09-01 13:57:39 +0800
committerfujinhua <fu.jinhua@zte.com.cn>2017-09-01 14:01:44 +0800
commit0750bee8cfa8612105455bea35b5514b193354a5 (patch)
treeb0641c940accf41ab81d40bcd4969172dd32e091
parent229be292116f30908dd3de5bd69dfb7c15b42a93 (diff)
Update dockerfile of vfc-gvnfm-vnflcm
Add entrypoint to dockerfile Change-Id: If32fb9ec04a0f492c39d5f61f9481f86e27519cc Issue-Id: VFC-224 Signed-off-by: fujinhua <fu.jinhua@zte.com.cn>
-rwxr-xr-xlcm/docker/Dockerfile7
-rwxr-xr-xlcm/docker/build_image.sh2
-rwxr-xr-xlcm/docker/docker-entrypoint.sh35
-rwxr-xr-xlcm/docker/instance_init.sh25
4 files changed, 44 insertions, 25 deletions
diff --git a/lcm/docker/Dockerfile b/lcm/docker/Dockerfile
index e552304e..5b847db3 100755
--- a/lcm/docker/Dockerfile
+++ b/lcm/docker/Dockerfile
@@ -27,7 +27,7 @@ RUN apt-get update && \
apt-get install -y unzip
ADD . /service
-RUN cd /service
+WORKDIR /service
# get binary zip from nexus
RUN wget -q -O vfc-gvnfm-vnflcm-lcm.zip 'https://nexus.onap.org/service/local/artifact/maven/redirect?r=snapshots&g=org.onap.vfc.gvnfm.vnflcm&a=vfc-gvnfm-vnflcm-lcm&v=LATEST&e=zip' && \
@@ -44,6 +44,5 @@ RUN wget -q -O vfc-gvnfm-vnfres-res.zip 'https://nexus.onap.org/service/local/ar
EXPOSE 8801
EXPOSE 3306
-WORKDIR /service/vfc/gvnfm/vnflcm/
-
-CMD lcm/docker/instance_init.sh
+WORKDIR /service
+ENTRYPOINT vfc/gvnfm/vnflcm/lcm/docker/docker-entrypoint.sh
diff --git a/lcm/docker/build_image.sh b/lcm/docker/build_image.sh
index b40f1cf7..cd083932 100755
--- a/lcm/docker/build_image.sh
+++ b/lcm/docker/build_image.sh
@@ -16,7 +16,7 @@ if [ $HTTPS_PROXY ]; then
fi
function build_vnflcm {
- docker build ${PROXY_ARGS} --build-arg MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD} -t ${ORG}/${PROJECT}/${IMAGE}:${VERSION} -t ${ORG}/${PROJECT}/${IMAGE}:latest .
+ docker build ${PROXY_ARGS} -t ${ORG}/${PROJECT}/${IMAGE}:${VERSION} -t ${ORG}/${PROJECT}/${IMAGE}:latest .
}
function push_vnflcm {
diff --git a/lcm/docker/docker-entrypoint.sh b/lcm/docker/docker-entrypoint.sh
new file mode 100755
index 00000000..90341e83
--- /dev/null
+++ b/lcm/docker/docker-entrypoint.sh
@@ -0,0 +1,35 @@
+#!/bin/bash
+
+if [ -z "$SERVICE_IP" ]; then
+ export SERVICE_IP=`hostname -i`
+fi
+echo "SERVICE_IP=$SERVICE_IP"
+
+if [ -z "$MYSQL_ROOT_PASSWORD" ]; then
+ export MYSQL_ROOT_PASSWORD="root"
+fi
+echo "MYSQL_ROOT_PASSWORD=$MYSQL_ROOT_PASSWORD"
+
+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"
+
+# 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
+
+# Configure service based on docker environment variables
+./instance-config.sh
+
+# microservice-specific one-time initialization
+./instance-init.sh
+
+date > init.log
+
+# Start the microservice
+./instance-run.sh
diff --git a/lcm/docker/instance_init.sh b/lcm/docker/instance_init.sh
index 03c10a80..f33294db 100755
--- a/lcm/docker/instance_init.sh
+++ b/lcm/docker/instance_init.sh
@@ -9,6 +9,7 @@ function start_redis_server {
}
function start_mysql {
+ su mysql -c /usr/bin/mysqld_safe &
service mysql start
# Wait for mysql to initialize; Set mysql root password
for i in {1..10}; do
@@ -22,23 +23,7 @@ function create_database {
bash initDB.sh root $MYSQL_ROOT_PASSWORD 3306 127.0.0.1
}
-function edit_configs {
- cd /service/vfc/gvnfm/vnflcm/lcm/docker
- bash instance_config.sh
-}
-
-function start_server {
- cd /service/vfc/gvnfm/vnflcm/lcm
- bash run.sh
-}
-
-if [ $MYSQL_ROOT_PASSWORD ]; then
- install_python_libs
- start_redis_server
- start_mysql
- create_database
- edit_configs
- start_server
-else
- echo "MYSQL_ROOT_PASSWORD environment variable not set."
-fi
+install_python_libs
+start_redis_server
+start_mysql
+create_database