Bug 1843: LTS Support

Updates base to Ubuntu 20.04
Updates python to 3.8
Updates pip dependencies to more recent versions
Adds apt cache to stage 2 dockerfile

Fixes bug 1843

Change-Id: Iec7c73cb99f5ed3f0e07666d8c8c8be8ca91c0ea
Signed-off-by: beierlm <mark.beierl@canonical.com>
diff --git a/Dockerfile b/Dockerfile
index 3fad212..c597522 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -21,16 +21,23 @@
 #   devops-stages/stage-build.sh
 #
 
-FROM ubuntu:18.04
+FROM ubuntu:20.04
+
+ARG APT_PROXY
+RUN if [ ! -z $APT_PROXY ] ; then \
+    echo "Acquire::http::Proxy \"$APT_PROXY\";" > /etc/apt/apt.conf.d/proxy.conf ;\
+    echo "Acquire::https::Proxy \"$APT_PROXY\";" >> /etc/apt/apt.conf.d/proxy.conf ;\
+    fi
 
 RUN DEBIAN_FRONTEND=noninteractive apt-get update && \
     DEBIAN_FRONTEND=noninteractive apt-get -y install \
         debhelper \
+        dh-python \
         git \
         python3 \
         python3-all \
         python3-dev \
         python3-setuptools
 
-RUN python3 -m easy_install pip==21.0.1
-RUN pip3 install tox==3.22.0
+RUN python3 -m easy_install pip==21.3.1
+RUN pip install tox==3.24.5
diff --git a/requirements-dev.txt b/requirements-dev.txt
index e5ba877..21f6ba6 100644
--- a/requirements-dev.txt
+++ b/requirements-dev.txt
@@ -1,19 +1,3 @@
-aiokafka==0.7.0
-    # via -r https://osm.etsi.org/gitweb/?p=osm/common.git;a=blob_plain;f=requirements.txt;hb=master
-dataclasses==0.6
-    # via -r https://osm.etsi.org/gitweb/?p=osm/common.git;a=blob_plain;f=requirements.txt;hb=master
-kafka-python==2.0.2
-    # via
-    #   -r https://osm.etsi.org/gitweb/?p=osm/common.git;a=blob_plain;f=requirements.txt;hb=master
-    #   aiokafka
-git+https://osm.etsi.org/gerrit/osm/common.git@master#egg=osm-common
-    # via -r requirements-dev.in
-pycrypto==2.6.1
-    # via -r https://osm.etsi.org/gitweb/?p=osm/common.git;a=blob_plain;f=requirements.txt;hb=master
-pymongo==3.11.3
-    # via -r https://osm.etsi.org/gitweb/?p=osm/common.git;a=blob_plain;f=requirements.txt;hb=master
-pyyaml==5.4.1
-    # via -r https://osm.etsi.org/gitweb/?p=osm/common.git;a=blob_plain;f=requirements.txt;hb=master
 #######################################################################################
 # Copyright ETSI Contributors and Others.
 #
@@ -30,3 +14,19 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 #######################################################################################
+aiokafka==0.7.2
+    # via -r https://osm.etsi.org/gitweb/?p=osm/common.git;a=blob_plain;f=requirements.txt;hb=master
+dataclasses==0.6
+    # via -r https://osm.etsi.org/gitweb/?p=osm/common.git;a=blob_plain;f=requirements.txt;hb=master
+kafka-python==2.0.2
+    # via
+    #   -r https://osm.etsi.org/gitweb/?p=osm/common.git;a=blob_plain;f=requirements.txt;hb=master
+    #   aiokafka
+osm-common @ git+https://osm.etsi.org/gerrit/osm/common.git@master
+    # via -r requirements-dev.in
+pycrypto==2.6.1
+    # via -r https://osm.etsi.org/gitweb/?p=osm/common.git;a=blob_plain;f=requirements.txt;hb=master
+pymongo==3.12.3
+    # via -r https://osm.etsi.org/gitweb/?p=osm/common.git;a=blob_plain;f=requirements.txt;hb=master
+pyyaml==5.4.1
+    # via -r https://osm.etsi.org/gitweb/?p=osm/common.git;a=blob_plain;f=requirements.txt;hb=master
diff --git a/requirements-dist.in b/requirements-dist.in
index 2b3c735..4f8784f 100644
--- a/requirements-dist.in
+++ b/requirements-dist.in
@@ -1,16 +1,18 @@
-# Copyright 2021 Canonical Ltd.
+# Copyright ETSI Contributors and Others.
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
 # You may obtain a copy of the License at
 #
-#     http://www.apache.org/licenses/LICENSE-2.0
+#    http://www.apache.org/licenses/LICENSE-2.0
 #
-#     Unless required by applicable law or agreed to in writing, software
-#     distributed under the License is distributed on an "AS IS" BASIS,
-#     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-#     See the License for the specific language governing permissions and
-#     limitations under the License.
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
 
 stdeb
 setuptools-version-command
+setuptools<60
\ No newline at end of file
diff --git a/requirements-dist.txt b/requirements-dist.txt
index 7393626..8192b48 100644
--- a/requirements-dist.txt
+++ b/requirements-dist.txt
@@ -1,10 +1,3 @@
-setuptools-version-command==2.2
-    # via -r requirements-dist.in
-stdeb==0.10.0
-    # via -r requirements-dist.in
-
-# The following packages are considered to be unsafe in a requirements file:
-# setuptools
 #######################################################################################
 # Copyright ETSI Contributors and Others.
 #
@@ -21,3 +14,13 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 #######################################################################################
+setuptools-version-command==99.9
+    # via -r requirements-dist.in
+stdeb==0.10.0
+    # via -r requirements-dist.in
+
+# The following packages are considered to be unsafe in a requirements file:
+setuptools==59.8.0
+    # via
+    #   -r requirements-dist.in
+    #   setuptools-version-command
diff --git a/requirements-test.txt b/requirements-test.txt
index 7e3a14d..c6718ee 100644
--- a/requirements-test.txt
+++ b/requirements-test.txt
@@ -1,37 +1,3 @@
-asynctest==0.13.0
-    # via -r requirements-test.in
-certifi==2020.12.5
-    # via requests
-chardet==4.0.0
-    # via requests
-coverage==5.5
-    # via
-    #   -r requirements-test.in
-    #   nose2
-flake8==3.9.0
-    # via -r requirements-test.in
-idna==2.10
-    # via requests
-mccabe==0.6.1
-    # via flake8
-mock==4.0.3
-    # via -r requirements-test.in
-nose2==0.10.0
-    # via -r requirements-test.in
-pycodestyle==2.7.0
-    # via flake8
-pyflakes==2.3.1
-    # via flake8
-requests-mock==1.8.0
-    # via -r requirements-test.in
-requests==2.25.1
-    # via requests-mock
-six==1.15.0
-    # via
-    #   nose2
-    #   requests-mock
-urllib3==1.26.4
-    # via requests
 #######################################################################################
 # Copyright ETSI Contributors and Others.
 #
@@ -48,3 +14,37 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 #######################################################################################
+asynctest==0.13.0
+    # via -r requirements-test.in
+certifi==2021.10.8
+    # via requests
+charset-normalizer==2.0.10
+    # via requests
+coverage==6.2
+    # via
+    #   -r requirements-test.in
+    #   nose2
+flake8==4.0.1
+    # via -r requirements-test.in
+idna==3.3
+    # via requests
+mccabe==0.6.1
+    # via flake8
+mock==4.0.3
+    # via -r requirements-test.in
+nose2==0.10.0
+    # via -r requirements-test.in
+pycodestyle==2.8.0
+    # via flake8
+pyflakes==2.4.0
+    # via flake8
+requests==2.27.1
+    # via requests-mock
+requests-mock==1.9.3
+    # via -r requirements-test.in
+six==1.16.0
+    # via
+    #   nose2
+    #   requests-mock
+urllib3==1.26.8
+    # via requests
diff --git a/requirements.in b/requirements.in
index 91e8bf5..ce72c77 100644
--- a/requirements.in
+++ b/requirements.in
@@ -12,8 +12,10 @@
 #     See the License for the specific language governing permissions and
 #     limitations under the License.
 
-juju
+async-timeout<4
+juju==2.9.4
 kubernetes
-pyasn1
 motor==1.3.1
+pyasn1
+pyyaml<6
 retrying-async
diff --git a/requirements.txt b/requirements.txt
index 7ff786a..c4aaea6 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,120 +1,3 @@
-async-timeout==3.0.1
-    # via retrying-async
-bcrypt==3.2.0
-    # via paramiko
-cachetools==4.2.1
-    # via google-auth
-certifi==2020.12.5
-    # via
-    #   kubernetes
-    #   requests
-cffi==1.14.5
-    # via
-    #   bcrypt
-    #   cryptography
-    #   pynacl
-chardet==4.0.0
-    # via requests
-cryptography==3.4.7
-    # via paramiko
-google-auth==1.28.0
-    # via kubernetes
-idna==2.10
-    # via requests
-juju==2.9.4
-    # via -r requirements.in
-jujubundlelib==0.5.6
-    # via theblues
-kubernetes==17.17.0
-    # via -r requirements.in
-macaroonbakery==1.3.1
-    # via
-    #   juju
-    #   theblues
-motor==1.3.1
-    # via -r requirements.in
-mypy-extensions==0.4.3
-    # via typing-inspect
-oauthlib==3.1.0
-    # via requests-oauthlib
-paramiko==2.7.2
-    # via juju
-protobuf==3.15.6
-    # via macaroonbakery
-pyasn1-modules==0.2.8
-    # via google-auth
-pyasn1==0.4.8
-    # via
-    #   -r requirements.in
-    #   juju
-    #   pyasn1-modules
-    #   rsa
-pycparser==2.20
-    # via cffi
-pymacaroons==0.13.0
-    # via macaroonbakery
-pymongo==3.11.3
-    # via motor
-pynacl==1.4.0
-    # via
-    #   macaroonbakery
-    #   paramiko
-    #   pymacaroons
-pyrfc3339==1.1
-    # via
-    #   juju
-    #   macaroonbakery
-python-dateutil==2.8.1
-    # via kubernetes
-pytz==2021.1
-    # via pyrfc3339
-pyyaml==5.4.1
-    # via
-    #   juju
-    #   jujubundlelib
-    #   kubernetes
-requests-oauthlib==1.3.0
-    # via kubernetes
-requests==2.25.1
-    # via
-    #   kubernetes
-    #   macaroonbakery
-    #   requests-oauthlib
-    #   theblues
-retrying-async==1.2.0
-    # via -r requirements.in
-rsa==4.7.2
-    # via google-auth
-six==1.15.0
-    # via
-    #   bcrypt
-    #   google-auth
-    #   kubernetes
-    #   macaroonbakery
-    #   protobuf
-    #   pymacaroons
-    #   pynacl
-    #   python-dateutil
-    #   websocket-client
-theblues==0.5.2
-    # via juju
-toposort==1.6
-    # via juju
-typing-extensions==3.7.4.3
-    # via typing-inspect
-typing-inspect==0.6.0
-    # via juju
-urllib3==1.26.4
-    # via
-    #   kubernetes
-    #   requests
-websocket-client==0.58.0
-    # via kubernetes
-websockets==7.0
-    # via juju
-
-# The following packages are considered to be unsafe in a requirements file:
-# setuptools
 #######################################################################################
 # Copyright ETSI Contributors and Others.
 #
@@ -131,3 +14,122 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 #######################################################################################
+async-timeout==3.0.1
+    # via
+    #   -r requirements.in
+    #   retrying-async
+bcrypt==3.2.0
+    # via paramiko
+cachetools==4.2.4
+    # via google-auth
+certifi==2021.10.8
+    # via
+    #   kubernetes
+    #   requests
+cffi==1.15.0
+    # via
+    #   bcrypt
+    #   cryptography
+    #   pynacl
+charset-normalizer==2.0.10
+    # via requests
+cryptography==36.0.1
+    # via paramiko
+google-auth==2.3.3
+    # via kubernetes
+idna==3.3
+    # via requests
+juju==2.9.4
+    # via -r requirements.in
+jujubundlelib==0.5.7
+    # via theblues
+kubernetes==21.7.0
+    # via
+    #   -r requirements.in
+    #   juju
+macaroonbakery==1.3.1
+    # via
+    #   juju
+    #   theblues
+motor==1.3.1
+    # via -r requirements.in
+mypy-extensions==0.4.3
+    # via typing-inspect
+oauthlib==3.1.1
+    # via requests-oauthlib
+paramiko==2.9.2
+    # via juju
+protobuf==3.19.3
+    # via macaroonbakery
+pyasn1==0.4.8
+    # via
+    #   -r requirements.in
+    #   juju
+    #   pyasn1-modules
+    #   rsa
+pyasn1-modules==0.2.8
+    # via google-auth
+pycparser==2.21
+    # via cffi
+pymacaroons==0.13.0
+    # via macaroonbakery
+pymongo==3.12.3
+    # via motor
+pynacl==1.5.0
+    # via
+    #   macaroonbakery
+    #   paramiko
+    #   pymacaroons
+pyrfc3339==1.1
+    # via
+    #   juju
+    #   macaroonbakery
+python-dateutil==2.8.2
+    # via kubernetes
+pytz==2021.3
+    # via pyrfc3339
+pyyaml==5.4.1
+    # via
+    #   -r requirements.in
+    #   juju
+    #   jujubundlelib
+    #   kubernetes
+requests==2.27.1
+    # via
+    #   kubernetes
+    #   macaroonbakery
+    #   requests-oauthlib
+    #   theblues
+requests-oauthlib==1.3.0
+    # via kubernetes
+retrying-async==1.2.0
+    # via -r requirements.in
+rsa==4.8
+    # via google-auth
+six==1.16.0
+    # via
+    #   bcrypt
+    #   google-auth
+    #   kubernetes
+    #   macaroonbakery
+    #   pymacaroons
+    #   python-dateutil
+theblues==0.5.2
+    # via juju
+toposort==1.7
+    # via juju
+typing-extensions==4.0.1
+    # via typing-inspect
+typing-inspect==0.7.1
+    # via juju
+urllib3==1.26.8
+    # via
+    #   kubernetes
+    #   requests
+websocket-client==1.2.3
+    # via kubernetes
+websockets==7.0
+    # via juju
+
+# The following packages are considered to be unsafe in a requirements file:
+# setuptools
diff --git a/tox.ini b/tox.ini
index bf31bce..5aaf2a4 100644
--- a/tox.ini
+++ b/tox.ini
@@ -23,7 +23,7 @@
 
 [testenv]
 usedevelop = True
-basepython = python3
+basepython = python3.8
 setenv = VIRTUAL_ENV={envdir}
          PYTHONDONTWRITEBYTECODE = 1
 deps =  -r{toxinidir}/requirements.txt
@@ -83,13 +83,18 @@
 
 #######################################################################################
 [testenv:pip-compile]
-deps =  pip-tools==5.5.0
+deps =  pip-tools==6.4.0
+skip_install = true
+whitelist_externals = bash
+        [
 commands =
-        - sh -c 'for file in requirements*.in ; do pip-compile -rU --no-header $file ;\
-        out=`echo $file | sed "s/.in/.txt/"` ; \
-        head -16 tox.ini >> $out ;\
-        done'
-whitelist_externals = sh
+        - bash -c "for file in requirements*.in ; do \
+        UNSAFE="" ; \
+        if [[ $file =~ 'dist' ]] ; then UNSAFE='--allow-unsafe' ; fi ; \
+        pip-compile -rU --no-header $UNSAFE $file ;\
+        out=`echo $file | sed 's/.in/.txt/'` ; \
+        sed -i -e '1 e head -16 tox.ini' $out ;\
+        done"
 
 
 #######################################################################################