-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDockerfile
More file actions
97 lines (83 loc) · 3.71 KB
/
Copy pathDockerfile
File metadata and controls
97 lines (83 loc) · 3.71 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
# Stage 1: build the scanbuddy_snr Rust extension
FROM rockylinux:8 AS rust-builder
RUN dnf install -y epel-release && \
dnf install -y gcc make openssl-devel perl-IPC-Cmd curl && \
dnf clean all
# install Rust toolchain
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
ENV PATH="/root/.cargo/bin:${PATH}"
# install miniforge and create free-threaded Python env for maturin
ARG MFG_PREFIX="/sw/miniforge"
RUN curl -sL "https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Linux-$(uname -m).sh" -o /tmp/miniforge.sh && \
bash /tmp/miniforge.sh -b -p "${MFG_PREFIX}" && \
rm /tmp/miniforge.sh
ENV PATH="${MFG_PREFIX}/bin:${PATH}"
RUN conda create -y -n python3.14t --override-channels -c conda-forge python-freethreading=3.14
RUN /sw/miniforge/envs/python3.14t/bin/pip install maturin numpy
# build the wheel
COPY rust_snr_calculation /tmp/rust_snr_calculation
WORKDIR /tmp/rust_snr_calculation
RUN rm -rf target && \
/sw/miniforge/envs/python3.14t/bin/maturin build --release \
--interpreter /sw/miniforge/envs/python3.14t/bin/python3
# Stage 2: final image
FROM rockylinux:8
# install EPEL repository and base packages
RUN dnf install -y epel-release && \
dnf install -y git vim htop && \
dnf clean all
# create a home directory
RUN mkdir -p /home/scanbuddy
ENV HOME=/home/scanbuddy
# compile and install 3dvolreg from AFNI (linux/amd64 and linux/arm64/v8)
ARG AFNI_PREFIX="/sw/apps/afni"
ARG AFNI_URI="https://github.com/afni/afni"
WORKDIR /tmp
RUN dnf install -y epel-release && \
dnf install -y --allowerasing curl tcsh libpng15 motif && \
dnf install -y make clang zlib-devel libXt-devel libXext-devel expat-devel motif-devel f2c && \
git clone "${AFNI_URI}"
WORKDIR afni/src
RUN cp other_builds/Makefile.linux_ubuntu_22_64 Makefile && \
make libmri.a 3dvolreg && \
mkdir -p "${AFNI_PREFIX}" && \
mv 3dvolreg "${AFNI_PREFIX}" && \
rm -r /tmp/afni
ENV PATH="${AFNI_PREFIX}:${PATH}"
# compile and install dcm2niix (linux/amd64 and linux/arm64/v8)
ARG D2N_PREFIX="/sw/apps/dcm2niix"
ARG D2N_VERSION="1.0.20220720"
ARG D2N_URI="https://github.com/rordenlab/dcm2niix/archive/refs/tags/v${D2N_VERSION}.zip"
WORKDIR /tmp
RUN dnf install -y unzip cmake gcc-c++ && \
dnf --enablerepo=powertools install -y libstdc++-static && \
curl -sL "${D2N_URI}" -o "dcm2niix_src.zip" && \
unzip "dcm2niix_src.zip" && \
rm "dcm2niix_src.zip" && \
mkdir "dcm2niix-${D2N_VERSION}/build"
WORKDIR "/tmp/dcm2niix-${D2N_VERSION}/build"
RUN cmake .. && \
make && \
mkdir -p "${D2N_PREFIX}" && \
cp bin/dcm2niix "${D2N_PREFIX}" && \
rm -r "/tmp/dcm2niix-${D2N_VERSION}"
ENV PATH="${D2N_PREFIX}:${PATH}"
# install miniforge
ARG MFG_PREFIX="/sw/miniforge"
WORKDIR /tmp
RUN curl -sL "https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Linux-$(uname -m).sh" -o "miniforge.sh"
RUN bash "miniforge.sh" -b -p "${MFG_PREFIX}" && \
rm "miniforge.sh"
ENV PATH="${MFG_PREFIX}/bin:${PATH}"
# install specific mamba version (1.5.12)
RUN conda install -y -n base -c conda-forge mamba=1.5.12
# install scanbuddy with python-freethreading
RUN mamba create -y -n python3.14t --override-channels -c conda-forge python-freethreading=3.14
RUN mamba env config vars set PYTHON_GIL=0 -n python3.14t
COPY . /tmp/scanbuddy
RUN mamba run -n python3.14t --no-capture-output python3 -m pip install /tmp/scanbuddy
# install the pre-built scanbuddy_snr wheel from the builder stage
COPY --from=rust-builder /tmp/rust_snr_calculation/target/wheels/*.whl /tmp/
RUN mamba run -n python3.14t --no-capture-output python3 -m pip install /tmp/scanbuddy_snr*.whl && \
rm /tmp/*.whl
ENTRYPOINT ["mamba", "run", "-n", "python3.14t", "--no-capture-output", "start.py"]