diff options
Diffstat (limited to 'docker')
-rwxr-xr-x | docker/Dockerfile | 7 | ||||
-rwxr-xr-x | docker/build_image.sh | 2 | ||||
-rwxr-xr-x | docker/docker-entrypoint.sh | 35 | ||||
-rwxr-xr-x | docker/instance_init.sh | 25 |
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 |