1- #! /usr/bin/env bash
1+ #! /usr/bin/env bash
2+ #
3+ # Generate base and main Dockerfiles for Nipype.
4+
5+ set -e
6+
7+ USAGE=" usage: $( basename $0 ) [-h] [-b] [-m]"
8+
9+ function Help {
10+ cat << USAGE
11+ Generate base and/or main Dockerfiles for Nipype.
12+
13+ Usage:
14+
15+ $( basename $0 ) [-h] [-b] [-m]
16+
17+ Options:
18+
19+ -h : display this help message and exit
20+ -b : generate base Dockerfile
21+ -m : generate main Dockerfile
22+
23+ USAGE
24+ }
25+
26+ # No command-line options passed.
27+ if [ -z " $1 " ]; then
28+ echo " $USAGE "
29+ exit 1
30+ fi
31+
32+ # Get command-line options.
33+ # Used the antsRegistrationSyN.sh as an example.
34+ # https://github.com/ANTsX/ANTs/blob/master/Scripts/antsRegistrationSyN.sh
35+ while getopts " hbm" OPT
36+ do
37+ case $OPT in
38+ h)
39+ Help
40+ exit 0
41+ ;;
42+ b)
43+ GENERATE_BASE=" 1"
44+ ;;
45+ m)
46+ GENERATE_MAIN=" 1"
47+ ;;
48+ \? )
49+ echo " $USAGE " >&2
50+ exit 1
51+ ;;
52+ esac
53+ done
54+
55+
56+ # neurodocker version 0.3.1-19-g8d02eb4
57+ NEURODOCKER_IMAGE=" kaczmarj/neurodocker@sha256:6b5f92f413b9710b7581e62293a8f74438b14ce7e4ab1ce68db2a09f7c64375a"
58+
59+ # neurodebian:stretch-non-free pulled on November 3, 2017
60+ BASE_IMAGE=" neurodebian@sha256:7590552afd0e7a481a33314724ae27f76ccedd05ffd7ac06ec38638872427b9b"
261
3- # kaczmarj/neurodocker:master pulled on September 13, 2017.
4- NEURODOCKER_IMAGE=" kaczmarj/neurodocker:master"
5- # neurodebian/stretch-non-free:latest pulled on September 13, 2017.
6- BASE_IMAGE=" neurodebian@sha256:b09c09faa34bca0ea096b9360ee5121e048594cb8e2d7744d7d546ade88a2996"
762NIPYPE_BASE_IMAGE=" kaczmarj/nipype:base"
863PKG_MANAGER=" apt"
9-
10- # Save Dockerfiles relative to this path so that this script can be run from
11- # any directory. https://stackoverflow.com/a/246128/5666087
1264DIR=" $( dirname " $0 " ) "
1365
14-
1566function generate_base_dockerfile() {
1667 docker run --rm " $NEURODOCKER_IMAGE " generate \
1768 --base " $BASE_IMAGE " --pkg-manager " $PKG_MANAGER " \
1869 --label maintainer=" The nipype developers https://github.com/nipy/nipype" \
1970 --spm version=12 matlab_version=R2017a \
20- --afni version=latest \
71+ --afni version=latest install_python2=true \
2172 --freesurfer version=6.0.0 min=true \
2273 --run ' echo "cHJpbnRmICJrcnp5c3p0b2YuZ29yZ29sZXdza2lAZ21haWwuY29tXG41MTcyXG4gKkN2dW12RVYzelRmZ1xuRlM1Si8yYzFhZ2c0RVxuIiA+IC9vcHQvZnJlZXN1cmZlci9saWNlbnNlLnR4dAo=" | base64 -d | sh' \
23- --install ants apt-utils bzip2 file fsl-core fsl-mni152-templates \
74+ --install ants apt-utils bzip2 convert3d file fsl-core fsl-mni152-templates \
2475 fusefat g++ git graphviz make ruby unzip xvfb \
2576 --add-to-entrypoint " source /etc/fsl/fsl.sh" \
2677 --env ANTSPATH=' /usr/lib/ants' PATH=' /usr/lib/ants:$PATH' \
27- --c3d version=1.0.0 \
28- --instruction " RUN gem install fakes3" \
29- --workdir /work \
78+ --run " gem install fakes3" \
3079 --no-check-urls > " $DIR /Dockerfile.base"
3180}
3281
@@ -45,12 +94,17 @@ function generate_main_dockerfile() {
4594 --env MKL_NUM_THREADS=1 OMP_NUM_THREADS=1 \
4695 --user neuro \
4796 --miniconda env_name=neuro \
48- add_to_path =true \
97+ activate =true \
4998 --copy docker/files/run_builddocs.sh docker/files/run_examples.sh \
5099 docker/files/run_pytests.sh nipype/external/fsl_imglob.py /usr/bin/ \
51100 --copy . /src/nipype \
52101 --user root \
53- --run " chmod 777 -R /src/nipype" \
102+ --run ' chown -R neuro /src
103+ && chmod +x /usr/bin/fsl_imglob.py /usr/bin/run_*.sh
104+ && . /etc/fsl/fsl.sh
105+ && ln -sf /usr/bin/fsl_imglob.py ${FSLDIR}/bin/imglob
106+ && mkdir /work
107+ && chown neuro /work' \
54108 --user neuro \
55109 --arg PYTHON_VERSION_MAJOR=3 PYTHON_VERSION_MINOR=6 BUILD_DATE VCS_REF VERSION \
56110 --miniconda env_name=neuro \
@@ -59,6 +113,12 @@ function generate_main_dockerfile() {
59113 pandas psutil scikit-learn scipy traits=4.6.0' \
60114 pip_opts=" -e" \
61115 pip_install=" /src/nipype[all]" \
116+ --run-bash " mkdir -p /src/pybids
117+ && curl -sSL --retry 5 https://github.com/INCF/pybids/tarball/master
118+ | tar -xz -C /src/pybids --strip-components 1
119+ && source activate neuro
120+ && pip install --no-cache-dir -e /src/pybids" \
121+ --workdir /work \
62122 --label org.label-schema.build-date=' $BUILD_DATE' \
63123 org.label-schema.name=" NIPYPE" \
64124 org.label-schema.description=" NIPYPE - Neuroimaging in Python: Pipelines and Interfaces" \
@@ -67,9 +127,13 @@ function generate_main_dockerfile() {
67127 org.label-schema.vcs-url=" https://github.com/nipy/nipype" \
68128 org.label-schema.version=' $VERSION' \
69129 org.label-schema.schema-version=" 1.0" \
70- --no-check-urls > " $DIR /../Dockerfile "
130+ --no-check-urls
71131}
72132
73133
74- generate_base_dockerfile
75- generate_main_dockerfile
134+ if [ " $GENERATE_BASE " == 1 ]; then
135+ generate_base_dockerfile > " $DIR /Dockerfile.base"
136+ fi
137+ if [ " $GENERATE_MAIN " == 1 ]; then
138+ generate_main_dockerfile > " $DIR /../Dockerfile"
139+ fi
0 commit comments