Skip to content

Commit 9ac9fa9

Browse files
committed
chore(docker): Fetch mri_vol2vol from FreeSurfer image, pare down Dockerfile
1 parent a0d2b61 commit 9ac9fa9

File tree

2 files changed

+20
-63
lines changed

2 files changed

+20
-63
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ jobs:
141141
-w /src/nitransforms -v $PWD:/src/nitransforms \
142142
-v /tmp/data/nitransforms-tests:/data -e TEST_DATA_HOME=/data \
143143
-e COVERAGE_FILE=/tmp/coverage/.pytest.coverage \
144-
-v /tmp/fslicense/license.txt:/opt/freesurfer/license.txt:ro \
144+
-v /tmp/fslicense/license.txt:/usr/local/freesurfer/license.txt:ro \
145145
-v /tmp/tests:/tmp nitransforms:latest \
146146
pytest --junit-xml=/tmp/summaries/pytest.xml \
147147
--cov nitransforms --cov-report xml:/tmp/coverage/unittests.xml \

Dockerfile

Lines changed: 19 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Ubuntu 22.04 LTS - Jammy
2-
ARG BASE_IMAGE=ubuntu:jammy-20240125
2+
ARG BASE_IMAGE=ubuntu:jammy-20250730
33

44
#
55
# Build wheel
@@ -14,9 +14,9 @@ RUN uv build --wheel /src
1414
#
1515

1616
# Utilities for downloading packages
17-
FROM ${BASE_IMAGE} as downloader
17+
FROM ${BASE_IMAGE} AS downloader
1818
# Bump the date to current to refresh curl/certificates/etc
19-
RUN echo "2023.07.20"
19+
RUN echo "2025.09.25"
2020
RUN apt-get update && \
2121
apt-get install -y --no-install-recommends \
2222
binutils \
@@ -28,64 +28,47 @@ RUN apt-get update && \
2828

2929
RUN update-ca-certificates -f
3030

31-
# FreeSurfer 7.3.2
32-
FROM downloader as freesurfer
33-
COPY docker/files/freesurfer7.3.2-exclude.txt /usr/local/etc/freesurfer7.3.2-exclude.txt
34-
COPY docker/files/fs-cert.pem /usr/local/etc/fs-cert.pem
35-
RUN curl --cacert /usr/local/etc/fs-cert.pem \
36-
-sSL https://surfer.nmr.mgh.harvard.edu/pub/dist/freesurfer/7.3.2/freesurfer-linux-ubuntu22_amd64-7.3.2.tar.gz \
37-
| tar zxv --no-same-owner -C /opt --exclude-from=/usr/local/etc/freesurfer7.3.2-exclude.txt
38-
3931
# Micromamba
40-
FROM downloader as micromamba
41-
42-
# Install a C compiler to build extensions when needed.
43-
# traits<6.4 wheels are not available for Python 3.11+, but build easily.
44-
RUN apt-get update && \
45-
apt-get install -y --no-install-recommends build-essential && \
46-
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
32+
FROM downloader AS micromamba
4733

4834
WORKDIR /
4935
# Bump the date to current to force update micromamba
50-
RUN echo "2024.02.06"
36+
RUN echo "2025.09.05"
5137
RUN curl -Ls https://micro.mamba.pm/api/micromamba/linux-64/latest | tar -xvj bin/micromamba
5238

5339
ENV MAMBA_ROOT_PREFIX="/opt/conda"
5440
COPY env.yml /tmp/env.yml
55-
# COPY requirements.txt /tmp/requirements.txt
5641
WORKDIR /tmp
5742
RUN micromamba create -y -f /tmp/env.yml && \
5843
micromamba clean -y -a
5944

6045
#
6146
# Main stage
6247
#
63-
FROM ${BASE_IMAGE} as nitransforms
48+
FROM ${BASE_IMAGE} AS nitransforms
6449

6550
# Configure apt
6651
ENV DEBIAN_FRONTEND="noninteractive" \
6752
LANG="en_US.UTF-8" \
6853
LC_ALL="en_US.UTF-8"
6954

70-
# Some baseline tools; bc is needed for FreeSurfer, so don't drop it
7155
RUN apt-get update && \
7256
apt-get install -y --no-install-recommends \
73-
bc \
74-
ca-certificates \
75-
curl \
76-
libgomp1 \
77-
lsb-release \
78-
netbase \
79-
xvfb && \
57+
libexpat1 \
58+
libgomp1 \
59+
&& \
8060
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
8161

82-
# Install files from stages
83-
COPY --from=freesurfer /opt/freesurfer /opt/freesurfer
62+
# Install FreeSurfer and AFNI bins from images
63+
COPY --from=freesurfer/freesurfer:7.4.1 \
64+
/usr/local/freesurfer/bin/mri_vol2vol \
65+
/usr/local/freesurfer/bin/
8466
COPY --from=afni/afni_make_build:AFNI_25.2.09 \
8567
/opt/afni/install/libf2c.so \
8668
/opt/afni/install/libmri.so \
8769
/usr/local/lib/
8870
COPY --from=afni/afni_make_build:AFNI_25.2.09 \
71+
/opt/afni/install/3dAllineate \
8972
/opt/afni/install/3dNwarpApply \
9073
/opt/afni/install/3dWarp \
9174
/opt/afni/install/3drefit \
@@ -97,41 +80,27 @@ ENV OS="Linux" \
9780
FS_OVERRIDE=0 \
9881
FIX_VERTEX_AREA="" \
9982
FSF_OUTPUT_FORMAT="nii.gz" \
100-
FREESURFER_HOME="/opt/freesurfer"
83+
FREESURFER_HOME="/usr/local/freesurfer"
10184
ENV SUBJECTS_DIR="$FREESURFER_HOME/subjects" \
10285
FUNCTIONALS_DIR="$FREESURFER_HOME/sessions" \
103-
MNI_DIR="$FREESURFER_HOME/mni" \
10486
LOCAL_DIR="$FREESURFER_HOME/local" \
105-
MINC_BIN_DIR="$FREESURFER_HOME/mni/bin" \
106-
MINC_LIB_DIR="$FREESURFER_HOME/mni/lib" \
107-
MNI_DATAPATH="$FREESURFER_HOME/mni/data"
108-
ENV PERL5LIB="$MINC_LIB_DIR/perl5/5.8.5" \
109-
MNI_PERL5LIB="$MINC_LIB_DIR/perl5/5.8.5" \
110-
PATH="$FREESURFER_HOME/bin:$FREESURFER_HOME/tktools:$MINC_BIN_DIR:$PATH"
87+
PATH="$FREESURFER_HOME/bin:$PATH"
11188

11289
# AFNI config
113-
ENV PATH="/opt/afni-latest:$PATH" \
114-
AFNI_IMSAVE_WARNINGS="NO" \
115-
AFNI_PLUGINPATH="/opt/afni-latest"
116-
117-
# Workbench config
118-
ENV PATH="/opt/workbench/bin_linux64:$PATH"
90+
ENV AFNI_IMSAVE_WARNINGS="NO"
11991

12092
# Create a shared $HOME directory
12193
RUN useradd -m -s /bin/bash -G users neuro
12294
WORKDIR /home/neuro
123-
ENV HOME="/home/neuro" \
124-
LD_LIBRARY_PATH="/usr/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH"
95+
ENV HOME="/home/neuro"
12596

12697
COPY --from=micromamba /bin/micromamba /bin/micromamba
12798
COPY --from=micromamba /opt/conda/envs/nitransforms /opt/conda/envs/nitransforms
12899

129100
ENV MAMBA_ROOT_PREFIX="/opt/conda"
130101
RUN micromamba shell init -s bash && \
131102
echo "micromamba activate nitransforms" >> $HOME/.bashrc
132-
ENV PATH="/opt/conda/envs/nitransforms/bin:$PATH" \
133-
CPATH="/opt/conda/envs/nitransforms/include:$CPATH" \
134-
LD_LIBRARY_PATH="/opt/conda/envs/nitransforms/lib:$LD_LIBRARY_PATH"
103+
ENV PATH="/opt/conda/envs/nitransforms/bin:$PATH"
135104

136105
# FSL environment
137106
ENV LANG="C.UTF-8" \
@@ -145,22 +114,10 @@ ENV LANG="C.UTF-8" \
145114
FSLREMOTECALL="" \
146115
FSLGECUDAQ="cuda.q"
147116

148-
# Unless otherwise specified each process should only use one thread - nipype
149-
# will handle parallelization
150-
ENV MKL_NUM_THREADS=1 \
151-
OMP_NUM_THREADS=1
152-
153117
# Install package
154-
# CRITICAL: Make sure python setup.py --version has been run at least once
155-
# outside the container, with access to the git history.
156118
COPY --from=src /src/dist/*.whl .
157119
RUN python -m pip install --no-cache-dir $( ls *.whl )[all]
158120

159-
160-
RUN find $HOME -type d -exec chmod go=u {} + && \
161-
find $HOME -type f -exec chmod go=u {} + && \
162-
rm -rf $HOME/.npm $HOME/.conda $HOME/.empty
163-
164121
RUN ldconfig
165122
WORKDIR /tmp/
166123

0 commit comments

Comments
 (0)