diff --git a/docker/.dockerignore b/.dockerignore similarity index 100% rename from docker/.dockerignore rename to .dockerignore diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..5360f00 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,57 @@ +FROM ghcr.io/prefix-dev/pixi:0.53.0 AS build + +USER root + +# Prepare environment +RUN apt-get update && \ + apt-get install -y --no-install-recommends \ + ca-certificates \ + git && \ + apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* + +# Run post-link scripts during install, but use global to keep out of source tree +RUN pixi config set --global run-post-link-scripts insecure + +# Install dependencies before the package itself to leverage caching +RUN mkdir /app +COPY pixi.lock pixi.toml /app +WORKDIR /app + +RUN pixi install -e default --frozen +RUN pixi shell-hook -e default --as-is | grep -v PATH > /shell-hook.sh + + +FROM jupyter/base-notebook:x86_64-lab-4.0.7 + +USER root + +# Prepare environment +RUN apt-get update && \ + apt-get install -y --no-install-recommends \ + curl \ + dvipng \ + texlive-fonts-recommended \ + texlive-fonts-extra \ + texlive-latex-extra \ + cm-super && \ + apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* + +COPY --link --from=build /app/.pixi/envs/default /app/.pixi/envs/default +COPY --link --from=build /shell-hook.sh /shell-hook.sh +RUN cat /shell-hook.sh >> $HOME/.bashrc +ENV PATH="/app/.pixi/envs/default/bin:$PATH" + +ENV NB_USER=jovyan \ + NB_GROUP=users \ + NB_UID=1000 \ + NB_GID=100 \ + HOME=/home/jovyan + +RUN fix-permissions "/home/${NB_USER}" +# RUN chmod -R ${NB_USER}.${NB_GROUP} "/home/${NB_USER}" + +USER ${NB_USER} + +WORKDIR ${HOME} + +COPY --chown=${NB_UID}:${NB_GID} . ${HOME}/nipreps-book \ No newline at end of file diff --git a/binder/postBuild b/binder/postBuild index c8b84ed..46262ae 100644 --- a/binder/postBuild +++ b/binder/postBuild @@ -1,6 +1,7 @@ #!/bin/bash +set -euxo pipefail -export ANTSPATH="$HOME/src/ants" -mkdir -p $ANTSPATH -curl -sSL "https://dl.dropbox.com/s/gwf51ykkk5bifyj/ants-Linux-centos6_x86_64-v2.3.4.tar.gz" | tar -xzC $ANTSPATH --strip-components 1 -export PATH="$ANTSPATH:$PATH" +curl -fsSL https://pixi.sh/install.sh | bash +export PATH="$HOME/.pixi/bin:$PATH" + +pixi install --locked diff --git a/binder/requirements.txt b/binder/requirements.txt index 113d184..8dd1937 100644 --- a/binder/requirements.txt +++ b/binder/requirements.txt @@ -1,12 +1 @@ -attr -dipy -git+https://github.com/nipreps/EddyMotionCorrection.git@main -jupytext -matplotlib -nibabel -nilearn -git+https://github.com/poldracklab/nitransforms.git@master -niworkflows >= 1.4.0rc5 -numpy -pytest -requests +# Python dependencies are managed via Pixi. See binder/postBuild for setup steps. \ No newline at end of file diff --git a/docker/Dockerfile b/docker/Dockerfile deleted file mode 100644 index 10d9c69..0000000 --- a/docker/Dockerfile +++ /dev/null @@ -1,46 +0,0 @@ -FROM jupyter/base-notebook:lab-3.0.12 - -USER root - -# Prepare environment -RUN apt-get update && \ - apt-get install -y --no-install-recommends \ - curl \ - dvipng \ - texlive-fonts-recommended \ - texlive-fonts-extra \ - texlive-latex-extra \ - cm-super && \ - apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* - -# Installing ANTs 2.3.3 (NeuroDocker build) -# Note: the URL says 2.3.4 but it is actually 2.3.3 -ENV ANTSPATH=/usr/lib/ants -RUN mkdir -p $ANTSPATH && \ - curl -sSL "https://dl.dropbox.com/s/gwf51ykkk5bifyj/ants-Linux-centos6_x86_64-v2.3.4.tar.gz" \ - | tar -xzC $ANTSPATH --strip-components 1 -ENV PATH=$ANTSPATH:$PATH - -USER $NB_UID - -# Installing precomputed python packages -RUN conda install -y -c anaconda -c conda-forge \ - attr \ - dipy \ - jupytext \ - nibabel \ - nilearn \ - matplotlib=2.2 \ - numpy=1.20 \ - requests \ - zlib && \ - conda clean --all -f -y && \ - fix-permissions "${CONDA_DIR}" && \ - fix-permissions "/home/${NB_USER}" - -# Install remaining python packages -RUN pip install --no-cache-dir --upgrade pip && \ - pip install --no-cache-dir nifreeze nitransforms niworkflows - -# Installing nipreps-book -COPY . $HOME/nipreps-book