Dockerfile 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. # This file creates a container that runs a jupyter lab server on Raspberry Pi
  2. # Originally from: https://github.com/mkjiang/rpi-jupyter/blob/master/Dockerfile and https://github.com/kidig/rpi-jupyter-lab/blob/master/Dockerfile
  3. FROM balenalib/raspberry-pi-python:3.8-build
  4. WORKDIR /root
  5. # Update pip and install jupyter
  6. RUN apt-get update
  7. RUN apt-get install -y libncurses5-dev
  8. RUN apt-get install -y libzmq-dev
  9. RUN apt-get install -y libfreetype6-dev
  10. RUN apt-get install -y libpng-dev
  11. RUN apt-get install -y python-dev --fix-missing
  12. RUN apt-get install -y patch
  13. RUN apt-get install -y build-essential
  14. RUN pip3 install --upgrade pip
  15. RUN pip3 install cython
  16. RUN pip3 install readline ipywidgets jupyter jupyterlab
  17. RUN pip3 install numpy
  18. # needs to build orjson - does not work on armv7
  19. #~ RUN pip3 install ipycanvas
  20. #~ RUN jupyter labextension install ipycanvas
  21. # Configure jupyter
  22. RUN jupyter nbextension enable --py widgetsnbextension
  23. RUN jupyter serverextension enable --py jupyterlab
  24. RUN jupyter notebook --generate-config
  25. RUN mkdir notebooks
  26. RUN sed -i "/c.NotebookApp.open_browser/c c.NotebookApp.open_browser = False" /root/.jupyter/jupyter_notebook_config.py \
  27. && sed -i "/c.NotebookApp.ip/c c.NotebookApp.ip = '*'" /root/.jupyter/jupyter_notebook_config.py \
  28. && sed -i "/c.NotebookApp.notebook_dir/c c.NotebookApp.notebook_dir = '/root'" /root/.jupyter/jupyter_notebook_config.py \
  29. && sed -i "/c.NotebookApp.password/c c.NotebookApp.password = 'sha1:5815fb7ca805:f09ed218dfcc908acb3e29c3b697079fea37486a'" /root/.jupyter/jupyter_notebook_config.py
  30. VOLUME /root/notebooks
  31. # Add Tini. Tini operates as a process subreaper for jupyter. This prevents kernel crashes.
  32. ENV TINI_VERSION 0.18.0
  33. ENV CFLAGS="-DPR_SET_CHILD_SUBREAPER=36 -DPR_GET_CHILD_SUBREAPER=37"
  34. ADD https://github.com/krallin/tini/archive/v${TINI_VERSION}.tar.gz /root/v${TINI_VERSION}.tar.gz
  35. RUN apt-get install -y cmake
  36. RUN tar zxvf v${TINI_VERSION}.tar.gz \
  37. && cd tini-${TINI_VERSION} \
  38. && cmake . \
  39. && make \
  40. && cp tini /usr/bin/. \
  41. && cd .. \
  42. && rm -rf "./tini-${TINI_VERSION}" \
  43. && rm "./v${TINI_VERSION}.tar.gz"
  44. ENTRYPOINT ["/usr/bin/tini", "--"]
  45. EXPOSE 8888
  46. # passwd is "code"
  47. CMD ["jupyter", "lab", "--allow-root", "--NotebookApp.token=''", "--NotebookApp.password='argon2:$argon2id$v=19$m=10240,t=10,p=8$GXZHXm2yFviNanoy9hyULw$1YLbN5ymQxuwvwPVN5e0hA'"]