From b02ed57633780d5849c5646245433c02165af217 Mon Sep 17 00:00:00 2001 From: Stefano Alberto Russo <stefano.russo@gmail.com> Date: Fri, 5 Nov 2021 15:11:33 +0100 Subject: [PATCH] Added the Jupyter Notebook container. --- JupyterNotebook/Dockerfile | 47 +++++++++++++++++++++++++++++ JupyterNotebook/build.sh | 3 ++ JupyterNotebook/files/entrypoint.sh | 22 ++++++++++++++ JupyterNotebook/run.sh | 2 ++ 4 files changed, 74 insertions(+) create mode 100644 JupyterNotebook/Dockerfile create mode 100755 JupyterNotebook/build.sh create mode 100644 JupyterNotebook/files/entrypoint.sh create mode 100755 JupyterNotebook/run.sh diff --git a/JupyterNotebook/Dockerfile b/JupyterNotebook/Dockerfile new file mode 100644 index 0000000..a41065a --- /dev/null +++ b/JupyterNotebook/Dockerfile @@ -0,0 +1,47 @@ +FROM base +MAINTAINER Stefano Alberto Russo <stefano.russo@inaf.it> + +# Switch to root +USER root + +#------------------------ +# Install Jupyter +#------------------------ + +# Curl +RUN apt-get install curl -y + +# Install get-pip script +RUN curl -O https://bootstrap.pypa.io/get-pip.py + +# Install Python3 and Pip3 +RUN apt-get install python3 python3-distutils -y +RUN python3 get-pip.py #-c <(echo 'pip==20.2') + +# Python-tk required by matplotlib/six +RUN apt-get install python-tk python3-tk python3-dev build-essential -y + +# Install Jupyter and Sphinx for docs +RUN pip3 install notebook==5.7.10 + + +#------------------------ +# Post-intall +#------------------------ + +# Fix home permissions +RUN chmod 777 /home + +# Set entrypoint command +COPY files/entrypoint.sh /usr/bin/entrypoint.sh +RUN chmod 755 /usr/bin/entrypoint.sh +ENV DEFAULT_ENTRYPOINT_COMMAND="/usr/bin/entrypoint.sh" + +# Set user +USER metauser + +# Set container name +ENV CONTAINER_NAME='jupyternotebook' + + + diff --git a/JupyterNotebook/build.sh b/JupyterNotebook/build.sh new file mode 100755 index 0000000..62d3197 --- /dev/null +++ b/JupyterNotebook/build.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +docker build . -t jupyternotebook diff --git a/JupyterNotebook/files/entrypoint.sh b/JupyterNotebook/files/entrypoint.sh new file mode 100644 index 0000000..24e59f0 --- /dev/null +++ b/JupyterNotebook/files/entrypoint.sh @@ -0,0 +1,22 @@ +#/bin/bash + +# Set port +if [ "x$BASE_PORT" == "x" ]; then + BASE_PORT=8888 + echo "[INFO] using default Notebook server port (8888)" +else + echo "[INFO] Setting Notebook server port to $BASE_PORT" +fi + +# Set password +if [ "x$AUTH_PASS" == "x" ]; then + echo "[INFO] Not using anyNotebook server password" +else + echo "[INFO] Setting Notebook server password to $AUTH_PASS" +fi + +# Create Notebooks dir if not existent +mkdir -p /home/metauser/notebooks + +# Run the Jupyter Notebook server. Use --allow-root if need to run as root. +exec jupyter notebook --ip=0.0.0.0 --port=$BASE_PORT --no-browser --NotebookApp.token=$AUTH_PASS --NotebookApp.notebook_dir='/home/metauser/notebooks' diff --git a/JupyterNotebook/run.sh b/JupyterNotebook/run.sh new file mode 100755 index 0000000..720602c --- /dev/null +++ b/JupyterNotebook/run.sh @@ -0,0 +1,2 @@ +#!/bin/bash +docker run -v$PWD/:/data -p8881:8881 -eBASE_PORT=8881 -eAAUTH_PASS=testpass -it jupyternotebook -- GitLab