forked from jbpoline/module-stats
-
Notifications
You must be signed in to change notification settings - Fork 12
/
generate_repronim_images.sh
105 lines (99 loc) · 4.56 KB
/
generate_repronim_images.sh
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
######################################################
# Generate a Dockerfile and Singularity recipe for building a repronim container
# (https://repronim.readthedocs.io/en/latest/).
# The Dockerfile and/or Singularity recipe installs most of repronim's dependencies.
#
# Steps to build, upload, and deploy the repronim docker and/or singularity image:
#
# 1. Create or update the Dockerfile and Singuarity recipe:
# bash generate_repronim_images.sh
#
# 2. Build the docker image:
# docker build -t repronim -f Dockerfile .
# OR
# bash generate_repronim_images.sh docker
#
# and/or singularity image:
# singularity build mindboggle.simg Singularity
# OR
# bash generate_repronim_images.sh singularity
#
# and/or both:
# bash generate_repronim_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 repronim your_docker_id/repronim:tag # See: https://docs.docker.com/engine/reference/commandline/tag/
# docker push your_docker_id/repronim:tag
#
# 4. Pull from Docker hub (or use the original):
# docker pull your_docker_id/repronim
#
# In the following, the Docker container can be the original (repronim)
# or the pulled version (ypur_docker_id/repronim:tag), and is given access to /Users/repronim
# on the host machine.
#
# 5. Enter the bash shell of the Docker container, and add port mappings:
# docker run --rm -ti -v /Users/repronim:/home/repronim -p 8888:8888 -p 5000:5000 your_docker_id/repronim
#
#
###############################################################################
image="kaczmarj/neurodocker:0.6.0"
set -e
generate_docker() {
docker run --rm ${image} generate docker \
--base neurodebian:stretch-non-free \
--pkg-manager apt \
--run-bash 'apt-get update' \
--install git datalad graphviz num-utils gcc g++ curl build-essential\
--user=repronim \
--miniconda \
conda_install="python=3.7 notebook ipython numpy pandas traits jupyter jupyterlab matplotlib scikit-image scikit-learn seaborn vtk jupyter_contrib_nbextensions nb_conda" \
pip_install='ipywidgets ipyevents jupytext nilearn nistats nibabel jupytext nipype nilearn datalad ipywidgets pythreejs pybids reprozip reproman pingouin nbformat' \
create_env='repronim' \
activate=true \
--run-bash "source activate repronim && jupyter nbextension enable exercise2/main && jupyter nbextension enable spellchecker/main" \
--run 'mkdir -p ~/.jupyter && echo c.NotebookApp.ip = \"0.0.0.0\" > ~/.jupyter/jupyter_notebook_config.py' \
--entrypoint="/neurodocker/startup.sh" \
--copy . /home/repronim/module-stats \
--cmd jupyter notebook
}
generate_singularity() {
docker run --rm ${image} generate singularity \
--base neurodebian:stretch-non-free \
--pkg-manager apt \
--run-bash 'apt-get update' \
--install git datalad graphviz num-utils gcc g++ curl build-essential\
--user=repronim \
--miniconda \
conda_install="python=3.7 notebook ipython numpy pandas traits jupyter jupyterlab matplotlib scikit-image scikit-learn seaborn vtk jupyter_contrib_nbextensions nb_conda" \
pip_install='ipywidgets ipyevents jupytext nilearn nistats nibabel jupytext nipype nilearn datalad ipywidgets pythreejs pybids reprozip reproman pingouin nbformat' \
create_env='repronim' \
activate=true \
--run-bash "source activate repronim && jupyter nbextension enable exercise2/main && jupyter nbextension enable spellchecker/main" \
--run 'mkdir -p ~/.jupyter && echo c.NotebookApp.ip = \"0.0.0.0\" > ~/.jupyter/jupyter_notebook_config.py' \
--entrypoint="/neurodocker/startup.sh" \
--copy . /home/repronim/module-stats
}
# 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 repronim .
elif [ '$1' = 'singularity' ]; then
echo "singularity image will be build locally"
# build image using the saved files
singularity build repronim.simg Singularity
elif [ '$1' = 'both' ]; then
echo "docker and singularity images will be build locally"
# build images using the saved files
docker build -t repronim .
singularity build repronim.simg Singularity
else
echo "Image(s) won't be build locally."
fi