-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
164 lines (154 loc) · 5.62 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# Stage: python
FROM nvidia/cuda:10.1-cudnn7-runtime-ubuntu18.04 as python
ENV DEBIAN_FRONTEND="noninteractive" \
PYENV_VER="v2.3.17" \
PYTHON_VER="3.8.12" \
PYENV_ROOT="/opt/.pyenv" \
PATH="/opt/.pyenv/shims:/opt/.pyenv/bin:/usr/local/cuda/bin:${PATH}" \
LD_LIBRARY_PATH=/usr/local/cuda/lib64:${LD_LIBRARY_PATH}
RUN apt-get update -qq \
&& apt-get install -y -q --no-install-recommends \
build-essential \
curl \
git \
libbz2-dev \
libffi-dev \
liblzma-dev \
libncurses5-dev \
libncursesw5-dev \
libreadline-dev \
libsqlite3-dev \
libssl-dev \
llvm \
python-openssl \
tk-dev \
wget \
xz-utils \
zlib1g-dev \
software-properties-common \
&& git clone -b ${PYENV_VER} --depth=1 https://github.com/pyenv/pyenv.git /opt/.pyenv \
&& pyenv install -v ${PYTHON_VER} \
&& pyenv global ${PYTHON_VER} \
&& python -m pip install --upgrade pip
# Stage: builder
# Notes: g++ (snakebids), tcsh (freesurfer), libtiff5 (mrtrix3)
FROM python as builder
RUN mkdir -p /opt \
&& apt-get update -qq \
&& apt-get install -y -q --no-install-recommends \
libeigen3-dev \
zlib1g-dev \
libqt5opengl5-dev \
libqt5svg5-dev \
libgl1-mesa-dev \
libncurses5 \
libxt6 \
libtiff5 \
parallel \
rsync \
tcsh \
g++ \
unzip \
bc \
# FSL dependencies
libexpat1-dev \
liblapack-dev \
libopenblas-dev \
libx11-dev \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Stage: ants
FROM builder as ants
ARG ANTS_VER=2.4.3
RUN wget https://github.com/ANTsX/ANTs/releases/download/v${ANTS_VER}/ants-${ANTS_VER}-centos7-X64-gcc.zip -O ants.zip \
&& unzip -qq ants.zip -d /opt \
&& mv /opt/ants-${ANTS_VER} /opt/ants \
&& rm ants.zip
# Stage: fsl
FROM fnndsc/fsl:6.0.5.1-cuda9.1 as fsl
RUN mv /usr/local/fsl/bin /usr/local/fsl/bin-all \
&& mkdir -p /usr/local/fsl/bin \
&& cd /usr/local/fsl/bin-all \
&& cp -R bet* bedpost* topup applytopup eddy* fslorient probtrack* fslmerge remove_ext avscale /usr/local/fsl/bin \
&& cd /usr/local/fsl/bin \
&& rm -r eddy_cuda8.0 eddy_cuda10.2 /usr/local/fsl/bin-all
# Stage: itksnap (built with Ubuntu16.04 - glibc 2.23)
FROM khanlab/itksnap:main as itksnap
RUN cp -R /opt/itksnap/ /opt/itksnap-mini/ \
&& cd /opt/itksnap-mini/bin \
&& rm c2d itksnap*
# Stage: mrtrix (nogui)
FROM builder as mrtrix
ARG MRTRIX_VER=3.0.4
ARG MRTRIX_CONFIG_FLAGS="-nogui"
ARG MRTRIX_BUILD_FLAGS=""
RUN git clone --depth 1 https://github.com/MRtrix3/mrtrix3.git /opt/mrtrix3 \
&& cd /opt/mrtrix3 \
&& git fetch --tags \
&& git checkout ${MRTRIX_VER} \
&& ./configure ${MRTRIX_CONFIG_FLAGS} \
&& ./build ${MRTRIX_BUILD_FLAGS} \
&& mkdir -p mrtrix3_runtime \
&& cp -R bin core lib src mrtrix3_runtime \
&& rm -r tmp
# Stage: niftyreg
FROM builder as niftyreg
ARG NIFTYREG_VER=1.3.9
RUN wget https://sourceforge.net/projects/niftyreg/files/nifty_reg-${NIFTYREG_VER}/NiftyReg-${NIFTYREG_VER}-Linux-x86_64-Release.tar.gz/download -O /opt/niftyreg.tar.gz \
&& tar -xf /opt/niftyreg.tar.gz -C /opt \
&& mv /opt/NiftyReg-${NIFTYREG_VER}-Linux-x86_64-Release /opt/niftyreg \
&& cd /opt/niftyreg/bin \
&& ls . | grep -xv "reg_aladin" | xargs rm \
&& rm /opt/niftyreg.tar.gz
# Stage: synthstrip
FROM freesurfer/synthstrip:1.3 as synthstrip
# Stage: synthseg
FROM builder as synthseg
RUN git clone https://github.com/BBillot/Synthseg.git /opt/SynthSeg \
&& curl https://www.dropbox.com/s/i62tzl821mqi3vd/synths_models_freesurfer_7.3.2.zip -Lo synthseg_models_freesurfer_7.3.2.zip \
&& unzip -qqo synthseg_models_freesurfer_7.3.2.zip -d /opt/SynthSeg/models \
&& rm synthseg_models_freesurfer_7.3.2.zip
# Stage: workbench
FROM builder as workbench
ARG WB_VER=1.5.0
RUN wget https://humanconnectome.org/storage/app/media/workbench/workbench-linux64-v${WB_VER}.zip -O workbench.zip \
&& unzip -qq workbench.zip -d /opt \
&& rm -r /opt/workbench/plugins_linux64 \
&& rm workbench.zip
# Stage: runtime
FROM builder as runtime
WORKDIR /
COPY --from=ants \
# Commands to copy
/opt/ants/bin/antsApplyTransforms \
/opt/ants/bin/antsRegistration \
/opt/ants/bin/Atropos \
/opt/ants/bin/N4BiasFieldCorrection \
/opt/ants/bin/CreateJacobianDeterminantImage \
# Target destination
/opt/ants/bin/
COPY --from=itksnap /opt/itksnap-mini /opt/itksnap/
COPY --from=mrtrix /opt/mrtrix3/mrtrix3_runtime /opt/mrtrix3/
COPY --from=niftyreg /opt/niftyreg /opt/niftyreg/
COPY --from=synthseg /opt/SynthSeg /opt/SynthSeg/
COPY --from=synthstrip /freesurfer /opt/freesurfer/
COPY --from=workbench /opt/workbench /opt/workbench/
# FSL + cuda9.1
COPY --from=fsl /usr/local/cuda /usr/local/cuda/
COPY --from=fsl /usr/local/cuda-9.1 /usr/local/cuda-9.1/
COPY --from=fsl /usr/local/fsl /usr/local/fsl/
# Setup environments
ENV OS=Linux \
ANTSPATH=/opt/ants/bin \
FREESURFER_HOME=/opt/freesurfer \
LD_LIBRARY_PATH=/opt/itksnap/lib:/opt/niftyreg/lib:/opt/workbench/libs_linux64:/opt/workbench/libs_linux64_software_opengl:${LD_LIBRARY_PATH}:/usr/local/cuda9.1/lib64:/usr/local/fsl/lib \
PATH=/opt/ants:/opt/ants/bin:/opt/freesurfer:/opt/itksnap/bin:/opt/mrtrix3/bin:/opt/niftyreg/bin/:/opt/workbench/bin_linux64:${PATH}:/usr/local/cuda9.1/bin:/usr/local/fsl/bin \
# FSL Options
FSLDIR=/usr/local/fsl \
FSLOUTPUTTYPE=NIFTI_GZ \
FSLMULTIFILEQUIT=TRUE \
FSLTCLSH=$FSLDIR/bin/fsltclsh \
FSLWISH=$FSLDIR/bin/fslwish
COPY . /opt/pythondeps
RUN pip install --prefer-binary --no-cache-dir /opt/pythondeps && apt-get purge -y -q curl g++ unzip wget \
&& apt-get --purge -y -qq autoremove
ENTRYPOINT ["/bin/bash"]