|
1 | | -# ----- 1. Create devcontainer image ----- |
2 | | -# Start from the fire-python devcontainer image that has all base dependencies |
3 | | -# Note: This does not contain the actual code for python-ismrmrd-server! |
4 | | -FROM kspacekelvin/fire-python-devcon AS python-mrd-pytorch-devcontainer |
| 1 | +# ----- 1. First stage to build ismrmrd and siemens_to_ismrmrd ----- |
| 2 | +FROM pytorch/pytorch:2.3.0-cuda11.8-cudnn8-runtime AS mrd_converter |
| 3 | +ARG DEBIAN_FRONTEND=noninteractive |
| 4 | +ENV TZ=America/Chicago |
5 | 5 |
|
6 | | -# Install PyTorch and its dependencies |
7 | | -RUN pip3 install --no-cache-dir torch torchvision \ |
8 | | - && rm -rf /root/.cache/pip |
| 6 | +RUN apt-get update && apt-get install -y git cmake g++ libhdf5-dev libxml2-dev libxslt1-dev libboost-all-dev libfftw3-dev libpugixml-dev |
| 7 | +RUN mkdir -p /opt/code |
9 | 8 |
|
10 | | -# ----- 2. Copy deployed code into the devcontainer for deployment ----- |
11 | | -FROM python-mrd-pytorch-devcontainer as python-mrd-pytorch-runtime |
| 9 | +# ISMRMRD library |
| 10 | +RUN cd /opt/code && \ |
| 11 | + git clone https://github.com/ismrmrd/ismrmrd.git && \ |
| 12 | + cd ismrmrd && \ |
| 13 | + git checkout d364e03 && \ |
| 14 | + mkdir build && \ |
| 15 | + cd build && \ |
| 16 | + cmake ../ && \ |
| 17 | + make -j $(nproc) && \ |
| 18 | + make install |
| 19 | + |
| 20 | +# siemens_to_ismrmrd converter |
| 21 | +RUN cd /opt/code && \ |
| 22 | + git clone https://github.com/ismrmrd/siemens_to_ismrmrd.git && \ |
| 23 | + cd siemens_to_ismrmrd && \ |
| 24 | + git checkout v1.2.11 && \ |
| 25 | + mkdir build && \ |
| 26 | + cd build && \ |
| 27 | + cmake ../ && \ |
| 28 | + make -j $(nproc) && \ |
| 29 | + make install |
| 30 | + |
| 31 | +# Create archive of ISMRMRD libraries (including symlinks) for second stage |
| 32 | +RUN cd /usr/local/lib && tar -czvf libismrmrd.tar.gz libismrmrd* |
| 33 | + |
| 34 | +# ----- 2. Create a devcontainer without all of the build dependencies of MRD ----- |
| 35 | +FROM pytorch/pytorch:2.3.0-cuda11.8-cudnn8-runtime AS python-mrd-cuda-devcontainer |
| 36 | + |
| 37 | +LABEL org.opencontainers.image.description="Python MRD Image Reconstruction and Analysis Server" |
| 38 | +LABEL org.opencontainers.image.url="https://github.com/kspaceKelvin/python-ismrmrd-server" |
| 39 | +LABEL org.opencontainers.image.authors="Kelvin Chow (kelvin.chow@siemens-healthineers.com)" |
| 40 | + |
| 41 | +# Copy ISMRMRD files from last stage |
| 42 | +COPY --from=mrd_converter /usr/local/include/ismrmrd /usr/local/include/ismrmrd/ |
| 43 | +COPY --from=mrd_converter /usr/local/share/ismrmrd /usr/local/share/ismrmrd/ |
| 44 | +COPY --from=mrd_converter /usr/local/bin/ismrmrd* /usr/local/bin/ |
| 45 | +COPY --from=mrd_converter /usr/local/lib/libismrmrd.tar.gz /usr/local/lib/ |
| 46 | +RUN cd /usr/local/lib && tar -zxvf libismrmrd.tar.gz && rm libismrmrd.tar.gz && ldconfig |
| 47 | + |
| 48 | +# Copy siemens_to_ismrmrd from last stage |
| 49 | +COPY --from=mrd_converter /usr/local/bin/siemens_to_ismrmrd /usr/local/bin/siemens_to_ismrmrd |
| 50 | + |
| 51 | +# Add dependencies for siemens_to_ismrmrd |
| 52 | +RUN apt-get update && apt-get install --no-install-recommends -y libxslt1.1 libhdf5-103 libboost-program-options1.74.0 libpugixml1v5 git dos2unix nano |
| 53 | +RUN mkdir -p /opt/code |
| 54 | + |
| 55 | +# Tell nano to remember its position from the last time it opened a file |
| 56 | +RUN echo "set positionlog" > ~/.nanorc |
| 57 | + |
| 58 | +# Python MRD library |
| 59 | +RUN pip3 install h5py==3.10.0 ismrmrd==1.14.1 |
| 60 | + |
| 61 | +RUN cd /opt/code && \ |
| 62 | + git clone https://github.com/ismrmrd/ismrmrd-python-tools.git && \ |
| 63 | + cd /opt/code/ismrmrd-python-tools && \ |
| 64 | + pip3 install --no-cache-dir . |
| 65 | + |
| 66 | +# matplotlib is used by rgb.py and provides various visualization tools including colormaps |
| 67 | +# pydicom is used by dicom2mrd.py to parse DICOM data |
| 68 | +RUN pip3 install --no-cache-dir matplotlib==3.8.2 pydicom==3.0.1 |
| 69 | + |
| 70 | +# Cleanup files not required after installation |
| 71 | +RUN apt-get clean && \ |
| 72 | + rm -rf /var/lib/apt/lists/* && \ |
| 73 | + rm -rf /root/.cache/pip |
| 74 | + |
| 75 | +# ----- 3. Copy deployed code into the devcontainer for deployment ----- |
| 76 | +FROM python-mrd-cuda-devcontainer AS python-mrd-runtime |
12 | 77 |
|
13 | 78 | # If building from the GitHub repo, uncomment the below section, open a command |
14 | 79 | # prompt in the folder containing this Dockerfile and run the command: |
|
0 commit comments