-
Notifications
You must be signed in to change notification settings - Fork 2
/
Dockerfile
106 lines (92 loc) · 3.63 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
# Use the official Python base image for x86_64
FROM --platform=linux/x86_64 python:3.11
# Download QEMU for cross-compilation
ADD https://github.com/multiarch/qemu-user-static/releases/download/v6.1.0-8/qemu-x86_64-static /usr/bin/qemu-x86_64-static
RUN chmod +x /usr/bin/qemu-x86_64-static
# Install required dependencies for FSL and Freesurfer
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
curl \
ca-certificates \
git \
tcsh \
xfonts-base \
gfortran \
libjpeg62 \
libtiff5-dev \
libpng-dev \
unzip \
libxext6 \
libx11-6 \
libxmu6 \
libglib2.0-0 \
libxft2 \
libxrender1 \
libxt6 \
ffmpeg \
libsm6
# Install Freesurfer
ENV FREESURFER_HOME="/opt/freesurfer" \
PATH="/opt/freesurfer/bin:$PATH" \
FREESURFER_VERSION=7.4.1
# copy over local freesurfer binaries
RUN mkdir /freesurfer_binaries
COPY freesurfer_binaries/* /freesurfer_binaries/
ARG USE_LOCAL_FREESURFER
RUN echo USE_LOCAL_FREESURFER=${USE_LOCAL_FREESURFER}
RUN if [ "$USE_LOCAL_FREESURFER" = "True" ]; then \
echo "Using local freesurfer binaries."; \
tar xzC /opt -f /freesurfer_binaries/freesurfer-linux-centos7_x86_64-${FREESURFER_VERSION}.tar.gz && \
echo ". /opt/freesurfer/SetUpFreeSurfer.sh" >> ~/.bashrc; \
fi && \
if [ "$USE_LOCAL_FREESURFER" = "False" ]; then \
echo "Using freesurfer binaries from surfer.nmr.mgh.harvard.edu."; \
curl -L --progress-bar https://surfer.nmr.mgh.harvard.edu/pub/dist/freesurfer/${FREESURFER_VERSION}/freesurfer-linux-centos7_x86_64-${FREESURFER_VERSION}.tar.gz | tar xzC /opt && \
echo ". /opt/freesurfer/SetUpFreeSurfer.sh" >> ~/.bashrc; \
fi
RUN rm -rf /freesurfer_binaries
# set bash as default terminal
SHELL ["/bin/bash", "-ce"]
# create directories for mounting input, output and project volumes
RUN mkdir -p /input /output /petdeface
ENV PATH="/root/.local/bin:$PATH"
# setup fs env
ENV PATH=/opt/freesurfer/bin:/opt/freesurfer/fsfast/bin:/opt/freesurfer/tktools:/opt/freesurfer/mni/bin:${PATH} \
OS=Linux \
FREESURFER_HOME=/opt/freesurfer \
FREESURFER=/opt/freesurfer \
SUBJECTS_DIR=/opt/freesurfer/subjects \
LOCAL_DIR=/opt/freesurfer/local \
FSFAST_HOME=/opt/freesurfer/fsfast \
FMRI_ANALYSIS_DIR=/opt/freesurfer/fsfast \
FUNCTIONALS_DIR=/opt/freesurfer/sessions \
FS_OVERRIDE=0 \
FIX_VERTEX_AREA="" \
FSF_OUTPUT_FORMAT=nii.gz \
MINC_BIN_DIR=/opt/freesurfer/mni/bin \
MINC_LIB_DIR=/opt/freesurfer/mni/lib \
MNI_DIR=/opt/freesurfer/mni \
MNI_DATAPATH=/opt/freesurfer/mni/data \
MNI_PERL5LIB=/opt/freesurfer/mni/share/perl5 \
PERL5LIB=/opt/freesurfer/mni/share/perl5
# copy the project
#COPY . /petdeface
COPY pyproject.toml /petdeface/pyproject.toml
COPY README.md /petdeface/README.md
COPY petdeface/ /petdeface/petdeface/
# install dependencies
RUN pip3 install --upgrade pip && cd /petdeface && pip3 install -e .
# do a bunch of folder creation before we're not root
RUN mkdir -p /.local/bin && \
mkdir -p /.cache && \
mkdir -p /.config/matplotlib && \
chmod -R 777 /.config && \
chmod -R 777 /output/ && \
chmod -R 777 /.cache/ && \
chmod -R 777 /.local/
COPY docker_deface.sh /petdeface/docker_deface.sh
# set the entrypoint to the main executable petdeface.py
# we don't run petdeface.py directly because we need to set up the ownership of the output files
# so we run a wrapper script that sets up the launches petdeface.py and sets the ownership of the output files
# on successful exit or on failure using trap.
ENTRYPOINT ["bash", "/petdeface/docker_deface.sh", "python3", "/petdeface/petdeface/petdeface.py"]