From 1012b69fc8f6e90d1cad2829e137055e888f1116 Mon Sep 17 00:00:00 2001 From: Charles-William Cummings Date: Tue, 30 Mar 2021 15:38:51 -0400 Subject: [PATCH 1/4] dockerfile now downloads tutorial notebooks when started --- Dockerfile | 11 +++++++++-- download-notebooks.sh | 11 +++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) create mode 100755 download-notebooks.sh diff --git a/Dockerfile b/Dockerfile index c4811c6..65bd313 100644 --- a/Dockerfile +++ b/Dockerfile @@ -55,10 +55,17 @@ ADD https://raw.githubusercontent.com/jupyter/docker-stacks/master/base-notebook RUN chmod a+rx /usr/local/bin/start.sh /usr/local/bin/start-singleuser.sh /usr/local/bin/start-notebook.sh /usr/local/bin/fix-permissions; \ chmod a+r /etc/jupyter/jupyter_notebook_config.py +# Prepare script and tutorial notebooks folder +COPY download-notebooks.sh /download-notebooks.sh +RUN mkdir -p /notebook_dir/tutorial-notebooks +# Change notebook folder's permission so user jenkins can execute the script and add notebooks to the tutorial folder +RUN chmod a+rx /download-notebooks.sh ; \ + chmod -R a+rwx /notebook_dir/tutorial-notebooks + # problem running start-notebook.sh when being root # the jupyter/base-notebook image also do not default to root user so we do the same here USER jenkins # follow jupyter/base-notebook image so config in jupyterhub is simpler -# start notebook in conda environment to have working jupyter extensions -CMD ["conda", "run", "-n", "birdy", "/usr/local/bin/start-notebook.sh"] +# download tutorial-notebooks and start notebook in conda environment to have working jupyter extensions +CMD ["/bin/bash", "-c", "/download-notebooks.sh && conda run -n birdy /usr/local/bin/start-notebook.sh --SingleUserNotebookApp.default_url=/lab"] diff --git a/download-notebooks.sh b/download-notebooks.sh new file mode 100755 index 0000000..36bf511 --- /dev/null +++ b/download-notebooks.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +# Notebook directory used by JupyterHub in birdhouse-deploy +notebook_dir="/notebook_dir/tutorial-notebooks" + +# Download notebooks required for the base image and add them to the notebook directory +wget -O - https://github.com/Ouranosinc/pavics-sdi/archive/master.tar.gz | \ + tar -xz --wildcards -C $notebook_dir --strip=4 "*/docs/source/notebooks/jupyter_extensions.ipynb" + +# Remove write permission on the tutorial-notebooks +chmod -R 555 $notebook_dir/* From b37b2a04d3bd9d4ee78dda8c41b4ceb7d9ef1b11 Mon Sep 17 00:00:00 2001 From: Charles-William Cummings Date: Tue, 30 Mar 2021 17:09:23 -0400 Subject: [PATCH 2/4] added documentation --- CHANGELOG.md | 11 +++++++++++ README.md | 3 +++ 2 files changed, 14 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 821736c..0a5ca35 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,17 @@ Fixes: ------ - ... +0.2.0 (2021-03-30) +=================== + +Changes: +-------- +- Custom tutorial notebooks are added when executing the Docker image entrypoint + +Fixes: +------ +- na + 0.1.0 (2021-02-19) =================== diff --git a/README.md b/README.md index be09946..11e3aab 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,9 @@ Base Jupyter docker image for PAVICS. Specialized component images will be built from this image for both CRIM and Ouranos organizations. +Tutorial notebooks are included with the docker image. Each specialized images provides its own custom notebooks, and +all generic notebooks of the base image are downloaded and added when starting the Docker container from JupyterHub. + Repos for the component images : * crim-ca/pavics-jupyter-images : https://github.com/crim-ca/pavics-jupyter-images * Ouranosinc/pavics-jupyter-images : to be created From 3c659dfae8bbb5cdfe1b888a1b7d17b4271bec7b Mon Sep 17 00:00:00 2001 From: Charles-William Cummings Date: Wed, 31 Mar 2021 08:14:17 -0400 Subject: [PATCH 3/4] rename variable in script --- download-notebooks.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/download-notebooks.sh b/download-notebooks.sh index 36bf511..b3e8b1a 100755 --- a/download-notebooks.sh +++ b/download-notebooks.sh @@ -1,11 +1,11 @@ #!/bin/sh # Notebook directory used by JupyterHub in birdhouse-deploy -notebook_dir="/notebook_dir/tutorial-notebooks" +NOTEBOOK_DIR="/notebook_dir/tutorial-notebooks" # Download notebooks required for the base image and add them to the notebook directory wget -O - https://github.com/Ouranosinc/pavics-sdi/archive/master.tar.gz | \ - tar -xz --wildcards -C $notebook_dir --strip=4 "*/docs/source/notebooks/jupyter_extensions.ipynb" + tar -xz --wildcards -C $NOTEBOOK_DIR --strip=4 "*/docs/source/notebooks/jupyter_extensions.ipynb" # Remove write permission on the tutorial-notebooks -chmod -R 555 $notebook_dir/* +chmod -R 555 $NOTEBOOK_DIR/* From e165fb431503b84507690157a7e4c1c529972bf7 Mon Sep 17 00:00:00 2001 From: Charles-William Cummings Date: Fri, 16 Apr 2021 13:22:37 -0400 Subject: [PATCH 4/4] revert first solution changes and add jq/yq installation to read yaml files from the deploy scripts --- CHANGELOG.md | 4 ++-- Dockerfile | 13 +++---------- README.md | 3 --- download-notebooks.sh | 11 ----------- environment/environment_main.yml | 2 ++ 5 files changed, 7 insertions(+), 26 deletions(-) delete mode 100755 download-notebooks.sh diff --git a/CHANGELOG.md b/CHANGELOG.md index 0a5ca35..f30b5ef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,12 +12,12 @@ Fixes: ------ - ... -0.2.0 (2021-03-30) +0.2.0 (2021-04-16) =================== Changes: -------- -- Custom tutorial notebooks are added when executing the Docker image entrypoint +- Add the jq/yq installations, which are required for the deploy scripts for the notebooks in JupyterHub. Fixes: ------ diff --git a/Dockerfile b/Dockerfile index 65bd313..cf6c57b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,7 +4,7 @@ RUN conda update conda # to checkout other notebooks and to run pip install RUN apt-get update && \ - DEBIAN_FRONTEND=noninteractive apt-get install -y git mercurial gcc && \ + DEBIAN_FRONTEND=noninteractive apt-get install -y git mercurial gcc jq && \ apt-get clean COPY environment /environment @@ -55,17 +55,10 @@ ADD https://raw.githubusercontent.com/jupyter/docker-stacks/master/base-notebook RUN chmod a+rx /usr/local/bin/start.sh /usr/local/bin/start-singleuser.sh /usr/local/bin/start-notebook.sh /usr/local/bin/fix-permissions; \ chmod a+r /etc/jupyter/jupyter_notebook_config.py -# Prepare script and tutorial notebooks folder -COPY download-notebooks.sh /download-notebooks.sh -RUN mkdir -p /notebook_dir/tutorial-notebooks -# Change notebook folder's permission so user jenkins can execute the script and add notebooks to the tutorial folder -RUN chmod a+rx /download-notebooks.sh ; \ - chmod -R a+rwx /notebook_dir/tutorial-notebooks - # problem running start-notebook.sh when being root # the jupyter/base-notebook image also do not default to root user so we do the same here USER jenkins # follow jupyter/base-notebook image so config in jupyterhub is simpler -# download tutorial-notebooks and start notebook in conda environment to have working jupyter extensions -CMD ["/bin/bash", "-c", "/download-notebooks.sh && conda run -n birdy /usr/local/bin/start-notebook.sh --SingleUserNotebookApp.default_url=/lab"] +# start notebook in conda environment to have working jupyter extensions +CMD ["conda", "run", "-n", "birdy", "/usr/local/bin/start-notebook.sh"] diff --git a/README.md b/README.md index 11e3aab..be09946 100644 --- a/README.md +++ b/README.md @@ -3,9 +3,6 @@ Base Jupyter docker image for PAVICS. Specialized component images will be built from this image for both CRIM and Ouranos organizations. -Tutorial notebooks are included with the docker image. Each specialized images provides its own custom notebooks, and -all generic notebooks of the base image are downloaded and added when starting the Docker container from JupyterHub. - Repos for the component images : * crim-ca/pavics-jupyter-images : https://github.com/crim-ca/pavics-jupyter-images * Ouranosinc/pavics-jupyter-images : to be created diff --git a/download-notebooks.sh b/download-notebooks.sh deleted file mode 100755 index b3e8b1a..0000000 --- a/download-notebooks.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh - -# Notebook directory used by JupyterHub in birdhouse-deploy -NOTEBOOK_DIR="/notebook_dir/tutorial-notebooks" - -# Download notebooks required for the base image and add them to the notebook directory -wget -O - https://github.com/Ouranosinc/pavics-sdi/archive/master.tar.gz | \ - tar -xz --wildcards -C $NOTEBOOK_DIR --strip=4 "*/docs/source/notebooks/jupyter_extensions.ipynb" - -# Remove write permission on the tutorial-notebooks -chmod -R 555 $NOTEBOOK_DIR/* diff --git a/environment/environment_main.yml b/environment/environment_main.yml index 3b784ee..5a189b9 100644 --- a/environment/environment_main.yml +++ b/environment/environment_main.yml @@ -13,5 +13,7 @@ dependencies: # utilities - curl - wget + # to read yaml files from the deploy scripts for the notebooks in JupyterHub + - yq # for pip packages - pip