From ba0360a186eef654f824e20db2abba82e1d88f29 Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Wed, 4 Mar 2020 11:30:16 -0800 Subject: [PATCH 1/4] Move LABEL and ENV to bottom Having them close to the bottom allow us to share most of the layer from the Docker images even after a Python version was updated --- Dockerfile | 56 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 31 insertions(+), 25 deletions(-) diff --git a/Dockerfile b/Dockerfile index da460a9..1558cc7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,31 +7,6 @@ ENV DEBIAN_FRONTEND noninteractive ENV APPDIR /app ENV LANG C.UTF-8 -# Versions, and expose labels for external usage -ENV PYTHON_VERSION_27 2.7.16 -ENV PYTHON_VERSION_35 3.5.7 -ENV PYTHON_VERSION_36 3.6.8 -ENV PYTHON_VERSION_37 3.7.3 -ENV PYTHON_VERSION_38 3.8.0 -ENV PYPY_VERSION_35 pypy3.5-7.0.0 - -# Note: 4.7.12.1 drastically increases memory usage -ENV CONDA_VERSION 4.6.14 - -# Use _PIP_VERSION (with starting _) because of a bug in Pip -# https://github.com/pypa/pip/issues/4528 -ENV _PIP_VERSION 20.0.1 - -ENV SETUPTOOLS_VERSION 45.1.0 -ENV VIRTUALENV_VERSION 16.7.9 -LABEL python.version_27=$PYTHON_VERSION_27 -LABEL python.version_35=$PYTHON_VERSION_35 -LABEL python.version_36=$PYTHON_VERSION_36 -LABEL python.version_37=$PYTHON_VERSION_37 -LABEL python.version_38=$PYTHON_VERSION_38 -LABEL pypy.version_35=$PYPY_VERSION_35 -LABEL conda.version=$CONDA_VERSION - # System dependencies RUN apt-get -y update RUN apt-get -y install \ @@ -140,6 +115,7 @@ RUN apt-get -y install \ swig # Install Python tools/libs +ENV VIRTUALENV_VERSION 16.7.9 RUN apt-get -y install \ python-pip \ && pip install -U \ @@ -162,6 +138,8 @@ USER docs WORKDIR /home/docs # Install Conda +# Note: 4.7.12.1 drastically increases memory usage +ENV CONDA_VERSION 4.6.14 RUN curl -O https://repo.continuum.io/miniconda/Miniconda2-${CONDA_VERSION}-Linux-x86_64.sh RUN bash Miniconda2-${CONDA_VERSION}-Linux-x86_64.sh -b -p /home/docs/.conda/ ENV PATH $PATH:/home/docs/.conda/bin @@ -175,6 +153,14 @@ RUN unzip master.zip && \ ENV PYENV_ROOT /home/docs/.pyenv ENV PATH /home/docs/.pyenv/shims:$PATH:/home/docs/.pyenv/bin +# Define Python versions to be installed via pyenv +ENV PYTHON_VERSION_27 2.7.16 +ENV PYTHON_VERSION_35 3.5.7 +ENV PYTHON_VERSION_36 3.6.8 +ENV PYTHON_VERSION_37 3.7.3 +ENV PYTHON_VERSION_38 3.8.0 +ENV PYPY_VERSION_35 pypy3.5-7.0.0 + # Install supported Python versions RUN pyenv install $PYTHON_VERSION_27 && \ pyenv install $PYTHON_VERSION_38 && \ @@ -192,12 +178,20 @@ RUN pyenv install $PYTHON_VERSION_27 && \ WORKDIR /tmp +# Python2 dependencies are hardcoded because Python2 is +# deprecated. Updating them to their latest versions may raise +# incompatibility issues. RUN pyenv local $PYTHON_VERSION_27 && \ pyenv exec pip install --no-cache-dir -U pip==20.0.1 && \ pyenv exec pip install --no-cache-dir -U setuptools==44.0.0 && \ pyenv exec pip install --no-cache-dir --only-binary numpy,scipy numpy scipy && \ pyenv exec pip install --no-cache-dir pandas matplotlib virtualenv==16.7.9 +# Use _PIP_VERSION (with starting _) because of a bug in Pip +# https://github.com/pypa/pip/issues/4528 +ENV _PIP_VERSION 20.0.1 + +ENV SETUPTOOLS_VERSION 45.1.0 RUN pyenv local $PYTHON_VERSION_38 && \ pyenv exec pip install --no-cache-dir -U pip==$_PIP_VERSION && \ pyenv exec pip install --no-cache-dir -U setuptools==$SETUPTOOLS_VERSION && \ @@ -230,4 +224,16 @@ RUN pyenv local $PYPY_VERSION_35 && \ WORKDIR / +# Adding labels for external usage +LABEL python.version_27=$PYTHON_VERSION_27 +LABEL python.version_35=$PYTHON_VERSION_35 +LABEL python.version_36=$PYTHON_VERSION_36 +LABEL python.version_37=$PYTHON_VERSION_37 +LABEL python.version_38=$PYTHON_VERSION_38 +LABEL python.pip=$_PIP_VERSION +LABEL python.setuptools=$SETUPTOOLS_VERSION +LABEL python.virtualenv=$VIRTUALENV_VERSION +LABEL pypy.version_35=$PYPY_VERSION_35 +LABEL conda.version=$CONDA_VERSION + CMD ["/bin/bash"] From c0c81dda1575f65e04c591b7a1cf04b54e3bb92f Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Wed, 4 Mar 2020 11:33:32 -0800 Subject: [PATCH 2/4] Move conda installation closest to the bottom Conda has been doing the package we updated the most in the last months. So, it may be good to have it the closest to the bottom as possible. --- Dockerfile | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index 1558cc7..ec17b12 100644 --- a/Dockerfile +++ b/Dockerfile @@ -137,14 +137,6 @@ RUN useradd -m --uid 1005 --gid 205 docs USER docs WORKDIR /home/docs -# Install Conda -# Note: 4.7.12.1 drastically increases memory usage -ENV CONDA_VERSION 4.6.14 -RUN curl -O https://repo.continuum.io/miniconda/Miniconda2-${CONDA_VERSION}-Linux-x86_64.sh -RUN bash Miniconda2-${CONDA_VERSION}-Linux-x86_64.sh -b -p /home/docs/.conda/ -ENV PATH $PATH:/home/docs/.conda/bin -RUN rm -f Miniconda2-${CONDA_VERSION}-Linux-x86_64.sh - # Install pyenv RUN wget https://github.com/pyenv/pyenv/archive/master.zip RUN unzip master.zip && \ @@ -222,6 +214,17 @@ RUN pyenv local $PYPY_VERSION_35 && \ pyenv exec pip install --no-cache-dir -U setuptools==$SETUPTOOLS_VERSION && \ pyenv exec pip install --no-cache-dir virtualenv==$VIRTUALENV_VERSION + +# Install Conda +WORKDIR /home/docs +# Note: 4.7.12.1 drastically increases memory usage +ENV CONDA_VERSION 4.6.14 +RUN curl -O https://repo.continuum.io/miniconda/Miniconda2-${CONDA_VERSION}-Linux-x86_64.sh +RUN bash Miniconda2-${CONDA_VERSION}-Linux-x86_64.sh -b -p /home/docs/.conda/ +ENV PATH $PATH:/home/docs/.conda/bin +RUN rm -f Miniconda2-${CONDA_VERSION}-Linux-x86_64.sh + + WORKDIR / # Adding labels for external usage From 8df342fed2c2a3747ea2f87a401dd4d8f6aaf96f Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Wed, 4 Mar 2020 14:11:42 -0800 Subject: [PATCH 3/4] Suppress no test ran exit code when running 0 tests --- .travis.yml | 2 +- Pipfile | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3d37267..34a2d4d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,7 +10,7 @@ before_install: install: - pipenv install script: - - pipenv run pytest + - pipenv run pytest --suppress-no-test-exit-code - docker build . branches: diff --git a/Pipfile b/Pipfile index f9273b9..473475e 100644 --- a/Pipfile +++ b/Pipfile @@ -9,4 +9,5 @@ name = "pypi" "dockerfile-parse" = "*" requests = "*" -pytest = "*" \ No newline at end of file +pytest = "*" +pytest-custom-exit-code = "*" From 087cd755b92fe34b76f22f362c91efda9622c79e Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Thu, 30 Apr 2020 13:06:20 +0200 Subject: [PATCH 4/4] Merge conflict fixed --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 9307b32..2b1a8f1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -180,7 +180,7 @@ RUN pyenv local $RTD_PYTHON_VERSION_27 && \ ENV RTD_PIP_VERSION 20.0.1 ENV RTD_SETUPTOOLS_VERSION 45.1.0 -RUN pyenv local $PYTHON_VERSION_38 && \ +RUN pyenv local $RTD_PYTHON_VERSION_38 && \ pyenv exec pip install --no-cache-dir -U pip==$RTD_PIP_VERSION && \ pyenv exec pip install --no-cache-dir -U setuptools==$RTD_SETUPTOOLS_VERSION && \ pyenv exec pip install --no-cache-dir --only-binary numpy numpy && \