diff options
author | 2018-08-08 16:00:50 +0800 | |
---|---|---|
committer | 2018-08-08 16:00:50 +0800 | |
commit | 3b75ae19a25647785c81c02129bf12e0ed54e043 (patch) | |
tree | c9787d8d0437d35a20b1a5c12aba81c0c80530b9 /res/docker | |
parent | 278369e5fa6a7585df69af444c518503aa603740 (diff) |
Remove DB and redis service from vnfres
Change-Id: If3b274d442bdde62a225c5fe02116af4f38a0509
Issue-ID: VFC-980
Signed-off-by: fujinhua <fu.jinhua@zte.com.cn>
Diffstat (limited to 'res/docker')
-rw-r--r-- | res/docker/Dockerfile | 11 | ||||
-rwxr-xr-x | res/docker/docker-entrypoint.sh | 18 | ||||
-rwxr-xr-x | res/docker/instance_config.sh | 20 | ||||
-rwxr-xr-x | res/docker/instance_init.sh | 23 |
4 files changed, 18 insertions, 54 deletions
diff --git a/res/docker/Dockerfile b/res/docker/Dockerfile index b3c3a25..d81d196 100644 --- a/res/docker/Dockerfile +++ b/res/docker/Dockerfile @@ -9,9 +9,6 @@ ENV https_proxy $HTTPS_PROXY RUN sed -i "s|set compatible|set nocompatible|" /etc/vim/vimrc.tiny RUN echo "set backspace=2" >> /etc/vim/vimrc.tiny -RUN echo "mysql-server mysql-server/root_password password root" | debconf-set-selections -RUN echo "mysql-server mysql-server/root_password_again password root" | debconf-set-selections - RUN apt-get update && \ apt-get install -y python-virtualenv && \ apt-get install -y python-setuptools && \ @@ -19,8 +16,6 @@ RUN apt-get update && \ apt-get install -y python-pip && \ apt-get install -y gcc && \ apt-get install -y libmysqlclient-dev && \ - apt-get install -y redis-server && \ - apt-get install -y mysql-server && \ apt-get install -y mysql-client && \ apt-get install -y wget && \ apt-get install -y unzip && \ @@ -37,16 +32,10 @@ RUN wget -q -O vfc-gvnfm-vnfres.zip 'https://nexus.onap.org/service/local/artifa unzip vfc-gvnfm-vnfres.zip && \ rm -rf vfc-gvnfm-vnfres.zip -RUN sed -i "s|bind-address.*|# bind-address = 127.0.0.1|" /etc/mysql/my.cnf - -VOLUME /var/lib/mysql - WORKDIR /service/vfc/gvnfm/vnfres/res RUN pip install -r requirements.txt EXPOSE 8802 -EXPOSE 3306 -EXPOSE 6379 WORKDIR /service ENTRYPOINT vfc/gvnfm/vnfres/res/docker/docker-entrypoint.sh diff --git a/res/docker/docker-entrypoint.sh b/res/docker/docker-entrypoint.sh index 214ae15..a4caa72 100755 --- a/res/docker/docker-entrypoint.sh +++ b/res/docker/docker-entrypoint.sh @@ -5,17 +5,18 @@ if [ -z "$SERVICE_IP" ]; then 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" +if [ -z "$MYSQL_ADDR" ]; then + echo "Missing required variable MYSQL_ADDR: <ip>:<port>" + exit 1 +fi +echo "MYSQL_ADDR=$MYSQL_ADDR" + # Wait for MSB initialization echo "Wait for MSB initialization" for i in {1..5}; do @@ -23,6 +24,13 @@ for i in {1..5}; do sleep $i done +# Wait for DB initialization +echo "Wait for DB initialization" +for i in {1..5}; do + curl -sS -m 1 $MYSQL_ADDR > /dev/null && break + sleep $i +done + # Configure service based on docker environment variables vfc/gvnfm/vnfres/res/docker/instance_config.sh diff --git a/res/docker/instance_config.sh b/res/docker/instance_config.sh index edf1beb..d6eedbd 100755 --- a/res/docker/instance_config.sh +++ b/res/docker/instance_config.sh @@ -15,25 +15,13 @@ if [ $SERVICE_IP ]; then sed -i "s|\"ip\": \".*\"|\"ip\": \"$SERVICE_IP\"|" vfc/gvnfm/vnfres/res/res/pub/config/config.py fi -if [ $REDIS_HOST ]; then - sed -i "s|REDIS_HOST.*|REDIS_HOST = '$REDIS_HOST'|" vfc/gvnfm/vnfres/res/res/pub/config/config.py -fi - -sed -i "s|DB_NAME.*|DB_NAME = 'gvnfm'|" vfc/gvnfm/vnfres/res/res/pub/config/config.py -sed -i "s|DB_USER.*|DB_USER = 'gvnfm'|" vfc/gvnfm/vnfres/res/res/pub/config/config.py -sed -i "s|DB_PASSWD.*|DB_PASSWD = 'gvnfm'|" vfc/gvnfm/vnfres/res/res/pub/config/config.py - # Configure MYSQL -if [ -z "$MYSQL_ADDR" ]; then - export MYSQL_IP=`hostname -i` - export MYSQL_PORT=3306 - export MYSQL_ADDR=$MYSQL_IP:$MYSQL_PORT -else - MYSQL_IP=`echo $MYSQL_ADDR | cut -d: -f 1` - MYSQL_PORT=`echo $MYSQL_ADDR | cut -d: -f 2` -fi +MYSQL_IP=`echo $MYSQL_ADDR | cut -d: -f 1` +MYSQL_PORT=`echo $MYSQL_ADDR | cut -d: -f 2` echo "MYSQL_ADDR=$MYSQL_ADDR" + sed -i "s|DB_IP.*|DB_IP = '$MYSQL_IP'|" vfc/gvnfm/vnfres/res/res/pub/config/config.py sed -i "s|DB_PORT.*|DB_PORT = $MYSQL_PORT|" vfc/gvnfm/vnfres/res/res/pub/config/config.py +sed -i "s|REDIS_HOST.*|REDIS_HOST = '$MYSQL_IP'|" vfc/gvnfm/vnfres/res/res/pub/config/config.py cat vfc/gvnfm/vnfres/res/res/pub/config/config.py diff --git a/res/docker/instance_init.sh b/res/docker/instance_init.sh index 11753d9..cfc9b0d 100755 --- a/res/docker/instance_init.sh +++ b/res/docker/instance_init.sh @@ -1,23 +1,2 @@ #!/bin/bash - -function start_redis_server { - redis-server & -} - -function start_mysql { - service mysql start - sleep 1 -} - -function create_database { - cd /service/vfc/gvnfm/vnfres/res/assembly/bin - if [ ! -f dbexist.txt ]; then - echo 1 > dbexist.txt - bash initDB.sh root $MYSQL_ROOT_PASSWORD 3306 127.0.0.1 - fi - cd /service -} - -start_redis_server -start_mysql -create_database +echo "No service needs init." |