2020-02-20 10:03:48 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
cd $(cd -P -- "$(dirname -- "$0")" && pwd -P)
|
|
|
|
|
|
|
|
# Set the path of the generated Dockerfile
|
|
|
|
export DOCKERFILE=".build/Dockerfile"
|
|
|
|
export STACKS_DIR=".build/docker-stacks"
|
2020-06-22 11:26:01 +00:00
|
|
|
# please test the build of the commit in https://github.com/jupyter/docker-stacks/commits/master in advance
|
2021-01-05 11:39:30 +00:00
|
|
|
export HEAD_COMMIT="703d8b2dcb886be2fe5aa4660a48fbcef647e7aa"
|
2020-03-10 15:35:10 +00:00
|
|
|
|
|
|
|
while [[ "$#" -gt 0 ]]; do case $1 in
|
|
|
|
-c|--commit) HEAD_COMMIT="$2"; shift;;
|
2020-06-22 11:26:01 +00:00
|
|
|
--no-datascience-notebook) no_datascience_notebook=1;;
|
|
|
|
--no-useful-packages) no_useful_packages=1;;
|
|
|
|
-s|--slim) no_datascience_notebook=1 && no_useful_packages=1;;
|
2020-03-10 15:35:10 +00:00
|
|
|
*) echo "Unknown parameter passed: $1" &&
|
|
|
|
echo "Usage: $0 -c [sha-commit] # set the head commit of the docker-stacks submodule
|
|
|
|
(https://github.com/jupyter/docker-stacks/commits/master). default: $HEAD_COMMIT."; exit 1;;
|
|
|
|
esac; shift; done
|
2020-02-20 10:03:48 +00:00
|
|
|
|
|
|
|
|
2020-03-10 17:29:25 +00:00
|
|
|
# Clone if docker-stacks doesn't exist, and set to the given commit or the default commit
|
2020-02-20 10:03:48 +00:00
|
|
|
ls $STACKS_DIR/README.md > /dev/null 2>&1 || (echo "Docker-stacks was not found, cloning repository" \
|
|
|
|
&& git clone https://github.com/jupyter/docker-stacks.git $STACKS_DIR)
|
2020-03-10 17:29:25 +00:00
|
|
|
echo "Set docker-stacks to commit '$HEAD_COMMIT'."
|
|
|
|
if [[ "$HEAD_COMMIT" == "latest" ]]; then
|
|
|
|
echo "WARNING, the latest commit of docker-stacks is used. This may result in version conflicts"
|
|
|
|
cd $STACKS_DIR && git pull && cd -
|
|
|
|
else
|
|
|
|
export GOT_HEAD="false"
|
2020-06-22 11:26:01 +00:00
|
|
|
cd $STACKS_DIR && git pull && git reset --hard "$HEAD_COMMIT" > /dev/null 2>&1 && cd - && export GOT_HEAD="true"
|
2020-03-11 07:07:03 +00:00
|
|
|
echo "$HEAD"
|
2020-03-10 17:29:25 +00:00
|
|
|
if [[ "$GOT_HEAD" == "false" ]]; then
|
2020-06-22 11:26:01 +00:00
|
|
|
echo "Error: The given sha-commit is invalid."
|
2020-03-10 17:29:25 +00:00
|
|
|
echo "Usage: $0 -c [sha-commit] # set the head commit of the docker-stacks submodule (https://github.com/jupyter/docker-stacks/commits/master)."
|
2020-06-22 11:26:01 +00:00
|
|
|
echo "Exiting"
|
2020-03-10 17:29:25 +00:00
|
|
|
exit 2
|
|
|
|
else
|
|
|
|
echo "Set head to given commit."
|
|
|
|
fi
|
|
|
|
fi
|
2020-02-20 10:03:48 +00:00
|
|
|
|
|
|
|
# Write the contents into the DOCKERFILE and start with the header
|
2020-09-29 09:42:20 +00:00
|
|
|
echo "# This Dockerfile is generated by 'generate-Dockerfile.sh' from elements within 'src/'
|
|
|
|
|
|
|
|
# **Please do not change this file directly!**
|
|
|
|
# To adapt this Dockerfile, adapt 'generate-Dockerfile.sh' or 'src/Dockerfile.usefulpackages'.
|
|
|
|
# More information can be found in the README under configuration.
|
|
|
|
|
2020-06-22 16:14:45 +00:00
|
|
|
" > $DOCKERFILE
|
|
|
|
cat src/Dockerfile.header >> $DOCKERFILE
|
2020-02-20 10:03:48 +00:00
|
|
|
|
|
|
|
echo "
|
|
|
|
############################################################################
|
|
|
|
#################### Dependency: jupyter/base-image ########################
|
|
|
|
############################################################################
|
|
|
|
" >> $DOCKERFILE
|
|
|
|
cat $STACKS_DIR/base-notebook/Dockerfile | grep -v BASE_CONTAINER >> $DOCKERFILE
|
2020-02-22 14:10:11 +00:00
|
|
|
|
2020-02-22 17:56:54 +00:00
|
|
|
# copy files that are used during the build:
|
2020-02-20 10:03:48 +00:00
|
|
|
cp $STACKS_DIR/base-notebook/jupyter_notebook_config.py .build/
|
2020-02-22 14:10:11 +00:00
|
|
|
cp $STACKS_DIR/base-notebook/fix-permissions .build/
|
2020-02-20 10:03:48 +00:00
|
|
|
cp $STACKS_DIR/base-notebook/start.sh .build/
|
|
|
|
cp $STACKS_DIR/base-notebook/start-notebook.sh .build/
|
|
|
|
cp $STACKS_DIR/base-notebook/start-singleuser.sh .build/
|
2020-02-23 19:26:12 +00:00
|
|
|
chmod 755 .build/*
|
2020-02-20 10:03:48 +00:00
|
|
|
|
|
|
|
echo "
|
|
|
|
############################################################################
|
|
|
|
################# Dependency: jupyter/minimal-notebook #####################
|
|
|
|
############################################################################
|
|
|
|
" >> $DOCKERFILE
|
|
|
|
cat $STACKS_DIR/minimal-notebook/Dockerfile | grep -v BASE_CONTAINER >> $DOCKERFILE
|
|
|
|
|
|
|
|
echo "
|
|
|
|
############################################################################
|
|
|
|
################# Dependency: jupyter/scipy-notebook #######################
|
|
|
|
############################################################################
|
|
|
|
" >> $DOCKERFILE
|
|
|
|
cat $STACKS_DIR/scipy-notebook/Dockerfile | grep -v BASE_CONTAINER >> $DOCKERFILE
|
|
|
|
|
2020-06-22 11:26:01 +00:00
|
|
|
# install Julia and R if not excluded or spare mode is used
|
|
|
|
if [[ "$no_datascience_notebook" != 1 ]]; then
|
|
|
|
echo "
|
|
|
|
############################################################################
|
|
|
|
################ Dependency: jupyter/datascience-notebook ##################
|
|
|
|
############################################################################
|
|
|
|
" >> $DOCKERFILE
|
|
|
|
cat $STACKS_DIR/datascience-notebook/Dockerfile | grep -v BASE_CONTAINER >> $DOCKERFILE
|
|
|
|
else
|
|
|
|
echo "Set 'no-datascience-notebook', not installing the datascience-notebook with Julia and R."
|
|
|
|
fi
|
2020-02-20 10:03:48 +00:00
|
|
|
|
|
|
|
# Note that the following step also installs the cudatoolkit, which is
|
|
|
|
# essential to access the GPU.
|
|
|
|
echo "
|
|
|
|
############################################################################
|
2020-02-24 20:35:15 +00:00
|
|
|
########################## Dependency: gpulibs #############################
|
2020-02-20 10:03:48 +00:00
|
|
|
############################################################################
|
|
|
|
" >> $DOCKERFILE
|
2020-02-24 20:35:15 +00:00
|
|
|
cat src/Dockerfile.gpulibs >> $DOCKERFILE
|
2020-02-20 10:03:48 +00:00
|
|
|
|
2020-06-22 11:26:01 +00:00
|
|
|
# install useful packages if not excluded or spare mode is used
|
|
|
|
if [[ "$no_useful_packages" != 1 ]]; then
|
|
|
|
echo "
|
|
|
|
############################################################################
|
|
|
|
############################ Useful packages ###############################
|
|
|
|
############################################################################
|
|
|
|
" >> $DOCKERFILE
|
|
|
|
cat src/Dockerfile.usefulpackages >> $DOCKERFILE
|
|
|
|
else
|
|
|
|
echo "Set 'no-useful-packages', not installing stuff within src/Dockerfile.usefulpackages."
|
|
|
|
fi
|
2020-02-20 10:03:48 +00:00
|
|
|
|
2020-02-25 07:40:59 +00:00
|
|
|
# Copy the demo notebooks and change permissions
|
|
|
|
cp -r extra/Getting_Started data
|
|
|
|
chmod -R 755 data/
|
2020-02-26 08:22:01 +00:00
|
|
|
|
2020-02-26 10:03:52 +00:00
|
|
|
# Copying config
|
2020-02-26 07:06:49 +00:00
|
|
|
cp src/jupyter_notebook_config.json .build/
|
2020-02-26 08:22:01 +00:00
|
|
|
echo >> $DOCKERFILE
|
2020-02-26 10:03:52 +00:00
|
|
|
echo "# Copy jupyter_notebook_config.json" >> $DOCKERFILE
|
2020-02-26 08:22:01 +00:00
|
|
|
echo "COPY jupyter_notebook_config.json /etc/jupyter/" >> $DOCKERFILE
|
|
|
|
|
2020-02-22 19:40:18 +00:00
|
|
|
#cp $(find $(dirname $DOCKERFILE) -type f | grep -v $STACKS_DIR | grep -v .gitkeep) .
|
2020-02-22 17:56:54 +00:00
|
|
|
|
2020-06-22 08:12:46 +00:00
|
|
|
echo "GPU Dockerfile was generated successfully in file ${DOCKERFILE}."
|
|
|
|
echo "Run 'bash start-local.sh -p [PORT]' to start the GPU-based Juyterlab instance."
|