diff --git a/Dockerfile b/Dockerfile index 3c8c0ff..e3f1cc9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,36 +1,180 @@ -FROM alpine:3.8 - -RUN apk add --no-cache python3 && \ - python3 -m ensurepip && \ - rm -r /usr/lib/python*/ensurepip && \ - pip3 install --upgrade pip setuptools && \ - if [ ! -e /usr/bin/pip ]; then ln -s pip3 /usr/bin/pip ; fi && \ - if [[ ! -e /usr/bin/python ]]; then ln -sf /usr/bin/python3 /usr/bin/python; fi && \ - rm -r /root/.cache - -RUN apk add --no-cache libpng freetype libstdc++ openblas libxml2 libxslt && \ - apk add --no-cache --virtual .build-deps \ - g++ gfortran file binutils \ - openblas-dev \ - python3-dev \ - gcc \ - build-base \ - libpng-dev \ - musl-dev \ - freetype-dev \ - libxml2-dev \ - libxslt-dev && \ - ln -s /usr/include/locale.h /usr/include/xlocale.h \ - && pip3 install numpy \ - && pip3 install scipy==1.3.3 \ - && pip3 install pandas \ - && pip3 install matplotlib \ - && pip3 install joblib \ - && pip3 install rsHRF \ - && rm -r /root/.cache \ - && find /usr/lib/python3.*/ -name 'tests' -exec rm -r '{}' + \ - && find /usr/lib/python3.*/site-packages/ -name '*.so' -print -exec sh -c 'file "{}" | grep -q "not stripped" && strip -s "{}"' \; \ - && rm /usr/include/xlocale.h \ - && apk del .build-deps - -ENTRYPOINT ["rsHRF"] +# Your version: 0.6.0 Latest version: 0.7.0 +# Generated by Neurodocker version 0.6.0 +# Timestamp: 2020-04-21 18:20:36 UTC +# +# Thank you for using Neurodocker. If you discover any issues +# or ways to improve this software, please submit an issue or +# pull request on our GitHub repository: +# +# https://github.com/kaczmarj/neurodocker + +FROM neurodebian + +ARG DEBIAN_FRONTEND="noninteractive" + +ENV LANG="en_US.UTF-8" \ + LC_ALL="en_US.UTF-8" \ + ND_ENTRYPOINT="/neurodocker/startup.sh" +RUN export ND_ENTRYPOINT="/neurodocker/startup.sh" \ + && apt-get update -qq \ + && apt-get install -y -q --no-install-recommends \ + apt-utils \ + bzip2 \ + ca-certificates \ + curl \ + locales \ + unzip \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* \ + && sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen \ + && dpkg-reconfigure --frontend=noninteractive locales \ + && update-locale LANG="en_US.UTF-8" \ + && chmod 777 /opt && chmod a+s /opt \ + && mkdir -p /neurodocker \ + && if [ ! -f "$ND_ENTRYPOINT" ]; then \ + echo '#!/usr/bin/env bash' >> "$ND_ENTRYPOINT" \ + && echo 'set -e' >> "$ND_ENTRYPOINT" \ + && echo 'export USER="${USER:=`whoami`}"' >> "$ND_ENTRYPOINT" \ + && echo 'if [ -n "$1" ]; then "$@"; else /usr/bin/env bash; fi' >> "$ND_ENTRYPOINT"; \ + fi \ + && chmod -R 777 /neurodocker && chmod a+s /neurodocker + +ENTRYPOINT ["/neurodocker/startup.sh"] + +RUN apt-get update -qq \ + && apt-get install -y -q --no-install-recommends \ + libpng \ + freetype \ + libstdc++ \ + openblas \ + libxml2 \ + libxslt \ + g++ \ + gfortran \ + file \ + binutils \ + openblas-dev \ + python3-dev \ + gcc \ + build-base \ + libpng-dev \ + musl-dev \ + freetype-dev \ + libxml2-dev \ + libxslt-dev \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +RUN test "$(getent passwd rshrf)" || useradd --no-user-group --create-home --shell /bin/bash rshrf +USER rshrf + +ENV CONDA_DIR="/opt/miniconda-latest" \ + PATH="/opt/miniconda-latest/bin:$PATH" +RUN export PATH="/opt/miniconda-latest/bin:$PATH" \ + && echo "Downloading Miniconda installer ..." \ + && conda_installer="/tmp/miniconda.sh" \ + && curl -fsSL --retry 5 -o "$conda_installer" https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh \ + && bash "$conda_installer" -b -p /opt/miniconda-latest \ + && rm -f "$conda_installer" \ + && conda update -yq -nbase conda \ + && conda config --system --prepend channels conda-forge \ + && conda config --system --set auto_update_conda false \ + && conda config --system --set show_channel_urls true \ + && sync && conda clean --all && sync \ + && conda create -y -q --name rshrf \ + && conda install -y -q --name rshrf \ + "python=3.7" \ + "pandas" \ + "scipy==1.3.3" \ + "numpy" \ + "matplotlib" \ + "joblib" \ + && sync && conda clean --all && sync \ + && bash -c "source activate rshrf \ + && pip install --no-cache-dir \ + "rsHRF"" \ + && rm -rf ~/.cache/pip/* \ + && sync \ + && sed -i '$isource activate rshrf' $ND_ENTRYPOINT + +RUN mkdir -p ~/.jupyter && echo c.NotebookApp.ip = \"0.0.0.0\" > ~/.jupyter/jupyter_notebook_config.py + +ENTRYPOINT ["/neurodocker/startup.sh"] + +WORKDIR /home/rshrf + +CMD ["rshrf"] + +RUN echo '{ \ + \n "pkg_manager": "apt", \ + \n "instructions": [ \ + \n [ \ + \n "base", \ + \n "neurodebian" \ + \n ], \ + \n [ \ + \n "install", \ + \n [ \ + \n "libpng", \ + \n "freetype", \ + \n "libstdc++", \ + \n "openblas", \ + \n "libxml2", \ + \n "libxslt", \ + \n "g++", \ + \n "gfortran", \ + \n "file", \ + \n "binutils", \ + \n "openblas-dev", \ + \n "python3-dev", \ + \n "gcc", \ + \n "build-base", \ + \n "libpng-dev", \ + \n "musl-dev", \ + \n "freetype-dev", \ + \n "libxml2-dev", \ + \n "libxslt-dev" \ + \n ] \ + \n ], \ + \n [ \ + \n "user", \ + \n "rshrf" \ + \n ], \ + \n [ \ + \n "miniconda", \ + \n { \ + \n "conda_install": [ \ + \n "python=3.7", \ + \n "pandas", \ + \n "scipy==1.3.3", \ + \n "numpy", \ + \n "matplotlib", \ + \n "joblib" \ + \n ], \ + \n "pip_install": [ \ + \n "rsHRF" \ + \n ], \ + \n "create_env": "rshrf", \ + \n "activate": true \ + \n } \ + \n ], \ + \n [ \ + \n "run", \ + \n "mkdir -p ~/.jupyter && echo c.NotebookApp.ip = \\\"0.0.0.0\\\" > ~/.jupyter/jupyter_notebook_config.py" \ + \n ], \ + \n [ \ + \n "entrypoint", \ + \n "/neurodocker/startup.sh" \ + \n ], \ + \n [ \ + \n "workdir", \ + \n "/home/rshrf" \ + \n ], \ + \n [ \ + \n "cmd", \ + \n [ \ + \n "rshrf" \ + \n ] \ + \n ] \ + \n ] \ + \n}' > /neurodocker/neurodocker_specs.json diff --git a/Singularity b/Singularity new file mode 100644 index 0000000..e7901d0 --- /dev/null +++ b/Singularity @@ -0,0 +1,181 @@ +# Your version: 0.6.0 Latest version: 0.7.0 +# Generated by Neurodocker version 0.6.0 +# Timestamp: 2020-04-21 18:20:37 UTC +# +# Thank you for using Neurodocker. If you discover any issues +# or ways to improve this software, please submit an issue or +# pull request on our GitHub repository: +# +# https://github.com/kaczmarj/neurodocker + +Bootstrap: docker +From: neurodebian + +%post +export ND_ENTRYPOINT="/neurodocker/startup.sh" +apt-get update -qq +apt-get install -y -q --no-install-recommends \ + apt-utils \ + bzip2 \ + ca-certificates \ + curl \ + locales \ + unzip +apt-get clean +rm -rf /var/lib/apt/lists/* +sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen +dpkg-reconfigure --frontend=noninteractive locales +update-locale LANG="en_US.UTF-8" +chmod 777 /opt && chmod a+s /opt +mkdir -p /neurodocker +if [ ! -f "$ND_ENTRYPOINT" ]; then + echo '#!/usr/bin/env bash' >> "$ND_ENTRYPOINT" + echo 'set -e' >> "$ND_ENTRYPOINT" + echo 'export USER="${USER:=`whoami`}"' >> "$ND_ENTRYPOINT" + echo 'if [ -n "$1" ]; then "$@"; else /usr/bin/env bash; fi' >> "$ND_ENTRYPOINT"; +fi +chmod -R 777 /neurodocker && chmod a+s /neurodocker + +apt-get update -qq +apt-get install -y -q --no-install-recommends \ + libpng \ + freetype \ + libstdc++ \ + openblas \ + libxml2 \ + libxslt \ + g++ \ + gfortran \ + file \ + binutils \ + openblas-dev \ + python3-dev \ + gcc \ + build-base \ + libpng-dev \ + musl-dev \ + freetype-dev \ + libxml2-dev \ + libxslt-dev +apt-get clean +rm -rf /var/lib/apt/lists/* + +test "$(getent passwd rshrf)" || useradd --no-user-group --create-home --shell /bin/bash rshrf +su - rshrf + +export PATH="/opt/miniconda-latest/bin:$PATH" +echo "Downloading Miniconda installer ..." +conda_installer="/tmp/miniconda.sh" +curl -fsSL --retry 5 -o "$conda_installer" https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh +bash "$conda_installer" -b -p /opt/miniconda-latest +rm -f "$conda_installer" +conda update -yq -nbase conda +conda config --system --prepend channels conda-forge +conda config --system --set auto_update_conda false +conda config --system --set show_channel_urls true +sync && conda clean --all && sync +conda create -y -q --name rshrf +conda install -y -q --name rshrf \ + "python=3.7" \ + "pandas" \ + "scipy==1.3.3" \ + "numpy" \ + "matplotlib" \ + "joblib" +sync && conda clean --all && sync +bash -c "source activate rshrf + pip install --no-cache-dir \ + "rsHRF"" +rm -rf ~/.cache/pip/* +sync +sed -i '$isource activate rshrf' $ND_ENTRYPOINT + + +mkdir -p ~/.jupyter && echo c.NotebookApp.ip = \"0.0.0.0\" > ~/.jupyter/jupyter_notebook_config.py + +cd /home/rshrf + +echo '{ +\n "pkg_manager": "apt", +\n "instructions": [ +\n [ +\n "base", +\n "neurodebian" +\n ], +\n [ +\n "_header", +\n { +\n "version": "generic", +\n "method": "custom" +\n } +\n ], +\n [ +\n "install", +\n [ +\n "libpng", +\n "freetype", +\n "libstdc++", +\n "openblas", +\n "libxml2", +\n "libxslt", +\n "g++", +\n "gfortran", +\n "file", +\n "binutils", +\n "openblas-dev", +\n "python3-dev", +\n "gcc", +\n "build-base", +\n "libpng-dev", +\n "musl-dev", +\n "freetype-dev", +\n "libxml2-dev", +\n "libxslt-dev" +\n ] +\n ], +\n [ +\n "user", +\n "rshrf" +\n ], +\n [ +\n "miniconda", +\n { +\n "conda_install": [ +\n "python=3.7", +\n "pandas", +\n "scipy==1.3.3", +\n "numpy", +\n "matplotlib", +\n "joblib" +\n ], +\n "pip_install": [ +\n "rsHRF" +\n ], +\n "create_env": "rshrf", +\n "activate": true +\n } +\n ], +\n [ +\n "run", +\n "mkdir -p ~/.jupyter && echo c.NotebookApp.ip = \\\"0.0.0.0\\\" > ~/.jupyter/jupyter_notebook_config.py" +\n ], +\n [ +\n "entrypoint", +\n "/neurodocker/startup.sh" +\n ], +\n [ +\n "workdir", +\n "/home/rshrf" +\n ] +\n ] +\n}' > /neurodocker/neurodocker_specs.json + +%environment +export LANG="en_US.UTF-8" +export LC_ALL="en_US.UTF-8" +export ND_ENTRYPOINT="/neurodocker/startup.sh" +export CONDA_DIR="/opt/miniconda-latest" +export PATH="/opt/miniconda-latest/bin:$PATH" + +%runscript +/neurodocker/startup.sh diff --git a/generate_rshrf_images.sh b/generate_rshrf_images.sh new file mode 100644 index 0000000..245f072 --- /dev/null +++ b/generate_rshrf_images.sh @@ -0,0 +1,103 @@ +###################################################### +# Generate a Dockerfile and Singularity recipe for building a rshrf container +# (http://bids-apps.neuroimaging.io/rsHRF/). +# The Dockerfile and/or Singularity recipe installs most of rshrf's dependencies. +# +# Steps to build, upload, and deploy the rshrf docker and/or singularity image: +# +# 1. Create or update the Dockerfile and Singuarity recipe: +# bash generate_rshrf_images.sh +# +# 2. Build the docker image: +# docker build -t rshrf -f Dockerfile . +# OR +# bash generate_rshrf_images.sh docker +# +# and/or singularity image: +# singularity build mindboggle.simg Singularity +# OR +# bash generate_rshrf_images.sh singularity +# +# and/or both: +# bash generate_rshrf_images.sh both +# +# 3. Push to Docker hub: +# (https://docs.docker.com/docker-cloud/builds/push-images/) +# export DOCKER_ID_USER="your_docker_id" +# docker login +# docker tag rshrf your_docker_id/rshrf:tag # See: https://docs.docker.com/engine/reference/commandline/tag/ +# docker push your_docker_id/rshrf:tag +# +# 4. Pull from Docker hub (or use the original): +# docker pull your_docker_id/rshrf +# +# In the following, the Docker container can be the original (rshrf) +# or the pulled version (ypur_docker_id/rshrf:tag), and is given access to /Users/rshrf +# on the host machine. +# +# 5. Enter the bash shell of the Docker container, and add port mappings: +# docker run --rm -ti -v /Users/rshrf:/home/rshrf -p 8888:8888 -p 5000:5000 your_docker_id/rshrf +# +# +############################################################################### + +image="kaczmarj/neurodocker:0.6.0" + +set -e + +generate_docker() { + docker run --rm ${image} generate docker \ + --base neurodebian \ + --pkg-manager apt \ + --install libpng freetype libstdc++ openblas libxml2 libxslt g++ gfortran file binutils \ + openblas-dev python3-dev gcc build-base libpng-dev musl-dev freetype-dev libxml2-dev libxslt-dev \ + --user=rshrf \ + --miniconda \ + conda_install="python=3.7 pandas scipy==1.3.3 numpy matplotlib joblib" \ + pip_install='rsHRF' \ + create_env='rshrf' \ + activate=true \ + --run 'mkdir -p ~/.jupyter && echo c.NotebookApp.ip = \"0.0.0.0\" > ~/.jupyter/jupyter_notebook_config.py' \ + --entrypoint="/neurodocker/startup.sh" \ + --workdir "/home/rshrf" \ + --cmd rshrf +} + +generate_singularity() { + docker run --rm ${image} generate singularity \ + --base neurodebian \ + --pkg-manager apt \ + --install libpng freetype libstdc++ openblas libxml2 libxslt g++ gfortran file binutils \ + openblas-dev python3-dev gcc build-base libpng-dev musl-dev freetype-dev libxml2-dev libxslt-dev \ + --user=rshrf \ + --miniconda \ + conda_install="python=3.7 pandas scipy==1.3.3 numpy matplotlib joblib" \ + pip_install='rsHRF' \ + create_env='rshrf' \ + activate=true \ + --run 'mkdir -p ~/.jupyter && echo c.NotebookApp.ip = \"0.0.0.0\" > ~/.jupyter/jupyter_notebook_config.py' \ + --entrypoint="/neurodocker/startup.sh" \ + --workdir "/home/rshrf" + } + +# generate files +generate_docker > Dockerfile +generate_singularity > Singularity + +# check if images should be build locally or not +if [ '$1' = 'docker' ]; then + echo "docker image will be build locally" + # build image using the saved files + docker build -t rshrf . +elif [ '$1' = 'singularity' ]; then + echo "singularity image will be build locally" + # build image using the saved files + singularity build rshrf.simg Singularity +elif [ '$1' = 'both' ]; then + echo "docker and singularity images will be build locally" + # build images using the saved files + docker build -t rshrf . + singularity build rshrf.simg Singularity +else +echo "Image(s) won't be build locally." +fi