Dockerfile 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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.10-buster-build
  4. WORKDIR /root
  5. # Update pip and install jupyter
  6. # RUN /bin/bash -c 'wget https://archive.raspbian.org/raspbian.public.key -O - | sudo apt-key add -'
  7. RUN apt-get update
  8. RUN apt-get install -y libncurses5-dev
  9. RUN apt-get install -y libzmq-dev
  10. RUN apt-get install -y libfreetype6-dev
  11. RUN apt-get install -y libpng-dev
  12. RUN apt-get install -y python-dev --fix-missing
  13. RUN apt-get install -y patch
  14. RUN apt-get install -y build-essential
  15. RUN pip3 install --upgrade pip
  16. RUN pip3 install cython
  17. RUN pip3 install readline ipywidgets jupyter jupyterlab
  18. RUN pip3 install numpy
  19. RUN pip3 install pillow
  20. RUN pip3 install pyzmq
  21. # needs to build orjson - does not work on armv7
  22. #~ RUN pip3 install ipycanvas
  23. #~ RUN jupyter labextension install ipycanvas
  24. # Configure jupyter
  25. RUN jupyter nbextension enable --py widgetsnbextension
  26. RUN jupyter serverextension enable --py jupyterlab
  27. RUN jupyter notebook --generate-config
  28. RUN mkdir notebooks
  29. RUN sed -i "/c.NotebookApp.open_browser/c c.NotebookApp.open_browser = False" /root/.jupyter/jupyter_notebook_config.py \
  30. && sed -i "/c.NotebookApp.ip/c c.NotebookApp.ip = '*'" /root/.jupyter/jupyter_notebook_config.py \
  31. && sed -i "/c.NotebookApp.notebook_dir/c c.NotebookApp.notebook_dir = '/root'" /root/.jupyter/jupyter_notebook_config.py \
  32. && sed -i "/c.NotebookApp.password/c c.NotebookApp.password = 'sha1:5815fb7ca805:f09ed218dfcc908acb3e29c3b697079fea37486a'" /root/.jupyter/jupyter_notebook_config.py
  33. # enables sublime mode on all cells (fixes ctrl+d multi select)
  34. RUN pip3 install jupyterlab_sublime
  35. VOLUME /root/notebooks
  36. # Add Tini. Tini operates as a process subreaper for jupyter. This prevents kernel crashes.
  37. ENV TINI_VERSION 0.18.0
  38. ENV CFLAGS="-DPR_SET_CHILD_SUBREAPER=36 -DPR_GET_CHILD_SUBREAPER=37"
  39. ADD https://github.com/krallin/tini/archive/v${TINI_VERSION}.tar.gz /root/v${TINI_VERSION}.tar.gz
  40. RUN apt-get install -y cmake
  41. RUN tar zxvf v${TINI_VERSION}.tar.gz \
  42. && cd tini-${TINI_VERSION} \
  43. && cmake . \
  44. && make \
  45. && cp tini /usr/bin/. \
  46. && cd .. \
  47. && rm -rf "./tini-${TINI_VERSION}" \
  48. && rm "./v${TINI_VERSION}.tar.gz"
  49. ENTRYPOINT ["/usr/bin/tini", "--"]
  50. EXPOSE 8888
  51. # passwd is "code"
  52. CMD ["jupyter", "lab", "--collaborative", "--allow-root", "--NotebookApp.token=''", "--NotebookApp.password='argon2:$argon2id$v=19$m=10240,t=10,p=8$GXZHXm2yFviNanoy9hyULw$1YLbN5ymQxuwvwPVN5e0hA'"]
  53. # local flaschen-taschen terminal
  54. RUN mkdir /opt/ft \
  55. && cd /opt/ft \
  56. && git clone --recursive https://github.com/hzeller/flaschen-taschen.git \
  57. && cd flaschen-taschen/server \
  58. && make FT_BACKEND=terminal
  59. RUN echo '/opt/ft/flaschen-taschen/server/ft-server -D64x64 --hd-terminal --layer-timeout 60' >> /bin/ft64
  60. RUN chmod 777 /bin/ft64
  61. RUN ln -s /opt/ft/flaschen-taschen/server/ft-server /bin/ft
  62. RUN chmod 777 /bin/ft
  63. # some custom libs for jlab
  64. COPY ./matrix_ft.py /usr/local/lib/python3.9/site-packages/matrix_ft.py