Skip to content

Instantly share code, notes, and snippets.

@op07n
Last active March 6, 2020 13:26
Show Gist options
  • Save op07n/2138ef2bc59a33f7fe9aac8e5dfcfc71 to your computer and use it in GitHub Desktop.
Save op07n/2138ef2bc59a33f7fe9aac8e5dfcfc71 to your computer and use it in GitHub Desktop.
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"]
#!/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}
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment