Skip to content

Commit 1386f52

Browse files
committed
[FIX] TemplateFlow + docker run -u ...
1 parent 4470ffb commit 1386f52

File tree

1 file changed

+27
-22
lines changed

1 file changed

+27
-22
lines changed

Dockerfile

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
FROM ubuntu:xenial-20161213
33

44
# Pre-cache neurodebian key
5-
COPY docker/files/neurodebian.gpg /root/.neurodebian.gpg
5+
COPY docker/files/neurodebian.gpg /usr/local/etc/neurodebian.gpg
66

77
# Prepare environment
88
RUN apt-get update && \
@@ -67,7 +67,7 @@ ENV PERL5LIB="$MINC_LIB_DIR/perl5/5.8.5" \
6767

6868
# Installing Neurodebian packages (FSL, AFNI, git)
6969
RUN curl -sSL "http://neuro.debian.net/lists/$( lsb_release -c | cut -f2 ).us-ca.full" >> /etc/apt/sources.list.d/neurodebian.sources.list && \
70-
apt-key add /root/.neurodebian.gpg && \
70+
apt-key add /usr/local/etc/neurodebian.gpg && \
7171
(apt-key adv --refresh-keys --keyserver hkp://ha.pool.sks-keyservers.net 0xA5D32F012649A5A9 || true)
7272

7373
RUN apt-get update && \
@@ -98,6 +98,10 @@ RUN mkdir -p $ANTSPATH && \
9898
| tar -xzC $ANTSPATH --strip-components 1
9999
ENV PATH=$ANTSPATH:$PATH
100100

101+
# Create a shared $HOME directory
102+
WORKDIR /home/fmriprep
103+
ENV HOME="/home/fmriprep"
104+
101105
# Installing SVGO
102106
RUN curl -sL https://deb.nodesource.com/setup_10.x | bash -
103107
RUN apt-get install -y nodejs
@@ -142,41 +146,40 @@ RUN conda install -y python=3.7.1 \
142146
zlib; sync && \
143147
chmod -R a+rX /usr/local/miniconda; sync && \
144148
chmod +x /usr/local/miniconda/bin/*; sync && \
145-
conda clean --all -y; sync && \
149+
conda build purge-all; sync && \
146150
conda clean -tipsy && sync
147151

148152
# Precaching fonts, set 'Agg' as default backend for matplotlib
149153
RUN python -c "from matplotlib import font_manager" && \
150154
sed -i 's/\(backend *: \).*$/\1Agg/g' $( python -c "import matplotlib; print(matplotlib.matplotlib_fname())" )
151-
RUN pip install "datalad==0.10.0" && \
152-
rm -rf ~/.cache/pip
155+
RUN pip install --no-cache-dir "datalad==0.10.0"
153156

154157
# Unless otherwise specified each process should only use one thread - nipype
155158
# will handle parallelization
156159
ENV MKL_NUM_THREADS=1 \
157160
OMP_NUM_THREADS=1
158161

159162
# Precaching atlases
160-
RUN git config --global user.name "fMRIPrep User" && \
161-
git config --global user.email "[email protected]"
162-
ENV TEMPLATEFLOW_HOME="/opt/templateflow"
163-
WORKDIR /opt
163+
WORKDIR /home/fmriprep/.cache
164164
RUN datalad install -r https://github.com/templateflow/templateflow.git
165-
RUN datalad get $TEMPLATEFLOW_HOME/tpl-MNI152NLin2009cAsym/* \
166-
$TEMPLATEFLOW_HOME/tpl-MNI152Lin/* \
167-
$TEMPLATEFLOW_HOME/tpl-OASIS30ANTs/* \
168-
$TEMPLATEFLOW_HOME/tpl-NKI/*
169-
RUN git -C $TEMPLATEFLOW_HOME config annex.merge-annex-branches false && \
170-
git -C $TEMPLATEFLOW_HOME/tpl-MNI152NLin2009cAsym config annex.merge-annex-branches false && \
171-
git -C $TEMPLATEFLOW_HOME/tpl-MNI152Lin config annex.merge-annex-branches false && \
172-
git -C $TEMPLATEFLOW_HOME/tpl-OASIS30ANTs config annex.merge-annex-branches false && \
173-
git -C $TEMPLATEFLOW_HOME/tpl-NKI config annex.merge-annex-branches false
165+
WORKDIR /home/fmriprep/.cache/templateflow
166+
RUN git config user.name "fMRIPrep User" && \
167+
git config user.email "[email protected]"
168+
RUN datalad get tpl-MNI152NLin2009cAsym/* \
169+
tpl-MNI152Lin/* \
170+
tpl-OASIS30ANTs/* \
171+
tpl-NKI/* && \
172+
rm -rf /home/fmriprep/.cache/datalad
173+
RUN git -C . config annex.merge-annex-branches false && \
174+
git -C tpl-MNI152NLin2009cAsym config annex.merge-annex-branches false && \
175+
git -C tpl-MNI152Lin config annex.merge-annex-branches false && \
176+
git -C tpl-OASIS30ANTs config annex.merge-annex-branches false && \
177+
git -C tpl-NKI config annex.merge-annex-branches false
174178

175179
# Installing dev requirements (packages that are not in pypi)
176180
WORKDIR /src/
177181
COPY requirements.txt requirements.txt
178-
RUN pip install -r requirements.txt && \
179-
rm -rf ~/.cache/pip
182+
RUN pip install --no-cache-dir -r requirements.txt
180183

181184
# Installing FMRIPREP
182185
COPY . /src/fmriprep
@@ -185,13 +188,15 @@ ARG VERSION
185188
RUN echo "${VERSION}" > /src/fmriprep/fmriprep/VERSION && \
186189
echo "include fmriprep/VERSION" >> /src/fmriprep/MANIFEST.in && \
187190
cd /src/fmriprep && \
188-
pip install .[all] && \
189-
rm -rf ~/.cache/pip
191+
pip install --no-cache-dir .[all]
190192

191193
RUN install -m 0755 \
192194
/src/fmriprep/scripts/generate_reference_mask.py \
193195
/usr/local/bin/generate_reference_mask
194196

197+
RUN find $HOME -type d -exec chmod go=u {} + && \
198+
find $HOME -type f -exec chmod go=u {} +
199+
195200
ENV IS_DOCKER_8395080871=1
196201

197202
RUN ldconfig

0 commit comments

Comments
 (0)