Improve Dockerfile 55/67255/3
authorStamatis Katsaounis <mokats@intracom-telecom.com>
Thu, 14 Mar 2019 13:00:05 +0000 (15:00 +0200)
committerStamatis Katsaounis <mokats@intracom-telecom.com>
Wed, 20 Mar 2019 07:55:37 +0000 (07:55 +0000)
This patch improves the Dockerfile which produces the Dovetail image.

Change-Id: I65e65f155afe237b11c668e6486e48b55cc7e96c
Signed-off-by: Stamatis Katsaounis <mokats@intracom-telecom.com>
docker/Dockerfile
dovetail/run.py
dovetail/tests/unit/test_run.py

index c5239db..15c0a4f 100644 (file)
@@ -1,5 +1,5 @@
-FROM ubuntu:14.04
-MAINTAINER Leo Wang <grakiss.wanglei@huawei.com>
+FROM ubuntu:18.04
+MAINTAINER Stamatis Katsaounis <mokats@intracom-telecom.com>
 LABEL version="0.1" description="OPNFV Dovetail Docker Container"
 
 ARG BRANCH=master
@@ -8,41 +8,35 @@ RUN \
     apt-get update \
 && \
     apt-get install -y \
-        build-essential \
         gcc \
+        make \
         git \
         libssl-dev \
         libffi-dev \
         vim \
         python-dev \
-        python-mock \
         python-pip \
-        apt-transport-https \
-        wget \
         --no-install-recommends \
 && \
-    apt-get update
+    rm -rf /var/lib/apt/lists/*
 
-RUN easy_install -U setuptools==30.0.0
-
-RUN wget -qO- https://get.docker.com/ \
-| \
-    sed 's/-q docker-ce/-q docker-ce=17.03.0~ce-0~ubuntu-trusty/' \
-| \
-    sed 's/edge/stable/' \
-| \
-    sh
+RUN pip install -U setuptools wheel
 
 ENV HOME /home/opnfv
 ENV REPOS_DIR ${HOME}/dovetail
-WORKDIR /home/opnfv
+WORKDIR $HOME
 
 RUN \
     mkdir -p ${REPOS_DIR} \
 && \
-    git config --global http.sslVerify false \
+    git init /tmp/dovetail \
+&& \
+    (cd /tmp/dovetail && \
+        git fetch --tags https://gerrit.opnfv.org/gerrit/dovetail $BRANCH && \
+        git checkout FETCH_HEAD && \
+        pip install .) \
 && \
-    pip install git+https://git.opnfv.org/dovetail@$BRANCH#egg=dovetail \
+    rm -rf /tmp/dovetail \
 && \
     ln -s /usr/local/lib/python2.7/dist-packages/dovetail ${REPOS_DIR}/dovetail
 
index f538b86..71a6968 100755 (executable)
@@ -128,7 +128,7 @@ def clean_results_dir():
     result_path = dt_cfg.dovetail_config['result_dir']
     if os.path.exists(result_path):
         if os.path.isdir(result_path):
-            cmd = 'sudo rm -rf %s/*' % (result_path)
+            cmd = 'rm -rf %s/*' % (result_path)
             dt_utils.exec_cmd(cmd, exit_on_error=False, exec_msg_on=False)
         else:
             print('result_dir in dovetail_config.yml is not a directory.')
@@ -160,7 +160,7 @@ def copy_userconfig_files(logger):
     userconfig_path = dt_cfg.dovetail_config['userconfig_dir']
     if not os.path.isdir(userconfig_path):
         os.makedirs(userconfig_path)
-    cmd = 'sudo cp -r %s/* %s' % (constants.USERCONF_PATH, userconfig_path)
+    cmd = 'cp -r %s/* %s' % (constants.USERCONF_PATH, userconfig_path)
     dt_utils.exec_cmd(cmd, logger, exit_on_error=False)
 
 
@@ -168,7 +168,7 @@ def copy_patch_files(logger):
     patch_set_path = dt_cfg.dovetail_config['patch_dir']
     if not os.path.isdir(patch_set_path):
         os.makedirs(patch_set_path)
-    cmd = 'sudo cp -a -r %s/* %s' % (constants.PATCH_PATH, patch_set_path)
+    cmd = 'cp -a -r %s/* %s' % (constants.PATCH_PATH, patch_set_path)
     dt_utils.exec_cmd(cmd, logger, exit_on_error=False)
 
 
index 80b5eca..7f36d31 100644 (file)
@@ -233,7 +233,7 @@ class RunTesting(unittest.TestCase):
         mock_os.path.exists.assert_called_once_with('value')
         mock_os.path.isdir.assert_called_once_with('value')
         mock_utils.exec_cmd.assert_called_once_with(
-            'sudo rm -rf value/*', exit_on_error=False, exec_msg_on=False)
+            'rm -rf value/*', exit_on_error=False, exec_msg_on=False)
 
     @patch('dovetail.run.dt_utils')
     @patch('dovetail.run.dt_cfg')
@@ -302,7 +302,7 @@ class RunTesting(unittest.TestCase):
         mock_os.path.isdir.assert_called_once_with('value')
         mock_os.makedirs.assert_called_once_with('value')
         mock_utils.exec_cmd.assert_called_once_with(
-            'sudo cp -r value/* value', logger, exit_on_error=False)
+            'cp -r value/* value', logger, exit_on_error=False)
 
     @patch('dovetail.run.constants')
     @patch('dovetail.run.dt_cfg')
@@ -320,7 +320,7 @@ class RunTesting(unittest.TestCase):
         mock_os.path.isdir.assert_called_once_with('value')
         mock_os.makedirs.assert_called_once_with('value')
         mock_utils.exec_cmd.assert_called_once_with(
-            'sudo cp -a -r value/* value', logger, exit_on_error=False)
+            'cp -a -r value/* value', logger, exit_on_error=False)
 
     @patch('dovetail.run.os')
     def test_update_deploy_scenario(self, mock_os):