@@ -26,6 +26,8 @@ RUN apt-get update --yes && \
26
26
# the ubuntu base image is rebuilt too seldom sometimes (less than once a month)
27
27
apt-get upgrade --yes && \
28
28
apt-get install --yes --no-install-recommends \
29
+ # - bzip2 is necessary to extract the micromamba executable.
30
+ bzip2 \
29
31
ca-certificates \
30
32
fonts-liberation \
31
33
locales \
@@ -81,72 +83,60 @@ RUN echo "auth requisite pam_deny.so" >> /etc/pam.d/su && \
81
83
fix-permissions "${CONDA_DIR}"
82
84
83
85
USER ${NB_UID}
84
- ARG PYTHON_VERSION=default
86
+
87
+ # Pin python version here, or set it to "default"
88
+ ARG PYTHON_VERSION=3.9
85
89
86
90
# Setup work directory for backward-compatibility
87
91
RUN mkdir "/home/${NB_USER}/work" && \
88
92
fix-permissions "/home/${NB_USER}"
89
93
90
- # Install conda as jovyan and check the sha256 sum provided on the download site
91
- WORKDIR /tmp
92
-
93
- # CONDA_MIRROR is a mirror prefix to speed up downloading
94
- # For example, people from mainland China could set it as
95
- # https://mirrors.tuna.tsinghua.edu.cn/github-release/conda-forge/miniforge/LatestRelease
96
- ARG CONDA_MIRROR=https://github.com/conda-forge/miniforge/releases/latest/download
97
-
98
- # ---- Miniforge installer ----
99
- # Check https://github.com/conda-forge/miniforge/releases
100
- # Package Manager and Python implementation to use (https://github.com/conda-forge/miniforge)
101
- # We're using Mambaforge installer, possible options:
102
- # - conda only: either Miniforge3 to use Python or Miniforge-pypy3 to use PyPy
103
- # - conda + mamba: either Mambaforge to use Python or Mambaforge-pypy3 to use PyPy
104
- # Installation: conda, mamba, pip
105
- RUN set -x && \
106
- # Miniforge installer
107
- miniforge_arch=$(uname -m) && \
108
- miniforge_installer="Mambaforge-Linux-${miniforge_arch}.sh" && \
109
- wget --quiet "${CONDA_MIRROR}/${miniforge_installer}" && \
110
- /bin/bash "${miniforge_installer}" -f -b -p "${CONDA_DIR}" && \
111
- rm "${miniforge_installer}" && \
112
- # Conda configuration see https://conda.io/projects/conda/en/latest/configuration.html
113
- conda config --system --set auto_update_conda false && \
114
- conda config --system --set show_channel_urls true && \
115
- if [[ "${PYTHON_VERSION}" != "default" ]]; then mamba install --quiet --yes python="${PYTHON_VERSION}" ; fi && \
116
- # Pin major.minor version of python
117
- mamba list python | grep '^python ' | tr -s ' ' | cut -d ' ' -f 1,2 >> "${CONDA_DIR}/conda-meta/pinned" && \
118
- # Using conda to update all packages: https://github.com/mamba-org/mamba/issues/1092
119
- conda update --all --quiet --yes && \
120
- conda clean --all -f -y && \
121
- rm -rf "/home/${NB_USER}/.cache/yarn" && \
122
- fix-permissions "${CONDA_DIR}" && \
123
- fix-permissions "/home/${NB_USER}"
124
-
125
- # Using fixed version of mamba in arm, because the latest one has problems with arm under qemu
126
- # See: https://github.com/jupyter/docker-stacks/issues/1539
127
- RUN set -x && \
128
- arch=$(uname -m) && \
129
- if [ "${arch}" == "aarch64" ]; then \
130
- mamba install --quiet --yes \
131
- 'mamba<0.18' && \
132
- mamba clean --all -f -y && \
133
- fix-permissions "${CONDA_DIR}" && \
134
- fix-permissions "/home/${NB_USER}" ; \
135
- fi;
136
-
137
- # Install Jupyter Notebook, Lab, and Hub
94
+ # Download and install Micromamba, and initialize Conda prefix.
95
+ # <https://github.com/mamba-org/mamba#micromamba>
96
+ # Similar projects using Micromamba:
97
+ # - Micromamba-Docker: <https://github.com/mamba-org/micromamba-docker>
98
+ # - repo2docker: <https://github.com/jupyterhub/repo2docker>
99
+ # Install Python, Mamba, Jupyter Notebook, Lab, and Hub
138
100
# Generate a notebook server config
139
- # Cleanup temporary files
101
+ # Cleanup temporary files and remove Micromamba
140
102
# Correct permissions
141
103
# Do all this in a single RUN command to avoid duplicating all of the
142
104
# files across image layers when the permissions change
143
- RUN mamba install --quiet --yes \
144
- 'notebook' \
145
- 'jupyterhub' \
146
- 'jupyterlab' && \
105
+ COPY --chown="${NB_UID}:${NB_GID}" initial-condarc "${CONDA_DIR}/.condarc"
106
+ WORKDIR /tmp
107
+ RUN set -x && \
108
+ arch=$(uname -m) && \
109
+ if [ "${arch}" = "x86_64" ]; then \
110
+ # Should be simpler, see <https://github.com/mamba-org/mamba/issues/1437>
111
+ arch="64" ; \
112
+ fi && \
113
+ wget -qO /tmp/micromamba.tar.bz2 \
114
+ "https://micromamba.snakepit.net/api/micromamba/linux-${arch}/latest" && \
115
+ tar -xvjf /tmp/micromamba.tar.bz2 --strip-components=1 bin/micromamba && \
116
+ rm /tmp/micromamba.tar.bz2 && \
117
+ PYTHON_SPECIFIER="python=${PYTHON_VERSION}" && \
118
+ if [[ "${PYTHON_VERSION}" == "default" ]]; then PYTHON_SPECIFIER="python" ; fi && \
119
+ if [ "${arch}" == "aarch64" ]; then \
120
+ # Prevent libmamba from sporadically hanging on arm64 under QEMU
121
+ # <https://github.com/mamba-org/mamba/issues/1611>
122
+ ./micromamba config set extract_threads 1; \
123
+ fi && \
124
+ # Install the packages
125
+ ./micromamba install \
126
+ --root-prefix="${CONDA_DIR}" \
127
+ --prefix="${CONDA_DIR}" \
128
+ --yes \
129
+ "${PYTHON_SPECIFIER}" \
130
+ 'mamba' \
131
+ 'notebook' \
132
+ 'jupyterhub' \
133
+ 'jupyterlab' && \
134
+ rm micromamba && \
135
+ # Pin major.minor version of python
136
+ mamba list python | grep '^python ' | tr -s ' ' | cut -d ' ' -f 1,2 >> "${CONDA_DIR}/conda-meta/pinned" && \
137
+ jupyter notebook --generate-config && \
147
138
mamba clean --all -f -y && \
148
139
npm cache clean --force && \
149
- jupyter notebook --generate-config && \
150
140
jupyter lab clean && \
151
141
rm -rf "/home/${NB_USER}/.cache/yarn" && \
152
142
fix-permissions "${CONDA_DIR}" && \
0 commit comments