Skip to content

Commit 0447629

Browse files
authored
Merge pull request #1441 from mathbunnyru/asalikhov/use_mamba_everywhere
Use mamba instead of conda where possible
2 parents 42a7272 + b3a1933 commit 0447629

File tree

17 files changed

+59
-86
lines changed

17 files changed

+59
-86
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,9 @@ build-all-multi: $(foreach I, $(MULTI_IMAGES), build-multi/$(I)) $(foreach I, $(
112112

113113

114114

115-
check-outdated/%: ## check the outdated conda packages in a stack and produce a report (experimental)
115+
check-outdated/%: ## check the outdated mamba/conda packages in a stack and produce a report (experimental)
116116
@TEST_IMAGE="$(OWNER)/$(notdir $@)" pytest test/test_outdated.py
117-
check-outdated-all: $(foreach I, $(ALL_IMAGES), check-outdated/$(I)) ## check all the stacks for outdated conda packages
117+
check-outdated-all: $(foreach I, $(ALL_IMAGES), check-outdated/$(I)) ## check all the stacks for outdated packages
118118

119119

120120

base-notebook/Dockerfile

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,9 @@ RUN set -x && \
9595
# Conda configuration see https://conda.io/projects/conda/en/latest/configuration.html
9696
conda config --system --set auto_update_conda false && \
9797
conda config --system --set show_channel_urls true && \
98-
if [[ "${PYTHON_VERSION}" != "default" ]]; then conda install --yes python="${PYTHON_VERSION}"; fi && \
99-
conda list python | grep '^python ' | tr -s ' ' | cut -d ' ' -f 1,2 >> "${CONDA_DIR}/conda-meta/pinned" && \
98+
if [[ "${PYTHON_VERSION}" != "default" ]]; then mamba install --quiet --yes python="${PYTHON_VERSION}"; fi && \
99+
mamba list python | grep '^python ' | tr -s ' ' | cut -d ' ' -f 1,2 >> "${CONDA_DIR}/conda-meta/pinned" && \
100+
# Using conda to update all packages: https://github.com/mamba-org/mamba/issues/1092
100101
conda update --all --quiet --yes && \
101102
conda clean --all -f -y && \
102103
rm -rf "/home/${NB_USER}/.cache/yarn" && \
@@ -109,11 +110,11 @@ RUN set -x && \
109110
# Correct permissions
110111
# Do all this in a single RUN command to avoid duplicating all of the
111112
# files across image layers when the permissions change
112-
RUN conda install --quiet --yes \
113+
RUN mamba install --quiet --yes \
113114
'notebook' \
114115
'jupyterhub' \
115116
'jupyterlab' && \
116-
conda clean --all -f -y && \
117+
mamba clean --all -f -y && \
117118
npm cache clean --force && \
118119
jupyter notebook --generate-config && \
119120
jupyter lab clean && \

binder/README.ipynb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,14 @@
6666
"metadata": {},
6767
"outputs": [],
6868
"source": [
69-
"!which conda"
69+
"!which mamba"
7070
]
7171
},
7272
{
7373
"cell_type": "markdown",
7474
"metadata": {},
7575
"source": [
76-
"The user has read/write access to the root conda environment."
76+
"The user has read/write access to the root mamba environment."
7777
]
7878
},
7979
{
@@ -89,7 +89,7 @@
8989
"cell_type": "markdown",
9090
"metadata": {},
9191
"source": [
92-
"The following packages are conda-installed in the base image to support [Jupyter Notebook](https://github.com/jupyter/notebook), [JupyterLab](https://github.com/jupyterlab/jupyterlab), and their use in [JupyterHub](https://github.com/jupyterhub/jupyterhub) environments (e.g., [MyBinder](https://mybinder.org/))."
92+
"The following packages are mamba-installed in the base image to support [Jupyter Notebook](https://github.com/jupyter/notebook), [JupyterLab](https://github.com/jupyterlab/jupyterlab), and their use in [JupyterHub](https://github.com/jupyterhub/jupyterhub) environments (e.g., [MyBinder](https://mybinder.org/))."
9393
]
9494
},
9595
{
@@ -98,7 +98,7 @@
9898
"metadata": {},
9999
"outputs": [],
100100
"source": [
101-
"!conda list"
101+
"!mamba list"
102102
]
103103
},
104104
{

datascience-notebook/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ RUN mkdir /etc/julia && \
5454
USER ${NB_UID}
5555

5656
# R packages including IRKernel which gets installed globally.
57-
RUN conda install --quiet --yes \
57+
RUN mamba install --quiet --yes \
5858
'r-base' \
5959
'r-caret' \
6060
'r-crayon' \
@@ -75,7 +75,7 @@ RUN conda install --quiet --yes \
7575
'r-tidyverse' \
7676
'rpy2' \
7777
'unixodbc' && \
78-
conda clean --all -f -y && \
78+
mamba clean --all -f -y && \
7979
fix-permissions "${CONDA_DIR}" && \
8080
fix-permissions "/home/${NB_USER}"
8181

docs/contributing/stacks.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Feel free to follow it or pave your own path using alternative services and buil
1818
First, install [cookiecutter](https://github.com/cookiecutter/cookiecutter) using pip or conda:
1919

2020
```bash
21-
pip install cookiecutter # or conda install cookiecutter
21+
pip install cookiecutter # or mamba install cookiecutter
2222
```
2323

2424
Run the cookiecutter command pointing to the [jupyter/cookiecutter-docker-stacks](https://github.com/jupyter/cookiecutter-docker-stacks) project on GitHub.

docs/using/common.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -161,35 +161,35 @@ You can use either `pip`, `conda` or `mamba` to install new packages without any
161161

162162
```bash
163163
# install a package into the default (python 3.x) environment and cleanup after the installation
164-
pip install --quiet --no-cache-dir some-package && \
164+
mamba install --quiet --yes some-package && \
165+
mamba clean --all -f -y && \
165166
fix-permissions "${CONDA_DIR}" && \
166167
fix-permissions "/home/${NB_USER}"
167168

168-
conda install --quiet --yes some-package && \
169-
conda clean --all -f -y && \
169+
pip install --quiet --no-cache-dir some-package && \
170170
fix-permissions "${CONDA_DIR}" && \
171171
fix-permissions "/home/${NB_USER}"
172172

173-
mamba install --quiet --yes some-package && \
174-
mamba clean --all -f -y && \
173+
conda install --quiet --yes some-package && \
174+
conda clean --all -f -y && \
175175
fix-permissions "${CONDA_DIR}" && \
176176
fix-permissions "/home/${NB_USER}"
177177
```
178178

179179
### Using alternative channels
180180

181181
Conda is configured by default to use only the [`conda-forge`](https://anaconda.org/conda-forge) channel.
182-
However, alternative channels can be used either one shot by overwriting the default channel in the installation command or by configuring `conda` to use different channels.
182+
However, alternative channels can be used either one shot by overwriting the default channel in the installation command or by configuring `mamba` to use different channels.
183183
The examples below show how to use the [anaconda default channels](https://repo.anaconda.com/pkgs/main) instead of `conda-forge` to install packages.
184184

185185
```bash
186186
# using defaults channels to install a package
187-
conda install --channel defaults humanize
187+
mamba install --channel defaults humanize
188188
# configure conda to add default channels at the top of the list
189189
conda config --system --prepend channels defaults
190190
# install a package
191-
conda install --quiet --yes humanize && \
192-
conda clean --all -f -y && \
191+
mamba install --quiet --yes humanize && \
192+
mamba clean --all -f -y && \
193193
fix-permissions "${CONDA_DIR}" && \
194194
fix-permissions "/home/${NB_USER}"
195195
```

docs/using/recipes.md

Lines changed: 15 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ docker run -it -e GRANT_SUDO=yes --user root jupyter/minimal-notebook
2121
**You should only enable `sudo` if you trust the user and/or if the container is running on an isolated host.**
2222
See [Docker security documentation](https://docs.docker.com/engine/security/userns-remap/) for more information about running containers as `root`.
2323

24-
## Using `pip install` or `conda install` in a Child Docker image
24+
## Using `mamba install` or `pip install` in a Child Docker image
2525

2626
Create a new Dockerfile like the one shown below.
2727

@@ -61,8 +61,8 @@ For conda, the Dockerfile is similar:
6161
FROM jupyter/datascience-notebook:33add21fab64
6262
# Install from requirements.txt file
6363
COPY --chown=${NB_UID}:${NB_GID} requirements.txt /tmp/
64-
RUN conda install --yes --file /tmp/requirements.txt && \
65-
conda clean --all -f -y && \
64+
RUN mamba install --yes --file /tmp/requirements.txt && \
65+
mamba clean --all -f -y && \
6666
fix-permissions "${CONDA_DIR}" && \
6767
fix-permissions "/home/${NB_USER}"
6868
```
@@ -81,8 +81,8 @@ FROM jupyter/scipy-notebook:latest
8181
# Create a Python 2.x environment using conda including at least the ipython kernel
8282
# and the kernda utility. Add any additional packages you want available for use
8383
# in a Python 2 notebook to the first line here (e.g., pandas, matplotlib, etc.)
84-
RUN conda create --quiet --yes -p "${CONDA_DIR}/envs/python2" python=2.7 ipython ipykernel kernda && \
85-
conda clean --all -f -y
84+
RUN mamba create --quiet --yes -p "${CONDA_DIR}/envs/python2" python=2.7 ipython ipykernel kernda && \
85+
mamba clean --all -f -y
8686

8787
USER root
8888

@@ -109,17 +109,17 @@ FROM jupyter/minimal-notebook:latest
109109
ARG conda_env=python36
110110
ARG py_ver=3.6
111111

112-
# you can add additional libraries you want conda to install by listing them below the first line and ending with "&& \"
113-
RUN conda create --quiet --yes -p "${CONDA_DIR}/envs/${conda_env}" python=${py_ver} ipython ipykernel && \
114-
conda clean --all -f -y
112+
# you can add additional libraries you want mamba to install by listing them below the first line and ending with "&& \"
113+
RUN mamba create --quiet --yes -p "${CONDA_DIR}/envs/${conda_env}" python=${py_ver} ipython ipykernel && \
114+
mamba clean --all -f -y
115115

116116
# alternatively, you can comment out the lines above and uncomment those below
117117
# if you'd prefer to use a YAML file present in the docker build context
118118

119119
# COPY --chown=${NB_UID}:${NB_GID} environment.yml "/home/${NB_USER}/tmp/"
120120
# RUN cd "/home/${NB_USER}/tmp/" && \
121-
# conda env create -p "${CONDA_DIR}/envs/${conda_env}" -f environment.yml && \
122-
# conda clean --all -f -y
121+
# mamba env create -p "${CONDA_DIR}/envs/${conda_env}" -f environment.yml && \
122+
# mamba clean --all -f -y
123123

124124

125125
# create Python 3.x environment and link it to jupyter
@@ -195,8 +195,8 @@ notebooks, with no conversion, adding javascript Reveal.js:
195195

196196
```bash
197197
# Add Live slideshows with RISE
198-
RUN conda install --quiet --yes -c damianavila82 rise && \
199-
conda clean --all -f -y && \
198+
RUN mamba install --quiet --yes -c damianavila82 rise && \
199+
mamba clean --all -f -y && \
200200
fix-permissions "${CONDA_DIR}" && \
201201
fix-permissions "/home/${NB_USER}"
202202
```
@@ -206,12 +206,12 @@ Credit: [Paolo D.](https://github.com/pdonorio) based on
206206

207207
## xgboost
208208

209-
You need to install conda's gcc for Python xgboost to work properly.
209+
You need to install conda-forge's gcc for Python xgboost to work properly.
210210
Otherwise, you'll get an exception about libgomp.so.1 missing GOMP_4.0.
211211

212212
```bash
213-
conda install --quiet --yes gcc && \
214-
conda clean --all -f -y && \
213+
mamba install --quiet --yes gcc && \
214+
mamba clean --all -f -y && \
215215
fix-permissions "${CONDA_DIR}" && \
216216
fix-permissions "/home/${NB_USER}"
217217

@@ -521,29 +521,6 @@ RUN pip install --quiet --no-cache-dir jupyter_contrib_nbextensions && \
521521

522522
Ref: <https://github.com/jupyter/docker-stacks/issues/675>
523523

524-
## Enable auto-sklearn notebooks
525-
526-
Using `auto-sklearn` requires `swig`, which the other notebook images lack, so it cant be experimented with.
527-
Also, there is no Conda package for `auto-sklearn`.
528-
529-
```dockerfile
530-
ARG BASE_CONTAINER=jupyter/scipy-notebook
531-
FROM jupyter/scipy-notebook:latest
532-
533-
USER root
534-
535-
# autosklearn requires swig, which no other image has
536-
RUN apt-get update --yes && \
537-
apt-get install --yes --no-install-recommends swig && \
538-
apt-get clean && rm -rf /var/lib/apt/lists/*
539-
540-
USER ${NB_UID}
541-
542-
RUN pip install --quiet --no-cache-dir auto-sklearn && \
543-
fix-permissions "${CONDA_DIR}" && \
544-
fix-permissions "/home/${NB_USER}"
545-
```
546-
547524
## Enable Delta Lake in Spark notebooks
548525

549526
Please note that the [Delta Lake](https://delta.io/) packages are only available for Spark version > `3.0`.

docs/using/selecting.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ It is the basis for all other stacks.
2828
- Minimally-functional Jupyter Notebook server (e.g., no LaTeX support for saving notebooks as PDFs)
2929
- [Miniforge](https://github.com/conda-forge/miniforge) Python 3.x in `/opt/conda` with two package managers
3030
- [conda](https://github.com/conda/conda): "cross-platform, language-agnostic binary package manager".
31-
- [mamba](https://github.com/mamba-org/mamba): "reimplementation of the conda package manager in C++".
31+
- [mamba](https://github.com/mamba-org/mamba): "reimplementation of the conda package manager in C++". We use this package manager by default when installing packages.
3232
- `notebook`, `jupyterhub` and `jupyterlab` packages
3333
- No preinstalled scientific computing packages
3434
- Unprivileged user `jovyan` (`uid=1000`, configurable, see options) in group `users` (`gid=100`)

examples/docker-compose/notebook/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ USER root
1212
USER ${NB_UID}
1313

1414
# Switch back to jovyan to avoid accidental container runs as root
15-
# Add permanent pip/conda installs, data files, other user libs here
15+
# Add permanent mamba/pip/conda installs, data files, other user libs here
1616
# e.g., RUN pip install --quiet --no-cache-dir flake8

examples/make-deploy/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ USER root
1212
USER ${NB_UID}
1313

1414
# Switch back to jovyan to avoid accidental container runs as root
15-
# Add permanent pip/conda installs, data files, other user libs here
15+
# Add permanent mamba/pip/conda installs, data files, other user libs here
1616
# e.g., RUN pip install --quiet --no-cache-dir flake8

0 commit comments

Comments
 (0)