-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathDockerfile
More file actions
144 lines (125 loc) · 5.07 KB
/
Dockerfile
File metadata and controls
144 lines (125 loc) · 5.07 KB
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
# syntax=docker/dockerfile:1
ARG BASE_IMAGE=quay.io/jupyter/scipy-notebook:ubuntu-22.04
FROM ${BASE_IMAGE} AS base
USER root
# suppress warnings
ENV DEBIAN_FRONTEND=noninteractive
COPY docker/raw-ubuntu.sh /opt/scripts/
RUN bash /opt/scripts/raw-ubuntu.sh
#ENV LC_ALL=en_GB.UTF-8
ENV LANG=en_GB.UTF-8
ENV LANGUAGE=en_GB:en
COPY docker/build_gadgetron-ubuntu.sh /opt/scripts/
RUN bash /opt/scripts/build_gadgetron-ubuntu.sh
# SIRF external deps
COPY docker/build_system-ubuntu.sh /opt/scripts/
RUN bash /opt/scripts/build_system-ubuntu.sh
# SIRF python deps
ARG BUILD_GPU=0
ARG BUILD_CIL="ON"
COPY docker/requirements.yml /opt/scripts/
# https://jupyter-docker-stacks.readthedocs.io/en/latest/using/common.html#conda-environments
# https://github.com/TomographicImaging/CIL/blob/master/Dockerfile
RUN if test "$BUILD_GPU" != 0; then \
sed -ri 's/^(\s*)#\s*(- \S+.*#.*GPU.*)$/\1\2/' /opt/scripts/requirements.yml; \
fi \
&& if test "$BUILD_CIL" != "OFF"; then \
sed -r -i -e '/^\s*- (cil|ccpi-regulariser).*/d' /opt/scripts/requirements.yml; \
fi \
&& conda config --env --set channel_priority strict \
&& for ch in defaults ccpi conda-forge; do conda config --env --add channels $ch; done \
&& mamba env update -n base -f /opt/scripts/requirements.yml \
&& mamba clean --all -f -y && fix-permissions "${CONDA_DIR}" /home/${NB_USER}
FROM base AS build
COPY docker/update_nvidia_keys.sh /opt/scripts/
RUN bash /opt/scripts/update_nvidia_keys.sh
COPY docker/build_essential-ubuntu.sh /opt/scripts/
RUN bash /opt/scripts/build_essential-ubuntu.sh
# ccache
COPY --link docker/devel/.ccache/ /opt/ccache/
RUN ccache -o cache_dir=/opt/ccache
ENV PATH="/usr/lib/ccache:${PATH}"
# SIRF-SuperBuild config
COPY ./.git /opt/SIRF-SuperBuild.git
ARG SIRF_SB_URL="file:///opt/SIRF-SuperBuild.git"
ARG SIRF_SB_TAG="HEAD"
ARG REMOVE_BUILD_FILES=0
ARG RUN_CTEST=1
ARG NUM_PARALLEL_BUILDS=" "
# CMake options
ARG CMAKE_BUILD_TYPE="Release"
ARG STIR_ENABLE_OPENMP="ON"
ARG STIR_DISABLE_HDF5="OFF"
ARG USE_SYSTEM_Armadillo="ON"
ARG USE_SYSTEM_Boost="OFF"
ARG USE_SYSTEM_FFTW3="ON"
ARG USE_SYSTEM_HDF5="ON"
ARG USE_ITK="ON"
ARG USE_SYSTEM_SWIG="ON"
ARG USE_NiftyPET="OFF"
ARG BUILD_siemens_to_ismrmrd="ON"
ARG BUILD_pet_rd_tools="ON"
ARG Gadgetron_USE_CUDA="ON"
# BUILD_CIL is defined in the previous stage
ARG BUILD_CIL
ARG EXTRA_BUILD_FLAGS=""
# build, install in /opt/SIRF-SuperBuild/{INSTALL,sources/SIRF}, test (if RUN_CTEST)
COPY docker/user_sirf-ubuntu.sh /opt/scripts/
RUN BUILD_FLAGS="-G Ninja\
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}\
-DSTIR_ENABLE_OPENMP=${STIR_ENABLE_OPENMP}\
-DSTIR_DISABLE_HDF5=${STIR_DISABLE_HDF5}\
-DUSE_SYSTEM_Armadillo=${USE_SYSTEM_Armadillo}\
-DUSE_SYSTEM_Boost=${USE_SYSTEM_Boost}\
-DUSE_SYSTEM_FFTW3=${USE_SYSTEM_FFTW3}\
-DUSE_SYSTEM_HDF5=${USE_SYSTEM_HDF5}\
-DUSE_ITK=${USE_ITK}\
-DUSE_SYSTEM_SWIG=${USE_SYSTEM_SWIG}\
-DUSE_NiftyPET=${USE_NiftyPET}\
-DPATCH_ISMRMRD=ON\
-DBUILD_siemens_to_ismrmrd=${BUILD_siemens_to_ismrmrd}\
-DBUILD_pet_rd_tools=${BUILD_pet_rd_tools}\
-DGadgetron_USE_CUDA=${Gadgetron_USE_CUDA}\
-DBUILD_CIL=${BUILD_CIL}" \
EXTRA_BUILD_FLAGS="${EXTRA_BUILD_FLAGS}" \
RUN_CTEST=0 \
bash /opt/scripts/user_sirf-ubuntu.sh \
&& fix-permissions /opt/SIRF-SuperBuild /opt/ccache
# test (if RUN_CTEST)
RUN RUN_BUILD=0 \
bash /opt/scripts/user_sirf-ubuntu.sh \
&& fix-permissions /opt/SIRF-SuperBuild /opt/ccache
FROM base AS sirf
# X11 forwarding
RUN apt update -qq && apt install -yq --no-install-recommends \
libx11-xcb1 \
&& apt clean \
&& mkdir -p /usr/share/X11/xkb \
&& test -e /usr/bin/X || ln -s /usr/bin/Xorg /usr/bin/X
RUN echo 'test -z "$OMP_NUM_THREADS" && export OMP_NUM_THREADS=$(python -c "import multiprocessing as mc; print(max(1, mc.cpu_count() - 2))")' > /usr/local/bin/before-notebook.d/omp_num_threads.sh
COPY --chown=${NB_USER} --chmod=644 --link docker/.bashrc /home/${NB_USER}/
# RUN sed -i s:PYTHON_INSTALL_DIR:${CONDA_DIR}:g /home/${NB_USER}/.bashrc
# install from build
COPY --from=build --link --chown=${NB_USER} /opt/SIRF-SuperBuild/INSTALL/ /opt/SIRF-SuperBuild/INSTALL/
#COPY --from=build --link --chown=${NB_USER} /opt/SIRF-SuperBuild/sources/SIRF/ /opt/SIRF-SuperBuild/sources/SIRF/
# PYTHON_VERSION site-packages
COPY --from=build --link /opt/conda/lib/python3.12/site-packages/ /opt/conda/lib/python3.12/site-packages/
# install {SIRF-Exercises,CIL-Demos}
COPY docker/user_demos.sh /opt/scripts/
ARG BUILD_GPU
RUN BUILD_GPU=${BUILD_GPU} bash /opt/scripts/user_demos.sh \
&& fix-permissions /opt/SIRF-Exercises /opt/CIL-Demos "${CONDA_DIR}" /home/${NB_USER}
# docker-stacks notebook
USER ${NB_UID}
ENV DEBIAN_FRONTEND=''
#ENV DOCKER_STACKS_JUPYTER_CMD="notebook"
ENV RESTARTABLE="yes"
#ENV USE_HTTPS="yes"
# gadgetron
EXPOSE 9002
ENV GADGETRON_RELAY_HOST="0.0.0.0"
# run gadgetron in the background before start-notebook.py
COPY --link --chown=${NB_USER} docker/start-gadgetron-notebook.sh /opt/scripts/
# COPY --from=build --link --chown=${NB_USER} /opt/SIRF-SuperBuild/INSTALL/lib /opt/conda/lib
COPY --from=build --link --chown=${NB_USER} /opt/SIRF-SuperBuild/INSTALL/bin/env_sirf.sh /opt/conda/etc/conda/activate.d
CMD ["/opt/scripts/start-gadgetron-notebook.sh"]