-
Notifications
You must be signed in to change notification settings - Fork 12
/
Dockerfile
194 lines (174 loc) · 7.35 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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
FROM ubuntu:14.04
##############################################################
# Ubuntu system setup
##############################################################
ENV MAMBA_ROOT_PREFIX /opt/conda
# Disable interctive debconf post-install-configuration
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && \
apt-get -y install software-properties-common \
build-essential \
exfat-fuse \
exfat-utils \
npm \
curl \
bzip2 \
xvfb \
x11-apps \
git \
gcc-4.8 \
g++-4.8 \
cmake \
libtclap-dev \
libinsighttoolkit4.5 \
libinsighttoolkit4-dev \
libvtk5-dev \
libvtk5-qt4-dev \
libvtk5.8 \
libvtk5.8-qt4 \
tcl-vtk \
libvtk-java \
python-vtk \
python-vtkgdcm \
libncurses5 \
libncurses5-dev \
libann-dev && \
curl -L http://micro.mamba.pm/api/micromamba/linux-64/latest | \
tar -xj -C /tmp bin/micromamba && \
cp /tmp/bin/micromamba /bin/micromamba
##############################################################
# Setup and update micromamba
##############################################################
RUN mkdir -p "$(dirname $MAMBA_ROOT_PREFIX)" && \
/bin/micromamba shell init -s bash -p ~/micromamba
ENV PATH="$MAMBA_ROOT_PREFIX/bin:${PATH}"
##############################################################
# User/group creation
##############################################################
RUN groupadd -r -g 1000 mialsrtk && \
useradd -r -M -u 1000 -g mialsrtk mialsrtk
##############################################################
# Copy and compile C++ MIALSRTK code
##############################################################
# Copy only C++ source code
RUN mkdir -p /opt/mialsuperresolutiontoolkit/src
COPY src/ /opt/mialsuperresolutiontoolkit/src/
# Create the build directory and set the working directory
# to this directory
WORKDIR /opt/mialsuperresolutiontoolkit
RUN mkdir build
WORKDIR /opt/mialsuperresolutiontoolkit/build
# Configure and compile C++ MIALSRTK tools
# You can increase the number of cores used by make ("make -jN")
# to speed up local build. However, make sure that it is
# set back to make -j2 before pushing any change to GitHub.
RUN cmake \
-D CMAKE_BUILD_TYPE=Release \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D USE_OMP:BOOL=ON ../src && \
make -j6 && \
make install
##############################################################
# Python cache setup and creation of conda environment
##############################################################
# Create .cache and set right permissions for generated
# Python egg cache
RUN mkdir /.cache && \
chmod -R 777 /.cache
# Set the working directory to /app
WORKDIR /app
RUN chmod -R 777 /app
# Create the conda environment
COPY docker/bidsapp/environment.yml /app/environment.yml
RUN micromamba install -v -y -n base -f /app/environment.yml
# Note that it seems that using an environment name other
# than "base" is not recommended:
# https://github.com/mamba-org/micromamba-docker
##############################################################
# Make MIALSRTK and ANTs happy
##############################################################
ENV BIN_DIR="/usr/local/bin" \
ANTSPATH="/opt/conda/bin" \
PATH="$ANTSPATH:${BIN_DIR}:$PATH"
##############################################################
# Setup for scikit-image
#
# Commented for now as it causes issues with Singularity
# for scikit-image = 0.18.3 with OSError:
# [Errno 30] Read-only file system: '/app/skimage/0.18.3/data'
#
# The creation of the datadir for skimage has been introduced
# in 0.17 and so prior versions such as 0.16.2 should not
# perform this process, the version that is now used.
#
# See https://github.com/scikit-image/scikit-image/issues/4664
# for reference.
#
# Similar error encountered for:
# - fmriprep: https://github.com/nipreps/fmriprep/issues/1777
# - mriqc: https://neurostars.org/t/read-only-error-in-mriqc-using-singularity-on-cluster/2022
#
##############################################################
# ENV SKIMAGE_VERSION "0.18.3"
# ENV SKIMAGE_DATADIR "/app/skimage"
# RUN mkdir -p "${SKIMAGE_DATADIR}/${SKIMAGE_VERSION}" && \
# chmod -R 777 "${SKIMAGE_DATADIR}/${SKIMAGE_VERSION}"
# RUN . $CONDA_ENV_PATH/bin/activate $MY_CONDA_PY3ENV && \
# python -c "import skimage"
##############################################################
# Setup for tensorflow
##############################################################
# Filter out all messages
# ENV TF_CPP_MIN_LOG_LEVEL "0"
# Make tensorflow happy: Use jemalloc instead of malloc.
# Jemalloc suffers less from fragmentation when allocating
# and deallocating large objects
RUN apt-get update && apt-get install -y libjemalloc-dev && \
rm -rf /var/lib/apt/lists/*
ENV LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libjemalloc.so
# Use tcmalloc instead of malloc in TensorFLow
# that suffers less from fragmentation when
# allocating and deallocating large objects
# RUN apt-get update && apt-get install -y google-perftools && \
# rm -rf /var/lib/apt/lists/*
# ENV LD_PRELOAD=/usr/lib/libtcmalloc.so.4
##############################################################
# Initialize fake DISPLAY
##############################################################
ENV DISPLAY :0
##############################################################
# Copy the rest of the files (Pymialsrtk, license, readme and
# bidsapp entrypoint script) at the end to prevent recompiling
# again the C++ code even if no change was introduced
##############################################################
# Copy PyMIALSRTK code
RUN mkdir -p /opt/mialsuperresolutiontoolkit/pymialsrtk
COPY pymialsrtk/ /opt/mialsuperresolutiontoolkit/pymialsrtk/
COPY setup.py /opt/mialsuperresolutiontoolkit/setup.py
COPY get_version.py /opt/mialsuperresolutiontoolkit/get_version.py
##############################################################
# Copy LICENSE and README and .zenodo.json contributors files
##############################################################
COPY LICENSE.txt /opt/mialsuperresolutiontoolkit/LICENSE.txt
COPY README.md /opt/mialsuperresolutiontoolkit/README.md
COPY .zenodo.json /opt/mialsuperresolutiontoolkit/.zenodo.json
##############################################################
# Arguments passed to the docker build command
##############################################################
ARG BUILD_DATE
ARG VCS_REF
ARG VERSION
##############################################################
# Metadata
##############################################################
LABEL org.label-schema.build-date="$BUILD_DATE"
LABEL org.label-schema.name="MIAL Super-Resolution ToolKit Ubuntu 14.04"
LABEL org.label-schema.description="Computing environment of the MIAL Super-Resolution BIDS App based on Ubuntu 14.04."
LABEL org.label-schema.url="https://mialsrtk.readthedocs.io"
LABEL org.label-schema.vcs-ref="$VCS_REF"
LABEL org.label-schema.vcs-url="https://github.com/Medical-Image-Analysis-Laboratory/mialsuperresolutiontoolkit"
LABEL org.label-schema.version="$VERSION"
LABEL org.label-schema.maintainer="Sebastien Tourbier <sebastien.tourbier@alumni.epfl.ch>"
LABEL org.label-schema.vendor="Centre Hospitalier Universitaire Vaudois (CHUV), Lausanne, Switzerland"
LABEL org.label-schema.schema-version="1.0"
LABEL org.label-schema.docker.cmd="docker run --rm -v ~/data/bids_dataset:/tmp -t sebastientourbier/mialsuperresolutiontoolkit-ubuntu16.04:${VERSION}"