From 5904b43ca433cd9bd8574f880f15482f367d2d87 Mon Sep 17 00:00:00 2001
From: Michal Kolodziejski <michal.kolodziejski@cern.ch>
Date: Wed, 25 Nov 2020 15:37:23 +0100
Subject: [PATCH] Use virtualenv

---
 Dockerfile | 12 ++++++------
 assemble   |  7 ++-----
 2 files changed, 8 insertions(+), 11 deletions(-)

diff --git a/Dockerfile b/Dockerfile
index ab220e3..97a4fd8 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -11,7 +11,7 @@ and configured with a single YAML configuration file." \
     # <https://click.palletsprojects.com/en/7.x/python3/>.
     LC_ALL="en_US.utf-8" \
     LANG="en_US.utf-8" \
-    PYTHONPATH="$PYTHONPATH:/opt/app-root/lib/python3.6/site-packages:/opt/app-root/lib64/python3.6/site-packages"
+    VIRTUAL_ENV="/opt/app-root/venv"
 
 LABEL maintainer="CERN Authoring <authoring@cern.ch>" \
       summary="${SUMMARY}" \
@@ -31,8 +31,7 @@ USER root
 # as well as the specified version of MkDocs and the Material theme.
 # Install VCS tools to support https://pip.readthedocs.io/en/1.1/requirements.html#requirements-file-format
 RUN yum install -y rh-python36-python-pip git svn && \
-    yum clean all && \
-    /opt/rh/rh-python36/root/usr/bin/pip install --cache-dir /root --upgrade pip setuptools wheel
+    yum clean all
 
 # Move the original assemble script to another file
 # and copy our custom assemble script.
@@ -42,6 +41,7 @@ COPY assemble /usr/libexec/s2i/
 # Switch back to the default user.
 USER 1001
 
-RUN /opt/rh/rh-python36/root/bin/pip install --cache-dir /opt/app-root/.cache --prefix /opt/app-root \
-    mkdocs==${MKDOCS_VERSION} \
-    mkdocs-material==${MATERIAL_VERSION}
+RUN /opt/rh/rh-python36/root/bin/python -m venv $VIRTUAL_ENV
+ENV PATH="$VIRTUAL_ENV/bin:$PATH"
+RUN pip install --upgrade pip setuptools wheel && \
+    pip install mkdocs==${MKDOCS_VERSION} mkdocs-material==${MATERIAL_VERSION}
diff --git a/assemble b/assemble
index 4d3ac68..cd28bfb 100755
--- a/assemble
+++ b/assemble
@@ -14,15 +14,12 @@ cd /tmp/src-original/
 # Install custom Python dependencies.
 if [ -f ./requirements.txt ]; then
   echo "---> Installing custom Python dependencies..."
-  /opt/rh/rh-python36/root/bin/pip install \
-    --cache-dir /opt/app-root/.cache \
-    --prefix /opt/app-root \
-    -r requirements.txt
+  pip install -r requirements.txt
 fi
 
 # Build the MkDocs static site in the standard directory.
 echo "---> Building the MkDocs static site..."
-/opt/app-root/bin/mkdocs build --clean --site-dir /tmp/src/
+mkdocs build --clean --site-dir /tmp/src/
 
 # Move the Nginx-related files back to the standard directory.
 if [ -f ./nginx.conf ]; then
-- 
GitLab