Skip to content

Commit a2a1706

Browse files
authored
Merge pull request #10 from nipreps-containers/enh/update-to-micromamba
ENH: Migrate to micromamba
2 parents c834fb4 + 189ee8c commit a2a1706

File tree

3 files changed

+499
-93
lines changed

3 files changed

+499
-93
lines changed

Dockerfile

Lines changed: 25 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2121
# SOFTWARE.
2222
# Use Ubuntu 20.04 LTS
23-
FROM ubuntu:focal-20210416
23+
FROM ubuntu:jammy-20240125
2424

2525
# Make apt non-interactive
2626
RUN echo 'APT::Get::Assume-Yes "true";' > /etc/apt/apt.conf.d/90circleci \
@@ -35,6 +35,7 @@ RUN apt-get update && \
3535
build-essential \
3636
bzip2 \
3737
ca-certificates \
38+
curl \
3839
libtool \
3940
locales \
4041
lsb-release \
@@ -50,102 +51,33 @@ RUN locale-gen en_US.UTF-8 || true
5051
ENV LANG="en_US.UTF-8" \
5152
LC_ALL="en_US.UTF-8"
5253

53-
# Leave these args here to better use the Docker build cache
54-
# miniconda index: https://conda.io/en/latest/miniconda_hashes.html
55-
ENV CONDA_PATH="/opt/conda"
56-
ARG CONDA_VERSION=py39_23.1.0-1
57-
ARG SHA256SUM=5dc619babc1d19d6688617966251a38d245cb93d69066ccde9a013e1ebb5bf18
54+
WORKDIR /
55+
RUN curl -Ls https://micro.mamba.pm/api/micromamba/linux-64/latest | tar -xvj bin/micromamba
5856

59-
RUN wget --quiet https://repo.anaconda.com/miniconda/Miniconda3-${CONDA_VERSION}-Linux-x86_64.sh -O miniconda.sh && \
60-
echo "${SHA256SUM} miniconda.sh" > miniconda.sha256 && \
61-
sha256sum -c --status miniconda.sha256 && \
62-
mkdir -p /opt && \
63-
sh miniconda.sh -b -p ${CONDA_PATH} && \
64-
rm miniconda.sh miniconda.sha256 && \
65-
ln -s ${CONDA_PATH}/etc/profile.d/conda.sh /etc/profile.d/conda.sh && \
66-
echo ". ${CONDA_PATH}/etc/profile.d/conda.sh" >> ~/.bashrc && \
67-
echo "conda activate base" >> ~/.bashrc && \
68-
find ${CONDA_PATH}/ -follow -type f -name '*.a' -delete && \
69-
find ${CONDA_PATH}/ -follow -type f -name '*.js.map' -delete && \
70-
${CONDA_PATH}/bin/conda clean -afy
71-
72-
# Set CPATH for packages relying on compiled libs (e.g. indexed_gzip)
73-
ENV PATH="${CONDA_PATH}/bin:$PATH" \
74-
CPATH="${CONDA_PATH}/include:$CPATH" \
75-
PYTHONNOUSERSITE=1
76-
77-
COPY condarc /root/.condarc
78-
79-
RUN ${CONDA_PATH}/bin/conda install mamba -n base && \
80-
mamba install -y \
81-
attrs=22.2 \
82-
codecov=2.1 \
83-
colorclass=2.2 \
84-
coverage=6.3 \
85-
curl=7.88 \
86-
datalad=0.18 \
87-
dipy=1.5 \
88-
flake8=4.0 \
89-
git=2.39 \
90-
graphviz=3.0 \
91-
h5py=3.8 \
92-
indexed_gzip=1.7 \
93-
jinja2=3.1 \
94-
libxml2=2.10 \
95-
libxslt=1.1 \
96-
lockfile=0.12 \
97-
matplotlib=3.5 \
98-
mkl=2022.1 \
99-
mkl-service=2.4 \
100-
nibabel=4.0 \
101-
nilearn=0.9 \
102-
nipype=1.8 \
103-
nitime=0.9 \
104-
nodejs=18 \
105-
numpy=1.24 \
106-
packaging=23.0 \
107-
pandas=1.5 \
108-
pandoc=2.19 \
109-
pbr=5.11 \
110-
pip=23.0 \
111-
pockets=0.9 \
112-
psutil=5.9 \
113-
pydot=1.4 \
114-
pytest=7.2 \
115-
pytest-cov=4.0 \
116-
pytest-env=0.8 \
117-
pytest-xdist=3.2 \
118-
pyyaml=6.0 \
119-
requests=2.28 \
120-
scikit-image=0.19 \
121-
scikit-learn=1.2 \
122-
scipy=1.10 \
123-
seaborn=0.12 \
124-
setuptools=65 \
125-
sphinx=4.5 \
126-
sphinx_rtd_theme=1.0 \
127-
svgutils=0.3 \
128-
toml=0.10 \
129-
traits=6.3 \
130-
zlib=1.2 \
131-
zstd=1.5; sync && \
132-
chmod -R a+rX ${CONDA_PATH}; sync && \
133-
chmod +x ${CONDA_PATH}/bin/*; sync && \
134-
${CONDA_PATH}/bin/conda clean -afy && sync && \
135-
rm -rf ~/.conda ~/.cache/pip/*; sync
57+
ENV MAMBA_ROOT_PREFIX="/opt/conda"
58+
COPY env.yml /tmp/env.yml
59+
COPY requirements.txt /tmp/requirements.txt
60+
WORKDIR /tmp
61+
RUN micromamba create -y -f /tmp/env.yml && \
62+
micromamba clean -y -a
13663

13764
# Precaching fonts, set 'Agg' as default backend for matplotlib
138-
RUN ${CONDA_PATH}/bin/python -c "from matplotlib import font_manager" && \
139-
sed -i 's/\(backend *: \).*$/\1Agg/g' $( ${CONDA_PATH}/bin/python -c "import matplotlib; print(matplotlib.matplotlib_fname())" )
65+
RUN micromamba -n base run python -c "from matplotlib import font_manager" && \
66+
sed -i 's/\(backend *: \).*$/\1Agg/g' $( micromamba -n base run python -c "import matplotlib; print(matplotlib.matplotlib_fname())" )
14067

141-
# Install packages that are not distributed with conda
142-
RUN ${CONDA_PATH}/bin/python -m pip install --no-cache-dir -U \
143-
datalad-osf \
144-
etelemetry \
145-
nitransforms \
146-
templateflow \
147-
transforms3d
68+
# UV_USE_IO_URING for apparent race-condition (https://github.com/nodejs/node/issues/48444)
69+
# Check if this is still necessary when updating the base image.
70+
ENV PATH="/opt/conda/bin:$PATH" \
71+
UV_USE_IO_URING=0
14872

14973
# Installing SVGO and bids-validator
150-
RUN ${CONDA_PATH}/bin/npm install -g svgo@^2.3 bids-validator@1.8.0 && \
74+
RUN npm install -g svgo@^3.2.0 bids-validator@^1.14.0 && \
15175
rm -rf ~/.npm ~/.empty /root/.npm
76+
77+
# Initialize templateflow
78+
ENV TEMPLATEFLOW_HOME=/templateflow
79+
RUN templateflow update
80+
81+
# Pacify DataLad
82+
RUN git config --global user.name "NiPreps Miniconda" \
83+
&& git config --global user.email "nipreps@gmail.com"

env.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: base
2+
channels:
3+
- conda-forge
4+
# Update this ~yearly; last updated Jan 2024
5+
dependencies:
6+
- python=3.11
7+
# Needed for svgo and bids-validator; consider moving to deno
8+
- nodejs=20
9+
# Intel Math Kernel Library for numpy
10+
- mkl=2023.2.0
11+
- mkl-service=2.4.0
12+
# git-annex for templateflow users with DataLad superdatasets
13+
- git-annex=*=alldep*
14+
# Base scientific python stack; required by FSL, so pinned here
15+
- numpy=1.26
16+
- scipy=1.11
17+
- matplotlib=3.8
18+
- pandas=2.2
19+
- h5py=3.10
20+
# Dependencies compiled against numpy, best to stick with conda
21+
- nitime=0.10
22+
- scikit-image=0.22
23+
- scikit-learn=1.4
24+
# Utilities
25+
- graphviz=9.0
26+
- pandoc=3.1
27+
- pip
28+
- pip:
29+
- -r requirements.txt
30+
variables:
31+
FSLOUTPUTTYPE: NIFTI_GZ

0 commit comments

Comments
 (0)