diff --git a/containers/Dockerfile.quasiraw b/containers/Dockerfile.quasiraw index 31f7e5c9..667ed2ce 100644 --- a/containers/Dockerfile.quasiraw +++ b/containers/Dockerfile.quasiraw @@ -1,16 +1,16 @@ -FROM ubuntu:22.04 +FROM ubuntu:22.04 AS ubuntu_base ENV DEBIAN_FRONTEND="noninteractive" \ LANG="en_US.UTF-8" \ LC_ALL="en_US.UTF-8" RUN apt-get update -qq \ && apt-get install -y -q --no-install-recommends \ - apt-utils \ - bzip2 \ - ca-certificates \ - curl \ - locales \ - unzip \ + apt-utils \ + bzip2 \ + ca-certificates \ + curl \ + locales \ + unzip \ && rm -rf /var/lib/apt/lists/* RUN sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen \ && dpkg-reconfigure --frontend=noninteractive locales \ @@ -20,8 +20,6 @@ RUN sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen \ # Parameters ENV ANTS_VERSION="2.6.2" \ FSL_VERSION="6.0.7.19" \ - FS_VERSION="8.1.0" \ - FS_URL="https://surfer.nmr.mgh.harvard.edu/pub/dist/freesurfer/8.1.0/freesurfer_ubuntu22-8.1.0_amd64.deb" \ ANTS_URL="https://github.com/ANTsX/ANTs/releases/download/v2.6.2/ants-2.6.2-centos7-X64-gcc.zip" # Install: FSL @@ -37,145 +35,54 @@ ENV FSLDIR="/opt/fsl" \ FSLGECUDAQ="cuda.q" RUN apt-get update -qq \ && apt-get install -y -q --no-install-recommends \ - bc \ - ca-certificates \ - curl \ - dc \ - file \ - libfontconfig1 \ - libfreetype6 \ - libgl1-mesa-dev \ - libgl1-mesa-dri \ - libglu1-mesa-dev \ - libgomp1 \ - libice6 \ - libopenblas0 \ - libxcursor1 \ - libxft2 \ - libxinerama1 \ - libxrandr2 \ - libxrender1 \ - libxt6 \ - nano \ - python3 \ - sudo \ - wget \ + bc \ + ca-certificates \ + curl \ + dc \ + file \ + libfontconfig1 \ + libfreetype6 \ + libgl1-mesa-dev \ + libgl1-mesa-dri \ + libglu1-mesa-dev \ + libgomp1 \ + libice6 \ + libopenblas0 \ + libxcursor1 \ + libxft2 \ + libxinerama1 \ + libxrandr2 \ + libxrender1 \ + libxt6 \ + nano \ + python3 \ + sudo \ + wget \ && rm -rf /var/lib/apt/lists/* RUN echo "Installing FSL ..." \ && curl -fsSL https://fsl.fmrib.ox.ac.uk/fsldownloads/fslconda/releases/fslinstaller.py | python3 - -d $FSLDIR -V $FSL_VERSION -# Install: FreeSurfer -ENV OS="Linux" \ - PATH="/opt/freesurfer/bin:/opt/freesurfer/fsfast/bin:/opt/freesurfer/tktools:/opt/freesurfer/mni/bin:$PATH" \ - FREESURFER_HOME="/opt/freesurfer" \ - FREESURFER="/opt/freesurfer" \ - SUBJECTS_DIR="/opt/freesurfer/subjects" \ - LOCAL_DIR="/opt/freesurfer/local" \ - FSFAST_HOME="/opt/freesurfer/fsfast" \ - FMRI_ANALYSIS_DIR="/opt/freesurfer/fsfast" \ - FUNCTIONALS_DIR="/opt/freesurfer/sessions" \ - FS_OVERRIDE="0" \ - FIX_VERTEX_AREA="" \ - FSF_OUTPUT_FORMAT="nii.gz" \ - MINC_BIN_DIR="/opt/freesurfer/mni/bin" \ - MINC_LIB_DIR="/opt/freesurfer/mni/lib" \ - MNI_DIR="/opt/freesurfer/mni" \ - MNI_DATAPATH="/opt/freesurfer/mni/data" \ - MNI_PERL5LIB="/opt/freesurfer/mni/share/perl5" \ - PERL5LIB="/opt/freesurfer/mni/share/perl5" -RUN apt-get update -qq \ - && apt-get install -y -q --no-install-recommends \ - octave \ - wget \ - language-pack-en \ - binutils \ - libx11-dev \ - gettext \ - xterm \ - x11-apps \ - perl \ - make \ - csh \ - tcsh \ - file \ - bc \ - xorg \ - xorg-dev \ - xserver-xorg-video-intel \ - libncurses5 \ - libbsd0 \ - libegl1 \ - libexpat1 \ - libfontconfig1 \ - libfreetype6 \ - libgl1 \ - libglib2.0-0 \ - libglu1-mesa \ - libglvnd0 \ - libglx0 \ - libgomp1 \ - libice6 \ - libicu70 \ - libjpeg62 \ - libmd0 \ - libopengl0 \ - libpcre2-16-0 \ - libpng16-16 \ - libquadmath0 \ - libsm6 \ - libx11-6 \ - libx11-xcb1 \ - libxau6 \ - libxcb-icccm4 \ - libxcb-image0 \ - libxcb-keysyms1 \ - libxcb-randr0 \ - libxcb-render-util0 \ - libxcb-render0 \ - libxcb-shape0 \ - libxcb-shm0 \ - libxcb-sync1 \ - libxcb-util1 \ - libxcb-xfixes0 \ - libxcb-xinerama0 \ - libxcb-xinput0 \ - libxcb-xkb1 \ - libxcb1 \ - libxdmcp6 \ - libxext6 \ - libxft2 \ - libxi6 \ - libxkbcommon-x11-0 \ - libxkbcommon0 \ - libxmu6 \ - libxrender1 \ - libxss1 \ - libxt6 \ - mesa-utils \ - unzip \ - libncurses5 \ - libgomp1 \ - openjdk-8-jdk \ - xvfb \ - xauth \ - && rm -rf /var/lib/apt/lists/* -RUN export TMPDIR="$(mktemp -d)" -RUN echo "Downloading FreeSurfer ..." \ - && curl -o $TMPDIR/freesurfer.deb $FS_URL -RUN dpkg -i $TMPDIR/freesurfer.deb \ - && rm -rf $TMPDIR \ - && unset TMPDIR -RUN ln -s /usr/local/freesurfer/${FS_VERSION} /opt/freesurfer -RUN fs_install_mcr R2019b +# -- SynthStrip build stage -- +FROM freesurfer/synthstrip:1.8 AS synthstrip +# ---------------------------- + +# Back in the main ubuntu build context +FROM ubuntu_base AS main + +# Copy SynthStrip artifacts into main image +ENV FREESURFER_HOME="/freesurfer" + +# Copy SynthStrip files from build stage +COPY --from=synthstrip $FREESURFER_HOME $FREESURFER_HOME # Install ANTs ENV ANTSPATH="/opt/ants" \ PATH="/opt/ants:$PATH" RUN apt-get update -qq \ && apt-get install -y -q --no-install-recommends \ - ca-certificates \ - curl \ - unzip \ + ca-certificates \ + curl \ + unzip \ && rm -rf /var/lib/apt/lists/* RUN echo "Downloading ANTs ..." \ && curl -fsSL -o /opt/ants.zip $ANTS_URL @@ -190,25 +97,33 @@ ENV PATH="/root/.pixi/bin:${PATH}" WORKDIR /opt/brainprep RUN apt-get update -qq \ && apt-get install -y -q --no-install-recommends \ - git \ + git \ && rm -rf /var/lib/apt/lists/* COPY pixi.toml . RUN pixi install RUN ln -s /opt/brainprep/.pixi/envs/default/bin/brainprep /usr/local/bin/brainprep +# Wrapper in : /usr/local/bin +# This script sets the PYTHONPATH locally only for mri_synthstrip +RUN echo '#!/bin/bash\n\ + PYTHONPATH="/freesurfer/env/lib/python3.10/site-packages" \ + /usr/bin/python3 /freesurfer/mri_synthstrip "$@"' > /usr/local/bin/mri_synthstrip && \ + chmod +x /usr/local/bin/mri_synthstrip +ENV PATH="/usr/local/bin:$FREESURFER_HOME:$PATH + COPY entrypoint.sh /opt/entrypoint.sh RUN chmod +x /opt/entrypoint.sh ENTRYPOINT ["/opt/entrypoint.sh"] ENV DEFAULT_ARGS="subject-level-quasiraw group-level-quasiraw" LABEL org.opencontainers.image.title="BrainPrep Quasi-Raw" \ - org.opencontainers.image.description="Container for BrainPrep Quasi-Raw using FSL and FREESURFER" \ - org.opencontainers.image.version="v2" \ - org.opencontainers.image.licenses="CeCILL-B" \ - org.opencontainers.image.authors="CEA/NeuroSpin/GAIA" \ - org.opencontainers.image.documentation="https://brainprepdesk.github.io/brainprep/stable" \ - org.opencontainers.image.source="https://github.com/brainprepdesk/brainprep" \ - org.opencontainers.image.created="2025-01-15" \ - com.brainprep.fsl.version="${FSL_VERSION}" \ - com.brainprep.freesurfer.version="${FS_VERSION}" \ - com.brainprep.ants.version="${ANTS_VERSION}" + org.opencontainers.image.description="Container for BrainPrep Quasi-Raw using FSL and FREESURFER" \ + org.opencontainers.image.version="v2" \ + org.opencontainers.image.licenses="CeCILL-B" \ + org.opencontainers.image.authors="CEA/NeuroSpin/GAIA" \ + org.opencontainers.image.documentation="https://brainprepdesk.github.io/brainprep/stable" \ + org.opencontainers.image.source="https://github.com/brainprepdesk/brainprep" \ + org.opencontainers.image.created="2025-01-15" \ + com.brainprep.fsl.version="${FSL_VERSION}" \ + com.brainprep.freesurfer.version="${FS_VERSION}" \ + com.brainprep.ants.version="${ANTS_VERSION}"