summaryrefslogtreecommitdiffstats
path: root/docker
diff options
context:
space:
mode:
authorfujinhua <fu.jinhua@zte.com.cn>2017-09-01 14:00:05 +0800
committerfujinhua <fu.jinhua@zte.com.cn>2017-09-01 14:00:05 +0800
commitf40578b051e1d230035eb300436b30dd77b41888 (patch)
tree4bb74c489f66d38adce1dbc2a35531baa7d72ae1 /docker
parent8f82bb88330a9db6f27d53a6c822f58338cc7f68 (diff)
Update dockerfile of vfc-nfvo-lcm
Add entrypoint to dockerfile Change-Id: Iaf5f42ccc056062f2031e88437253ee8927eb697 Issue-Id: VFC-225 Signed-off-by: fujinhua <fu.jinhua@zte.com.cn>
Diffstat (limited to 'docker')
-rwxr-xr-xdocker/Dockerfile7
-rwxr-xr-xdocker/build_image.sh2
-rwxr-xr-xdocker/docker-entrypoint.sh35
-rwxr-xr-xdocker/instance_init.sh25
4 files changed, 43 insertions, 26 deletions
diff --git a/docker/Dockerfile b/docker/Dockerfile
index 0b6c42fc..e474e049 100755
--- a/docker/Dockerfile
+++ b/docker/Dockerfile
@@ -2,11 +2,9 @@ FROM ubuntu:14.04
ARG HTTP_PROXY=${HTTP_PROXY}
ARG HTTPS_PROXY=${HTTPS_PROXY}
-ARG MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
ENV http_proxy $HTTP_PROXY
ENV https_proxy $HTTPS_PROXY
-ENV MYSQL_ROOT_PASSWORD $MYSQL_ROOT_PASSWORD
RUN apt-get update && \
apt-get install -y python-devel && \
@@ -37,6 +35,5 @@ RUN wget -q -O vfc-nfvo-lcm.zip 'https://nexus.onap.org/service/local/artifact/m
EXPOSE 8403
EXPOSE 3306
-WORKDIR /
-
-CMD service/vfc/nfvo/lcm/docker/instance_init.sh
+WORKDIR /service
+ENTRYPOINT vfc/nfvo/lcm/docker/docker-entrypoint.sh
diff --git a/docker/build_image.sh b/docker/build_image.sh
index 508f0b41..9fc4879b 100755
--- a/docker/build_image.sh
+++ b/docker/build_image.sh
@@ -16,7 +16,7 @@ if [ $HTTPS_PROXY ]; then
fi
function build_lcm {
- 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_lcm {
diff --git a/docker/docker-entrypoint.sh b/docker/docker-entrypoint.sh
new file mode 100755
index 00000000..90341e83
--- /dev/null
+++ b/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/docker/instance_init.sh b/docker/instance_init.sh
index f880c6bc..c3a3b54e 100755
--- a/docker/instance_init.sh
+++ b/docker/instance_init.sh
@@ -10,6 +10,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
@@ -23,23 +24,7 @@ function create_database {
bash initDB.sh root $MYSQL_ROOT_PASSWORD 3306 127.0.0.1
}
-function edit_configs {
- cd /service/vfc/nfvo/lcm/
- bash docker/instance_config.sh
-}
-
-function start_server {
- cd /service/vfc/nfvo/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