Last active
March 6, 2020 13:26
-
-
Save op07n/2138ef2bc59a33f7fe9aac8e5dfcfc71 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM python:3.7 | |
RUN pip3 install \ | |
voila \ | |
ipywidgets numpy matplotlib | |
# create a user, since we don't want to run as root | |
RUN useradd -m jovyan | |
ENV HOME=/home/jovyan | |
WORKDIR $HOME | |
USER jovyan | |
COPY --chown=jovyan:jovyan entrypoint.sh /home/jovyan | |
COPY --chown=jovyan:jovyan Presentation.ipynb /home/jovyan | |
EXPOSE 8888 | |
ENTRYPOINT ["/home/jovyan/entrypoint.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# For a command line such as: | |
# "/home/jovyan/entrypoint.sh jupyter notebook --ip 0.0.0.0 --port 59537 --NotebookApp.custom_display_url=http://127.0.0.1:59537" | |
# strip out most args, just pass on the port | |
collect_port=0 | |
port="8888" | |
delim='=' | |
for var in "$@" | |
do | |
echo "$var" | |
if [ "$collect_port" == "1" ]; then | |
echo "Collecting external port $var" | |
port=$var | |
collect_port=0 | |
fi | |
splitarg=${var%%$delim*} | |
if [ "$splitarg" == "--port" ]; then | |
if [ ${#splitarg} == ${#var} ]; then | |
collect_port=1 | |
else | |
port=${var#*$delim} | |
echo "Setting external port $port" | |
fi | |
fi | |
done | |
base_url=$JUPYTERHUB_SERVICE_PREFIX | |
voila /home/jovyan/Presentation.ipynb --port=${port} --no-browser --Voila.base_url=${base_url} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment