From 9e57908b343f195414da2855a9e834654cea6368 Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Thu, 26 Aug 2021 16:44:23 +0200 Subject: [PATCH] Update image structure based on design doc updates --- Dockerfile.base | 48 +++++++++++++++++++++++---------------------- Dockerfile.conda47 | 23 ++++++---------------- Dockerfile.custom | 36 ---------------------------------- Dockerfile.mamba410 | 14 +++++++++++++ Dockerfile.py27 | 29 +++++++++++++++------------ Dockerfile.py38 | 24 +++++++++++++++++++++++ Dockerfile.py39 | 33 ++++++++++++++----------------- 7 files changed, 100 insertions(+), 107 deletions(-) delete mode 100644 Dockerfile.custom create mode 100644 Dockerfile.mamba410 create mode 100644 Dockerfile.py38 diff --git a/Dockerfile.base b/Dockerfile.base index e652ca6..cbea3e9 100644 --- a/Dockerfile.base +++ b/Dockerfile.base @@ -51,7 +51,6 @@ RUN apt-get -y install \ subversion \ zlib1g-dev - # LaTeX -- split to reduce image layer size RUN apt-get -y install \ texlive-fonts-extra @@ -85,13 +84,14 @@ RUN apt-get -y install \ fonts-hanazono \ xindy -# pyenv extra requirements -# https://github.com/pyenv/pyenv/wiki/Common-build-problems +# asdf Python extra requirements +# https://github.com/pyenv/pyenv/wiki#suggested-build-environment RUN apt-get install -y \ liblzma-dev \ libncurses5-dev \ libncursesw5-dev \ libssl-dev \ + libxmlsec1-dev \ llvm \ make \ python-openssl \ @@ -99,6 +99,17 @@ RUN apt-get install -y \ wget \ xz-utils +# asdf nodejs extra requirements +# https://github.com/asdf-vm/asdf-nodejs#linux-debian +RUN apt install -y \ + dirmngr \ + gpg + +# asdf Golang extra requirements +# https://github.com/kennyp/asdf-golang#linux-debian +RUN apt install -y \ + coreutils + # UID and GID from readthedocs/user RUN groupadd --gid 205 docs RUN useradd -m --uid 1005 --gid 205 docs @@ -106,27 +117,18 @@ RUN useradd -m --uid 1005 --gid 205 docs USER docs WORKDIR /home/docs -# Install pyenv -RUN wget https://github.com/pyenv/pyenv/archive/master.zip && \ - unzip master.zip && \ - rm -f master.zip && \ - mv pyenv-master ~docs/.pyenv -ENV PYENV_ROOT /home/docs/.pyenv -ENV PATH /home/docs/.pyenv/shims:$PATH:/home/docs/.pyenv/bin +# Install asdf +RUN git clone https://github.com/asdf-vm/asdf.git ~/.asdf --depth 1 --branch v0.8.1 +RUN echo ". /home/docs/.asdf/asdf.sh" >> ~/.bashrc +RUN echo ". /home/docs/.asdf/completions/asdf.bash" >> ~/.bashrc -# Install nodenv -RUN wget https://github.com/nodenv/nodenv/archive/master.zip && \ - unzip master.zip && \ - rm -f master.zip && \ - mv nodenv-master ~docs/.nodenv -RUN cd ~/.nodenv && src/configure && make -C src -ENV PATH /home/docs/.nodenv/bin:$PATH +# Activate asdf in current session +ENV PATH /home/docs/.asdf/shims:/home/docs/.asdf/bin:$PATH -# Install node-build -RUN mkdir /home/docs/.nodenv/plugins -RUN wget https://github.com/nodenv/node-build/archive/master.zip && \ - unzip master.zip && \ - rm -f master.zip && \ - mv node-build-master ~/.nodenv/plugins/node-build +# Install asdf plugins +RUN asdf plugin-add python +RUN asdf plugin add nodejs https://github.com/asdf-vm/asdf-nodejs.git +RUN asdf plugin-add rust https://github.com/code-lever/asdf-rust.git +RUN asdf plugin-add golang https://github.com/kennyp/asdf-golang.git CMD ["/bin/bash"] diff --git a/Dockerfile.conda47 b/Dockerfile.conda47 index e24263f..69783cf 100644 --- a/Dockerfile.conda47 +++ b/Dockerfile.conda47 @@ -1,25 +1,14 @@ # Read the Docs - ubuntu20-conda47 FROM readthedocs/build:ubuntu20-base -# Install Conda -# Note: 4.7.12.1 drastically increases memory usage -ENV RTD_CONDA_VERSION 4.6.14 +# Define Python versions to be installed via asdf +ENV RTD_PYTHON_VERSION miniconda3-4.7.12 -WORKDIR /home/docs +# Labels for external usage +LABEL python.version=$RTD_PYTHON_VERSION # Install supported Python versions -RUN pyenv install miniconda3-$RTD_CONDA_VERSION && \ - pyenv global miniconda3-$RTD_CONDA_VERSION - -WORKDIR /tmp - -ENV RTD_MAMBA_VERSION 0.8.2 -RUN pyenv local miniconda3-$RTD_CONDA_VERSION && \ - pyenv exec conda install --channel conda-forge mamba==$RTD_MAMBA_VERSION - -WORKDIR /home/docs - -# Adding labels for external usage -LABEL conda.version=$RTD_CONDA_VERSION +RUN asdf install python $RTD_PYTHON_VERSION && \ + asdf global python $RTD_PYTHON_VERSION CMD ["/bin/bash"] diff --git a/Dockerfile.custom b/Dockerfile.custom deleted file mode 100644 index 243cb69..0000000 --- a/Dockerfile.custom +++ /dev/null @@ -1,36 +0,0 @@ -# Read the Docs - On demand Docker image -# Building example: -# docker build \ -# --tag build-123456789 \ -# --file Dockerfile.custom \ -# --build-arg RTD_IMAGE=ubuntu20-py39 \ -# --build-arg RTD_NODE_VERSION=14.16.0 \ -# --build-arg RTD_RUST_VERSION=1.46.0 \ -# --build-arg RTD_APT_PACKAGES="swig imagemagick" . - -ARG RTD_IMAGE -FROM readthedocs/build:${RTD_IMAGE} - -ARG RTD_NODE_VERSION -ARG RTD_RUST_VERSION -ARG RTD_APT_PACKAGES - -USER root -WORKDIR / - -# Install extras -RUN apt-get update -RUN apt-get install -y ${RTD_APT_PACKAGES} - -USER docs -WORKDIR /home/docs - -# Install ``nodejs`` -RUN nodenv install ${RTD_NODE_VERSION} -RUN nodenv global ${RTD_NODE_VERSION} - -# Install ``rust`` -RUN curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain ${RTD_RUST_VERSION} -ENV PATH="/home/docs/.cargo/bin:$PATH" - -CMD ["/bin/bash"] diff --git a/Dockerfile.mamba410 b/Dockerfile.mamba410 new file mode 100644 index 0000000..f1f1eee --- /dev/null +++ b/Dockerfile.mamba410 @@ -0,0 +1,14 @@ +# Read the Docs - ubuntu20-mamba410 +FROM readthedocs/build:ubuntu20-base + +# Define Python versions to be installed via asdf +ENV RTD_PYTHON_VERSION mambaforge-4.10.1-5 + +# Labels for external usage +LABEL python.version=$RTD_PYTHON_VERSION + +# Install supported Python versions +RUN asdf install python $RTD_PYTHON_VERSION && \ + asdf global python $RTD_PYTHON_VERSION + +CMD ["/bin/bash"] diff --git a/Dockerfile.py27 b/Dockerfile.py27 index 36cb066..af845e2 100644 --- a/Dockerfile.py27 +++ b/Dockerfile.py27 @@ -1,24 +1,27 @@ # Read the Docs - ubuntu20-py27 FROM readthedocs/build:ubuntu20-base -# Define Python versions to be installed via pyenv -ENV RTD_PYTHON_VERSION_27 2.7.18 +# Define Python versions to be installed via asdf +ENV RTD_PYTHON_VERSION 2.7.18 +ENV RTD_PIP_VERSION 20.0.1 +ENV RTD_SETUPTOOLS_VERSION 44.0.0 +ENV RTD_VIRTUALENV_VERSION 16.7.9 -# Install supported Python versions -RUN pyenv install $RTD_PYTHON_VERSION_27 && \ - pyenv global $RTD_PYTHON_VERSION_27 +# Labels for external usage +LABEL python.version=$RTD_PYTHON_VERSION +LABEL python.pip=$RTD_PIP_VERSION +LABEL python.setuptools=$SETUPTOOLS_VERSION +LABEL python.virtualenv=$VIRTUALENV_VERSION -WORKDIR /tmp +# Install supported Python versions +RUN asdf install python $RTD_PYTHON_VERSION && \ + asdf global python $RTD_PYTHON_VERSION # Python2 dependencies are hardcoded because Python2 is # deprecated. Updating them to their latest versions may raise # incompatibility issues. -RUN pyenv local $RTD_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 virtualenv==16.7.9 - -# Adding labels for external usage -LABEL python.version_27=$PYTHON_VERSION_27 +RUN pip install --no-cache-dir -U pip==$RTD_PIP_VERSION && \ + pip install --no-cache-dir -U setuptools==$RTD_SETUPTOOLS_VERSION && \ + pip install --no-cache-dir virtualenv==$RTD_VIRTUALENV_VERSION CMD ["/bin/bash"] diff --git a/Dockerfile.py38 b/Dockerfile.py38 new file mode 100644 index 0000000..e914d71 --- /dev/null +++ b/Dockerfile.py38 @@ -0,0 +1,24 @@ +# Read the Docs - ubuntu20-py39 +FROM readthedocs/build:ubuntu20-base + +# Define Python versions to be installed via asdf +ENV RTD_PYTHON_VERSION 3.8.11 +ENV RTD_PIP_VERSION 21.2.4 +ENV RTD_SETUPTOOLS_VERSION 57.4.0 +ENV RTD_VIRTUALENV_VERSION 20.7.2 + +# Labels for external usage +LABEL python.version=$RTD_PYTHON_VERSION +LABEL python.pip=$RTD_PIP_VERSION +LABEL python.setuptools=$SETUPTOOLS_VERSION +LABEL python.virtualenv=$VIRTUALENV_VERSION + +# Install supported Python versions +RUN asdf install python $RTD_PYTHON_VERSION && \ + asdf global python $RTD_PYTHON_VERSION + +RUN pip install --no-cache-dir -U pip==$RTD_PIP_VERSION && \ + pip install --no-cache-dir -U setuptools==$RTD_SETUPTOOLS_VERSION && \ + pip install --no-cache-dir virtualenv==$RTD_VIRTUALENV_VERSION + +CMD ["/bin/bash"] diff --git a/Dockerfile.py39 b/Dockerfile.py39 index 2e1fd06..d89622a 100644 --- a/Dockerfile.py39 +++ b/Dockerfile.py39 @@ -1,27 +1,24 @@ # Read the Docs - ubuntu20-py39 FROM readthedocs/build:ubuntu20-base -ENV RTD_PYTHON_VERSION_39 3.9.0 +# Define Python versions to be installed via asdf +ENV RTD_PYTHON_VERSION 3.9.6 +ENV RTD_PIP_VERSION 21.2.4 +ENV RTD_SETUPTOOLS_VERSION 57.4.0 +ENV RTD_VIRTUALENV_VERSION 20.7.2 -# Install supported Python versions -RUN pyenv install $RTD_PYTHON_VERSION_39 && \ - pyenv global $RTD_PYTHON_VERSION_39 - -WORKDIR /tmp - -ENV RTD_PIP_VERSION 21.0.1 -ENV RTD_SETUPTOOLS_VERSION 45.1.0 -ENV RTD_VIRTUALENV_VERSION 20.4.3 - -RUN pyenv local $RTD_PYTHON_VERSION_39 && \ - 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 virtualenv==$RTD_VIRTUALENV_VERSION - -# Adding labels for external usage -LABEL python.version_39=$PYTHON_VERSION_39 +# Labels for external usage +LABEL python.version=$RTD_PYTHON_VERSION LABEL python.pip=$RTD_PIP_VERSION LABEL python.setuptools=$SETUPTOOLS_VERSION LABEL python.virtualenv=$VIRTUALENV_VERSION +# Install supported Python versions +RUN asdf install python $RTD_PYTHON_VERSION && \ + asdf global python $RTD_PYTHON_VERSION + +RUN pip install --no-cache-dir -U pip==$RTD_PIP_VERSION && \ + pip install --no-cache-dir -U setuptools==$RTD_SETUPTOOLS_VERSION && \ + pip install --no-cache-dir virtualenv==$RTD_VIRTUALENV_VERSION + CMD ["/bin/bash"]