-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDockerfile.pnlpipe
126 lines (112 loc) · 5.03 KB
/
Dockerfile.pnlpipe
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
FROM centos:7.5.1804
MAINTAINER Tashrif Billah <tbillah@bwh.harvard.edu>
# set up working directory, redefine home directory, remain root user
WORKDIR /home/pnlbwh
ENV HOME=/home/pnlbwh
ENV USER="root"
ENV LANG=en_US.UTF-8
COPY startup.sh /
COPY Slicer-29402.ini /
COPY .vimrc $HOME/
# install required libraries
RUN ln -sf /usr/share/zoneinfo/America/New_York /etc/localtime && \
yum -y groupinstall 'development tools' && \
yum -y install tree wget file bzip2 which vim git make libstdc++-static mesa-libGL bc tcsh libSM libXt-devel \
psmisc && \
#
# libraries for SlicerDMRI/FiberTractMeasurements
yum -y install libGLU libXrender && \
yum clean all && \
rm -rf /var/cache/yum && \
#
# install freesurfer
echo "Downloading FreeSurfer" && \
wget https://surfer.nmr.mgh.harvard.edu/pub/dist/freesurfer/7.1.0/freesurfer-linux-centos7_x86_64-7.1.0.tar.gz > /dev/null 2>&1 && \
echo "Unzipping FreeSurfer tar ball" && \
tar -xzf freesurfer-linux-centos7_x86_64-7.1.0.tar.gz && \
rm -f freesurfer-linux-centos7_x86_64-7.1.0.tar.gz && \
mv freesurfer freesurfer-7.1.0 && \
#
# install MCR for -subfields
cd freesurfer-7.1.0 && \
curl "https://surfer.nmr.mgh.harvard.edu/fswiki/MatlabRuntime?action=AttachFile&do=get&target=runtime2014bLinux.tar.gz" -o "runtime2014b.tar.gz" && \
tar -xzf runtime2014b.tar.gz && rm -f runtime2014b.tar.gz && \
cd .. && \
#
# install FSL
echo "Downloading FSL installer" && \
wget https://fsl.fmrib.ox.ac.uk/fsldownloads/fslinstaller.py -O fslinstaller.py > /dev/null 2>&1 && \
echo "Installing FSL" && \
python fslinstaller.py -V 6.0.1 -d $HOME/fsl-6.0.1 -p > /dev/null 2>&1 && \
# setup FSL environment
export FSLDIR=$HOME/fsl-6.0.1 && \
source $FSLDIR/etc/fslconf/fsl.sh && \
$FSLDIR/fslpython/bin/conda clean -y --all && \
rm -f fslinstaller.py
# clone pnlpipe repositories
RUN git clone --recurse-submodules https://github.com/pnlbwh/pnlpipe.git && \
git clone https://github.com/pnlbwh/pnlNipype.git && \
git clone https://github.com/pnlbwh/luigi-pnlpipe.git && \
#
# install CNN-Diffusion-MRIBrain-Segmentation
git clone https://github.com/pnlbwh/CNN-Diffusion-MRIBrain-Segmentation.git && \
cd CNN-Diffusion-MRIBrain-Segmentation && \
wget https://github.com/pnlbwh/CNN-Diffusion-MRIBrain-Segmentation/releases/download/v0.3/model_folder.tar.gz && \
tar -xzvf model_folder.tar.gz
# install miniconda3
RUN wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O Miniconda3-latest-Linux-x86_64.sh && \
/bin/bash Miniconda3-latest-Linux-x86_64.sh -b -p miniconda3/ && \
#
# initialize bashrc
cp /root/.bashrc $HOME/ && \
echo "source $HOME/miniconda3/bin/activate" >> ~/.bashrc && \
#
# create conda env
source miniconda3/bin/activate && \
conda env create -f pnlpipe/python_env/environment36.yml && \
echo "conda activate pnlpipe3" >> ~/.bashrc && \
#
# clean up conda cache
conda deactivate && \
conda clean -y --all && \
rm -rf $HOME/Miniconda3-latest-Linux-x86_64.sh .cache/pip/*
# conda activate is required again because we are beginning a different RUN i.e. shell
RUN source miniconda3/bin/activate && \
conda activate pnlpipe3 && \
export FREESURFER_HOME=$HOME/freesurfer-7.1.0 && \
#
# build pnlpipe dependencies
cd pnlpipe && mkdir soft_dir && export PNLPIPE_SOFT=$HOME/pnlpipe/soft_dir && \
./pnlpipe std init && \
./pnlpipe std setup && \
#
# clean up sources
cd soft_dir && \
rm -rf BRAINSTools BRAINSTools-build ANTs ANTs-build ANTs-bin-*/CMakeFiles ukftractography UKFTractography-build dcm2niix && \
rm -rf /tmp/* /var/tmp/*
# set up bashrc i.e shell
RUN echo "export PNLPIPE_SOFT=$HOME/pnlpipe/soft_dir" >> ~/.bashrc && \
echo "alias ls=\"ls --color\"" >> ~/.bashrc && \
cd $HOME/pnlpipe/soft_dir && \
for d in `find . -name env.sh`; do echo "source \${PNLPIPE_SOFT}/$d" >> ~/.bashrc; done && \
cd $HOME && \
echo "export FSLDIR=$HOME/fsl-6.0.1" >> ~/.bashrc && \
echo "source \$FSLDIR/etc/fslconf/fsl.sh" >> ~/.bashrc && \
echo "export PATH=\$FSLDIR/bin:\$PATH" >> ~/.bashrc && \
echo "export FREESURFER_HOME=$HOME/freesurfer-7.1.0" >> ~/.bashrc && \
echo "source \${FREESURFER_HOME}/SetUpFreeSurfer.sh" >> ~/.bashrc && \
echo "export PATH=$HOME/pnlNipype/scripts:$HOME/pnlNipype/exec:$HOME/CNN-Diffusion-MRIBrain-Segmentation/pipeline:\$PATH" >> ~/.bashrc && \
echo "export PYTHONPATH=$HOME/luigi-pnlpipe:\$PYTHONPATH" >> ~/.bashrc && \
#
# remove problematic aliases
sed -i "s/alias mv='mv -i'//g" ~/.bashrc && \
sed -i "s/alias cp='cp -i'//g" ~/.bashrc && \
sed -i "s/alias rm='rm -i'//g" ~/.bashrc && \
#
# facilitate creation of ~/matlab/startup.m
export FREESURFER_HOME=$HOME/freesurfer-7.1.0 && \
source ${FREESURFER_HOME}/SetUpFreeSurfer.sh && \
#
# change permission of startup script
chmod +x /startup.sh
ENTRYPOINT ["/startup.sh"]