Skip to content

Commit 300bb16

Browse files
committed
MAINT: Use the base nipreps/miniconda image
This should ease the issues we are having with some dependencies (esp. hdf5) as well as make the building process more standardized across nipreps. In the long run it should also help minimize build time, as we converge towards multi-stage builds where source images have been minimized.
1 parent 510ed0e commit 300bb16

File tree

2 files changed

+188
-91
lines changed

2 files changed

+188
-91
lines changed

.circleci/config.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,14 @@ jobs:
7474
set -e
7575
if [[ "$success" = "0" ]]; then
7676
echo "Pulling from local registry"
77-
docker tag localhost:5000/ubuntu ubuntu:xenial-20201030
77+
docker tag localhost:5000/ubuntu ubuntu:focal-20210416
7878
docker pull localhost:5000/dmriprep
7979
docker tag localhost:5000/dmriprep nipreps/dmriprep:latest
8080
docker tag localhost:5000/dmriprep nipreps/dmriprep
8181
else
8282
echo "Pulling from Docker Hub"
83-
docker pull ubuntu:xenial-20201030
84-
docker tag ubuntu:xenial-20201030 localhost:5000/ubuntu
83+
docker pull ubuntu:focal-20210416
84+
docker tag ubuntu:focal-20210416 localhost:5000/ubuntu
8585
docker push localhost:5000/ubuntu
8686
docker pull nipreps/dmriprep:latest
8787
fi

Dockerfile

Lines changed: 185 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -22,27 +22,33 @@
2222
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2323
# SOFTWARE.
2424

25-
# Use Ubuntu 16.04 LTS
26-
FROM ubuntu:xenial-20201030
25+
# Use Ubuntu 20.04 LTS
26+
FROM ubuntu:focal-20210416
2727

2828
# Prepare environment
2929
RUN apt-get update && \
3030
apt-get install -y --no-install-recommends \
31+
apt-utils \
3132
autoconf \
3233
build-essential \
3334
bzip2 \
3435
ca-certificates \
3536
curl \
36-
cython3 \
3737
git \
3838
libtool \
3939
lsb-release \
4040
pkg-config \
41+
unzip \
4142
xvfb && \
4243
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
4344

45+
ENV DEBIAN_FRONTEND="noninteractive" \
46+
LANG="en_US.UTF-8" \
47+
LC_ALL="en_US.UTF-8"
48+
4449
# Installing freesurfer
45-
RUN curl -sSL https://surfer.nmr.mgh.harvard.edu/pub/dist/freesurfer/6.0.1/freesurfer-Linux-centos6_x86_64-stable-pub-v6.0.1.tar.gz | tar zxv --no-same-owner -C /opt \
50+
RUN curl -sSL https://surfer.nmr.mgh.harvard.edu/pub/dist/freesurfer/6.0.1/freesurfer-Linux-centos6_x86_64-stable-pub-v6.0.1.tar.gz \
51+
| tar zxv --no-same-owner -C /opt \
4652
--exclude='freesurfer/diffusion' \
4753
--exclude='freesurfer/docs' \
4854
--exclude='freesurfer/fsfast' \
@@ -62,7 +68,8 @@ RUN curl -sSL https://surfer.nmr.mgh.harvard.edu/pub/dist/freesurfer/6.0.1/frees
6268
--exclude='freesurfer/subjects/V1_average' \
6369
--exclude='freesurfer/trctrain'
6470

65-
ENV FSL_DIR="/usr/share/fsl/5.0" \
71+
# Simulate SetUpFreeSurfer.sh
72+
ENV FSL_DIR="/opt/fsl-5.0.11" \
6673
OS="Linux" \
6774
FS_OVERRIDE=0 \
6875
FIX_VERTEX_AREA="" \
@@ -79,119 +86,209 @@ ENV PERL5LIB="$MINC_LIB_DIR/perl5/5.8.5" \
7986
MNI_PERL5LIB="$MINC_LIB_DIR/perl5/5.8.5" \
8087
PATH="$FREESURFER_HOME/bin:$FSFAST_HOME/bin:$FREESURFER_HOME/tktools:$MINC_BIN_DIR:$PATH"
8188

82-
# Pre-cache neurodebian key
83-
COPY .docker/neurodebian.gpg /usr/local/etc/neurodebian.gpg
84-
# Installing Neurodebian packages (FSL, AFNI, git)
85-
RUN curl -sSL "http://neuro.debian.net/lists/$( lsb_release -c | cut -f2 ).us-ca.full" >> /etc/apt/sources.list.d/neurodebian.sources.list && \
86-
apt-key add /usr/local/etc/neurodebian.gpg && \
87-
(apt-key adv --refresh-keys --keyserver hkp://ha.pool.sks-keyservers.net 0xA5D32F012649A5A9 || true)
88-
89-
RUN apt-get update && \
90-
apt-get install -y --no-install-recommends \
91-
fsl-core=5.0.9-5~nd16.04+1 \
92-
fsl-mni152-templates=5.0.7-2 \
93-
afni=16.2.07~dfsg.1-5~nd16.04+1 \
94-
convert3d && \
95-
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
96-
97-
ENV FSLDIR="/usr/share/fsl/5.0" \
89+
# FSL 5.0.11 (neurodocker build)
90+
RUN apt-get update -qq \
91+
&& apt-get install -y -q --no-install-recommends \
92+
bc \
93+
dc \
94+
file \
95+
libfontconfig1 \
96+
libfreetype6 \
97+
libgl1-mesa-dev \
98+
libgl1-mesa-dri \
99+
libglu1-mesa-dev \
100+
libgomp1 \
101+
libice6 \
102+
libxcursor1 \
103+
libxft2 \
104+
libxinerama1 \
105+
libxrandr2 \
106+
libxrender1 \
107+
libxt6 \
108+
sudo \
109+
wget \
110+
&& apt-get clean \
111+
&& rm -rf /var/lib/apt/lists/* \
112+
&& echo "Downloading FSL ..." \
113+
&& mkdir -p /opt/fsl-5.0.11 \
114+
&& curl -fsSL --retry 5 https://fsl.fmrib.ox.ac.uk/fsldownloads/fsl-5.0.11-centos6_64.tar.gz \
115+
| tar -xz -C /opt/fsl-5.0.11 --strip-components 1 \
116+
--exclude "fsl/config" \
117+
--exclude "fsl/data/atlases" \
118+
--exclude "fsl/data/first" \
119+
--exclude "fsl/data/mist" \
120+
--exclude "fsl/data/possum" \
121+
--exclude "fsl/data/standard/bianca" \
122+
--exclude "fsl/data/standard/tissuepriors" \
123+
--exclude "fsl/doc" \
124+
--exclude "fsl/etc/default_flobs.flobs" \
125+
--exclude "fsl/etc/fslconf" \
126+
--exclude "fsl/etc/js" \
127+
--exclude "fsl/etc/luts" \
128+
--exclude "fsl/etc/matlab" \
129+
--exclude "fsl/extras" \
130+
--exclude "fsl/include" \
131+
--exclude "fsl/python" \
132+
--exclude "fsl/refdoc" \
133+
--exclude "fsl/src" \
134+
--exclude "fsl/tcl" \
135+
--exclude "fsl/bin/FSLeyes" \
136+
&& find /opt/fsl-5.0.11/bin -type f -not \( \
137+
-name "applywarp" -or \
138+
-name "bet" -or \
139+
-name "bet2" -or \
140+
-name "convert_xfm" -or \
141+
-name "fast" -or \
142+
-name "flirt" -or \
143+
-name "fsl_regfilt" -or \
144+
-name "fslhd" -or \
145+
-name "fslinfo" -or \
146+
-name "fslmaths" -or \
147+
-name "fslmerge" -or \
148+
-name "fslroi" -or \
149+
-name "fslsplit" -or \
150+
-name "fslstats" -or \
151+
-name "imtest" -or \
152+
-name "mcflirt" -or \
153+
-name "melodic" -or \
154+
-name "prelude" -or \
155+
-name "remove_ext" -or \
156+
-name "susan" -or \
157+
-name "topup" -or \
158+
-name "zeropad" \) -delete \
159+
&& find /opt/fsl-5.0.11/data/standard -type f -not -name "MNI152_T1_2mm_brain.nii.gz" -delete
160+
ENV FSLDIR="/opt/fsl-5.0.11" \
161+
PATH="/opt/fsl-5.0.11/bin:$PATH" \
98162
FSLOUTPUTTYPE="NIFTI_GZ" \
99163
FSLMULTIFILEQUIT="TRUE" \
100-
POSSUMDIR="/usr/share/fsl/5.0" \
101-
LD_LIBRARY_PATH="/usr/lib/fsl/5.0:$LD_LIBRARY_PATH" \
102-
FSLTCLSH="/usr/bin/tclsh" \
103-
FSLWISH="/usr/bin/wish" \
104-
AFNI_MODELPATH="/usr/lib/afni/models" \
105-
AFNI_IMSAVE_WARNINGS="NO" \
106-
AFNI_TTATLAS_DATASET="/usr/share/afni/atlases" \
107-
AFNI_PLUGINPATH="/usr/lib/afni/plugins"
108-
ENV PATH="/usr/lib/fsl/5.0:/usr/lib/afni/bin:$PATH"
164+
FSLLOCKDIR="" \
165+
FSLMACHINELIST="" \
166+
FSLREMOTECALL="" \
167+
FSLGECUDAQ="cuda.q" \
168+
LD_LIBRARY_PATH="/opt/fsl-5.0.11/lib:$LD_LIBRARY_PATH"
109169

110-
COPY .docker/fsl-6.0/bin/topup /usr/share/fsl/5.0/bin/topup
111-
COPY .docker/fsl-6.0/bin/imglob /usr/share/fsl/5.0/bin/imglob
112-
COPY .docker/fsl-6.0/bin/eddy_openmp /usr/lib/fsl/5.0/eddy_openmp
113-
COPY .docker/fsl-6.0/lib/* /usr/lib/fsl/5.0/
170+
# Override some FSL tools with the version 6.0 binaries
171+
COPY .docker/fsl-6.0/bin/topup /opt/fsl-5.0.11/bin/topup
172+
COPY .docker/fsl-6.0/bin/imglob /opt/fsl-5.0.11/bin/imglob
173+
COPY .docker/fsl-6.0/bin/eddy_openmp /opt/fsl-5.0.11/eddy_openmp
174+
COPY .docker/fsl-6.0/lib/* /opt/fsl-5.0.11/lib/
175+
176+
# Convert3D (neurodocker build)
177+
RUN echo "Downloading Convert3D ..." \
178+
&& mkdir -p /opt/convert3d-1.0.0 \
179+
&& curl -fsSL --retry 5 https://sourceforge.net/projects/c3d/files/c3d/1.0.0/c3d-1.0.0-Linux-x86_64.tar.gz/download \
180+
| tar -xz -C /opt/convert3d-1.0.0 --strip-components 1 \
181+
--exclude "c3d-1.0.0-Linux-x86_64/lib" \
182+
--exclude "c3d-1.0.0-Linux-x86_64/share" \
183+
--exclude "c3d-1.0.0-Linux-x86_64/bin/c3d_gui"
184+
ENV C3DPATH="/opt/convert3d-1.0.0" \
185+
PATH="/opt/convert3d-1.0.0/bin:$PATH"
186+
187+
# AFNI latest (neurodocker build)
188+
RUN apt-get update -qq \
189+
&& apt-get install -y -q --no-install-recommends \
190+
apt-utils \
191+
ed \
192+
gsl-bin \
193+
libglib2.0-0 \
194+
libglu1-mesa-dev \
195+
libglw1-mesa \
196+
libgomp1 \
197+
libjpeg62 \
198+
libxm4 \
199+
netpbm \
200+
tcsh \
201+
xfonts-base \
202+
xvfb \
203+
&& apt-get clean \
204+
&& rm -rf /var/lib/apt/lists/* \
205+
&& curl -sSL --retry 5 -o /tmp/multiarch.deb http://archive.ubuntu.com/ubuntu/pool/main/g/glibc/multiarch-support_2.27-3ubuntu1.2_amd64.deb \
206+
&& dpkg -i /tmp/multiarch.deb \
207+
&& rm /tmp/multiarch.deb \
208+
&& curl -sSL --retry 5 -o /tmp/libxp6.deb http://mirrors.kernel.org/debian/pool/main/libx/libxp/libxp6_1.0.2-2_amd64.deb \
209+
&& dpkg -i /tmp/libxp6.deb \
210+
&& rm /tmp/libxp6.deb \
211+
&& curl -sSL --retry 5 -o /tmp/libpng.deb http://snapshot.debian.org/archive/debian-security/20160113T213056Z/pool/updates/main/libp/libpng/libpng12-0_1.2.49-1%2Bdeb7u2_amd64.deb \
212+
&& dpkg -i /tmp/libpng.deb \
213+
&& rm /tmp/libpng.deb \
214+
&& apt-get install -f \
215+
&& apt-get clean \
216+
&& rm -rf /var/lib/apt/lists/* \
217+
&& gsl2_path="$(find / -name 'libgsl.so.19' || printf '')" \
218+
&& if [ -n "$gsl2_path" ]; then \
219+
ln -sfv "$gsl2_path" "$(dirname $gsl2_path)/libgsl.so.0"; \
220+
fi \
221+
&& ldconfig \
222+
&& echo "Downloading AFNI ..." \
223+
&& mkdir -p /opt/afni-latest \
224+
&& curl -fsSL --retry 5 https://afni.nimh.nih.gov/pub/dist/tgz/linux_openmp_64.tgz \
225+
| tar -xz -C /opt/afni-latest --strip-components 1 \
226+
--exclude "linux_openmp_64/*.gz" \
227+
--exclude "linux_openmp_64/funstuff" \
228+
--exclude "linux_openmp_64/shiny" \
229+
--exclude "linux_openmp_64/afnipy" \
230+
--exclude "linux_openmp_64/lib/RetroTS" \
231+
--exclude "linux_openmp_64/meica.libs" \
232+
# Keep only what we use
233+
&& find /opt/afni-latest -type f -not \( \
234+
-name "3dTshift" -or \
235+
-name "3dUnifize" -or \
236+
-name "3dAutomask" -or \
237+
-name "3dvolreg" \) -delete
238+
239+
ENV PATH="/opt/afni-latest:$PATH" \
240+
AFNI_IMSAVE_WARNINGS="NO" \
241+
AFNI_PLUGINPATH="/opt/afni-latest"
114242

115243
# Installing ANTs 2.3.3 (NeuroDocker build)
116244
# Note: the URL says 2.3.4 but it is actually 2.3.3
117-
ENV ANTSPATH=/usr/lib/ants
118-
RUN mkdir -p $ANTSPATH && \
119-
curl -sSL "https://dl.dropbox.com/s/gwf51ykkk5bifyj/ants-Linux-centos6_x86_64-v2.3.4.tar.gz" \
245+
ENV ANTSPATH="/opt/ants" \
246+
PATH="/opt/ants:$PATH"
247+
WORKDIR $ANTSPATH
248+
RUN curl -sSL "https://dl.dropbox.com/s/gwf51ykkk5bifyj/ants-Linux-centos6_x86_64-v2.3.4.tar.gz" \
120249
| tar -xzC $ANTSPATH --strip-components 1
121-
ENV PATH=$ANTSPATH:$PATH
122250

123-
# Create a shared $HOME directory
124-
RUN useradd -m -s /bin/bash -G users dmriprep
125-
WORKDIR /home/dmriprep
126-
ENV HOME="/home/dmriprep"
251+
COPY --from=nipreps/miniconda@sha256:4d0dc0fabb794e9fe22ee468ae5f86c2c8c2b4cd9d7b7fdf0c134d9e13838729 /opt/conda /opt/conda
127252

128-
# Installing and setting up miniconda
129-
RUN curl -sSLO https://repo.continuum.io/miniconda/Miniconda3-4.5.11-Linux-x86_64.sh && \
130-
bash Miniconda3-4.5.11-Linux-x86_64.sh -b -p /usr/local/miniconda && \
131-
rm Miniconda3-4.5.11-Linux-x86_64.sh
253+
RUN ln -s /opt/conda/etc/profile.d/conda.sh /etc/profile.d/conda.sh && \
254+
echo ". /opt/conda/etc/profile.d/conda.sh" >> ~/.bashrc && \
255+
echo "conda activate base" >> ~/.bashrc
132256

133257
# Set CPATH for packages relying on compiled libs (e.g. indexed_gzip)
134-
ENV PATH="/usr/local/miniconda/bin:$PATH" \
135-
CPATH="/usr/local/miniconda/include/:$CPATH" \
258+
ENV PATH="/opt/conda/bin:$PATH" \
259+
CPATH="/opt/conda/include:$CPATH" \
260+
LD_LIBRARY_PATH="/opt/conda/lib:$LD_LIBRARY_PATH" \
136261
LANG="C.UTF-8" \
137262
LC_ALL="C.UTF-8" \
138263
PYTHONNOUSERSITE=1
139264

140-
# Installing precomputed python packages
141-
RUN conda install -y -c anaconda -c conda-forge \
142-
python=3.7.1 \
143-
graphviz=2.40 \
144-
git-annex \
145-
libxml2=2.9.8 \
146-
libxslt=1.1.32 \
147-
matplotlib=2.2 \
148-
mkl \
149-
mkl-service \
150-
nodejs \
151-
numpy=1.20 \
152-
pandoc=2.11 \
153-
pip=20.3 \
154-
scikit-learn=0.19 \
155-
scipy=1.5 \
156-
setuptools=51.1 \
157-
traits=4.6.0 \
158-
zlib; sync && \
159-
chmod -R a+rX /usr/local/miniconda; sync && \
160-
chmod +x /usr/local/miniconda/bin/*; sync && \
161-
conda build purge-all; sync && \
162-
conda clean -tipsy && sync
163-
164265
# Unless otherwise specified each process should only use one thread - nipype
165266
# will handle parallelization
166267
ENV MKL_NUM_THREADS=1 \
167268
OMP_NUM_THREADS=1
168269

169-
# Precaching fonts, set 'Agg' as default backend for matplotlib
170-
RUN python -c "from matplotlib import font_manager" && \
171-
sed -i 's/\(backend *: \).*$/\1Agg/g' $( python -c "import matplotlib; print(matplotlib.matplotlib_fname())" )
172-
173-
# Installing SVGO
174-
RUN npm install -g svgo
175-
176-
# Installing bids-validator
177-
RUN npm install -g [email protected]
178-
179-
# Refresh linked libraries
180-
RUN ldconfig
270+
# Create a shared $HOME directory
271+
RUN useradd -m -s /bin/bash -G users dmriprep
272+
WORKDIR /home/dmriprep
273+
ENV HOME="/home/dmriprep"
181274

182-
WORKDIR /src
275+
RUN echo ". /opt/conda/etc/profile.d/conda.sh" >> $HOME/.bashrc && \
276+
echo "conda activate base" >> $HOME/.bashrc
183277

184278
# Installing dMRIPrep
185279
COPY . /src/dmriprep
186280
ARG VERSION
187281
# Force static versioning within container
188282
RUN echo "${VERSION}" > /src/dmriprep/dmriprep/VERSION && \
189283
echo "include dmriprep/VERSION" >> /src/dmriprep/MANIFEST.in && \
190-
cd /src/dmriprep && \
191-
pip install --no-cache-dir .[all]
284+
/opt/conda/bin/python -m pip install --no-cache-dir "/src/dmriprep[all]"
192285

193286
RUN find $HOME -type d -exec chmod go=u {} + && \
194-
find $HOME -type f -exec chmod go=u {} +
287+
find $HOME -type f -exec chmod go=u {} + && \
288+
rm -rf $HOME/.npm $HOME/.conda $HOME/.empty
289+
290+
# Refresh linked libraries
291+
RUN ldconfig
195292

196293
WORKDIR /tmp/
197294
ENTRYPOINT ["/usr/local/miniconda/bin/dmriprep"]

0 commit comments

Comments
 (0)