Add example Source-to-Image scripts for building custom notebook images.

This commit is contained in:
Graham Dumpleton
2018-02-18 20:58:32 +11:00
parent 65f1c4bea0
commit bad4f68608
2 changed files with 42 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
#!/bin/bash
set -eo pipefail
# Copy injected files to correct place in 'work' directory.
cp -Rf /tmp/src/. /home/$NB_USER/work
rm -rf /tmp/src
# Install any Python modules. If we find an 'environment.yml' file we
# assume we should use 'conda' to install packages. If 'requirements.txt'
# use 'pip' instead. Ensure we are in the 'work' directory so relative
# directory paths in these files resolve okay if installing packages
# from subdirectories.
if [ -f /home/$NB_USER/work/environment.yml ]; then
(cd /home/$NB_USER/work && conda env update --name root --file environment.yml)
conda clean -tipsy
else
if [ -f /home/$NB_USER/work/requirements.txt ]; then
(cd /home/$NB_USER/work && pip --no-cache-dir install -r requirements.txt)
fi
fi
# Remove any 'environment.yml' or 'requirements.txt' file when done in
# case we are producing an image which will in turn be used as an S2I
# builder image.
rm -f /home/$NB_USER/work/environment.yml
rm -f /home/$NB_USER/work/requirements.txt
# Fix up permissions on home directory and Python installation so that
# everything is still writable by 'users' group.
fix-permissions $CONDA_DIR
fix-permissions /home/$NB_USER

5
examples/source-to-image/run Executable file
View File

@@ -0,0 +1,5 @@
#!/bin/bash
# Start up the notebook instance.
exec start-notebook.sh "$@"