summaryrefslogtreecommitdiffstats
path: root/mgr/docker
diff options
context:
space:
mode:
authorfujinhua <fu.jinhua@zte.com.cn>2018-08-08 16:10:48 +0800
committerfujinhua <fu.jinhua@zte.com.cn>2018-08-08 16:10:48 +0800
commitab32ab75c8d721fb1479a3c70fb787b6f224445b (patch)
tree30160c45a926b573dc0dc690556f2e93755676ce /mgr/docker
parent3ac879dd15908f592e37f2adc445eda4b4f54eaf (diff)
Remove DB and redis service from vnfmgr
Change-Id: I122f239cf4ab59cf5dd65f7fdebd367eebb8b548 Issue-ID: VFC-981 Signed-off-by: fujinhua <fu.jinhua@zte.com.cn>
Diffstat (limited to 'mgr/docker')
-rw-r--r--mgr/docker/Dockerfile18
-rwxr-xr-xmgr/docker/docker-entrypoint.sh18
-rwxr-xr-xmgr/docker/instance_config.sh22
-rwxr-xr-xmgr/docker/instance_init.sh23
4 files changed, 19 insertions, 62 deletions
diff --git a/mgr/docker/Dockerfile b/mgr/docker/Dockerfile
index d02977d..16302fe 100644
--- a/mgr/docker/Dockerfile
+++ b/mgr/docker/Dockerfile
@@ -6,9 +6,6 @@ ARG HTTPS_PROXY=${HTTPS_PROXY}
ENV http_proxy $HTTP_PROXY
ENV https_proxy $HTTPS_PROXY
-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 sed -i "s|set compatible|set nocompatible|" /etc/vim/vimrc.tiny
RUN echo "set backspace=2" >> /etc/vim/vimrc.tiny
@@ -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,23 +32,10 @@ RUN wget -q -O vfc-gvnfm-vnfmgr.zip 'https://nexus.onap.org/service/local/artifa
unzip vfc-gvnfm-vnfmgr.zip && \
rm -rf vfc-gvnfm-vnfmgr.zip
-# get db scripts from nexus
-RUN wget -q -O vfc-gvnfm-vnfres-res.zip 'https://nexus.onap.org/service/local/artifact/maven/redirect?r=snapshots&g=org.onap.vfc.gvnfm.vnfres.res&a=vfc-gvnfm-vnfres-res&v=LATEST&e=zip' && \
- unzip vfc-gvnfm-vnfres-res.zip vfc/gvnfm/vnfres/res/assembly/*.* && \
- mv ./vfc/gvnfm/vnfres/res/assembly/bin ./bin && \
- mv ./vfc/gvnfm/vnfres/res/assembly/dbscripts ./dbscripts && \
- rm -rf vfc-gvnfm-vnfres-res.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/vnfmgr/mgr
RUN pip install -r requirements.txt
EXPOSE 8803
-EXPOSE 3306
-EXPOSE 6379
WORKDIR /service
ENTRYPOINT vfc/gvnfm/vnfmgr/mgr/docker/docker-entrypoint.sh
diff --git a/mgr/docker/docker-entrypoint.sh b/mgr/docker/docker-entrypoint.sh
index 9d8b0cf..ecdd938 100755
--- a/mgr/docker/docker-entrypoint.sh
+++ b/mgr/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/vnfmgr/mgr/docker/instance_config.sh
diff --git a/mgr/docker/instance_config.sh b/mgr/docker/instance_config.sh
index 02e88c6..7952892 100755
--- a/mgr/docker/instance_config.sh
+++ b/mgr/docker/instance_config.sh
@@ -15,25 +15,13 @@ if [ $SERVICE_IP ]; then
sed -i "s|\"ip\": \".*\"|\"ip\": \"$SERVICE_IP\"|" vfc/gvnfm/vnfmgr/mgr/mgr/pub/config/config.py
fi
-if [ $REDIS_HOST ]; then
- sed -i "s|REDIS_HOST.*|REDIS_HOST = '$REDIS_HOST'|" vfc/gvnfm/vnfmgr/mgr/mgr/pub/config/config.py
-fi
-
-sed -i "s|DB_NAME.*|DB_NAME = 'gvnfm'|" vfc/gvnfm/vnfmgr/mgr/mgr/pub/config/config.py
-sed -i "s|DB_USER.*|DB_USER = 'gvnfm'|" vfc/gvnfm/vnfmgr/mgr/mgr/pub/config/config.py
-sed -i "s|DB_PASSWD.*|DB_PASSWD = 'gvnfm'|" vfc/gvnfm/vnfmgr/mgr/mgr/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/vnfmgr/mgr/mgr/pub/config/config.py
sed -i "s|DB_PORT.*|DB_PORT = $MYSQL_PORT|" vfc/gvnfm/vnfmgr/mgr/mgr/pub/config/config.py
+sed -i "s|REDIS_HOST.*|REDIS_HOST = '$MYSQL_IP'|" vfc/gvnfm/vnfmgr/mgr/mgr/pub/config/config.py
-cat vfc/gvnfm/vnfmgr/mgr/mgr/pub/config/config.py \ No newline at end of file
+cat vfc/gvnfm/vnfmgr/mgr/mgr/pub/config/config.py
diff --git a/mgr/docker/instance_init.sh b/mgr/docker/instance_init.sh
index 2764a07..cfc9b0d 100755
--- a/mgr/docker/instance_init.sh
+++ b/mgr/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/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."