File: Dockerfile

package info (click to toggle)
ismrmrd 1.15.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,576 kB
  • sloc: cpp: 6,439; ansic: 2,276; xml: 1,025; sh: 242; python: 72; makefile: 42
file content (130 lines) | stat: -rw-r--r-- 5,284 bytes parent folder | download
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
#########################################################
# file-normalizer stage
# In order to use BuildKit remote caching, input files must have
# not only the right content hash, but also the right permissions.
# Git only tracks whether the owner can execute a file.
# Here we bring in all files that are going to be used in the
# subsequent stage and normalize the permissions.
#########################################################

FROM mcr.microsoft.com/oss/busybox/busybox:1.33.1 AS file-normalizer

COPY environment.yml .devcontainer/devcontainer.bashrc /data/
RUN chmod -R 555 /data/

RUN mkdir -p /entrypoints
COPY docker/entrypoint.sh /entrypoints/
COPY docker/entrypoint-stream.sh /entrypoints/

RUN sed -i 's/\r$//' /entrypoints/*.sh
RUN chmod +x /entrypoints/*.sh

FROM mcr.microsoft.com/devcontainers/base:ubuntu-24.04 AS basecontainer

# Install needed packages and setup non-root user.
ARG USERNAME="vscode"
ARG USER_UID=1000
ARG USER_GID=$USER_UID
ARG CONDA_GID=900
ARG CONDA_ENVIRONMENT_NAME=ismrmrd

RUN apt-get update && apt-get install -y \
    libc6-dbg \
    && rm -rf /var/lib/apt/lists/*

ARG MINIFORGE_VERSION=25.11.0-1

# Based on https://github.com/conda-forge/miniforge-images/blob/master/ubuntu/Dockerfile
RUN wget --no-hsts --quiet https://github.com/conda-forge/miniforge/releases/download/${MINIFORGE_VERSION}/Miniforge3-${MINIFORGE_VERSION}-Linux-$(uname -m).sh -O /tmp/miniforge.sh \
    && /bin/bash /tmp/miniforge.sh -b -p /opt/conda \
    && rm /tmp/miniforge.sh \
    && /opt/conda/bin/conda clean --tarballs --index-cache --packages --yes \
    && find /opt/conda -follow -type f -name '*.a' -delete \
    && find /opt/conda -follow -type f -name '*.pyc' -delete \
    && /opt/conda/bin/conda clean --force-pkgs-dirs --all --yes  \
    && groupadd -r conda --gid ${CONDA_GID} \
    && usermod -aG conda ${USERNAME} \
    && chown -R :conda /opt/conda \
    && chmod -R g+w /opt/conda \
    && find /opt -type d | xargs -n 1 chmod g+s

FROM basecontainer AS devcontainer

ARG USER_UID
ARG USER_GID

# Create a conda environment from the environment file in the repo root.
COPY --from=file-normalizer --chown=$USER_UID:conda /data/environment.yml /tmp/build/
RUN umask 0002 \
    && /opt/conda/bin/conda env create -f /tmp/build/environment.yml \
    && /opt/conda/bin/conda clean -fy \
    && sudo chown -R :conda /opt/conda/envs

# Add a file that is to be sourced from .bashrc and from the devops pipeline stages
COPY --from=file-normalizer /data/devcontainer.bashrc /opt/devcontainer/

# Add a section to /etc/bash.bashrc that ensures that a section is present at the end of ~/.bashrc.
# We can't just write to .bashrc from here because it will be overwritten if the devcontainer user has
# opted to use their own dotfiles repo. The dotfiles repo is cloned after the postCreateCommand
# in the devcontainer.json file is executed.
RUN echo "\n\
if ! grep -q \"^source /opt/devcontainer/devcontainer.bashrc\" \${HOME}/.bashrc; then\n\
	echo \"source /opt/devcontainer/devcontainer.bashrc\" >> \${HOME}/.bashrc\n\
fi\n" >> /etc/bash.bashrc

ENV CMAKE_GENERATOR=Ninja

# Create a kits file for the VSCode CMake Tools extension, so you are not prompted for which kit to select whenever you open VSCode
RUN mkdir -p /home/vscode/.local/share/CMakeTools \
    && echo '[{"name":"GCC-15","compilers":{"C":"/opt/conda/envs/ismrmrd/bin/x86_64-conda-linux-gnu-gcc","CXX":"/opt/conda/envs/ismrmrd/bin/x86_64-conda-linux-gnu-g++"}}]' > /home/vscode/.local/share/CMakeTools/cmake-tools-kits.json \
    && chown vscode:conda /home/vscode/.local/share/CMakeTools/cmake-tools-kits.json

FROM devcontainer AS ismrmrd-build

ARG USER_UID
ARG USER_GID
SHELL ["/bin/bash", "-c"]
COPY --chown=$USER_UID:$USER_GID . /opt/code/ismrmrd/

RUN . /opt/conda/etc/profile.d/conda.sh && umask 0002 && conda activate ismrmrd && mkdir -p /opt/package && \
    cd /opt/code/ismrmrd && \
    mkdir build && \
    cd build && \
    cmake -GNinja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/opt/package ../ && \
    ninja && \
    ninja install

FROM ismrmrd-build AS ismrmrd-test

ENTRYPOINT [ "/opt/code/ismrmrd/docker/entrypoint.sh", "python", "/opt/code/ismrmrd/docker/validate_results.py" ]

FROM basecontainer AS ismrmrd

ARG USER_UID

RUN apt-get update && apt-get install -y socat \
    && rm -rf /var/lib/apt/lists/*

COPY --from=file-normalizer --chown=$USER_UID:conda /data/environment.yml /tmp/build/
RUN grep -v "#.*\<dev\>" /tmp/build/environment.yml > /tmp/build/filtered_environment.yml \
    && mv /tmp/build/filtered_environment.yml /tmp/build/environment.yml \
    && umask 0002 \
    && /opt/conda/bin/conda env create -f /tmp/build/environment.yml \
    && /opt/conda/bin/conda clean -fy \
    && sudo chown -R :conda /opt/conda/envs

COPY --from=ismrmrd-build --chown=$USER_UID:conda /opt/package /opt/conda/envs/ismrmrd/
COPY --from=file-normalizer --chown=$USER_UID:conda /entrypoints/entrypoint.sh /opt/
COPY --from=file-normalizer --chown=$USER_UID:conda /entrypoints/entrypoint-stream.sh /opt/

ENTRYPOINT [ "/opt/entrypoint.sh" ]


FROM ismrmrd AS ismrmrd-stream-recon

ENTRYPOINT [ "/opt/entrypoint-stream.sh" ]

FROM ismrmrd AS ismrmrd-stream-recon-server

ENTRYPOINT [ "/opt/entrypoint-stream.sh", "--socket-port", "9002" ]
EXPOSE 9002