Dockerfile 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. RUN pip3 install pillow
  19. RUN pip3 install pyzmq
  20. # needs to build orjson - does not work on armv7
  21. #~ RUN pip3 install ipycanvas
  22. #~ RUN jupyter labextension install ipycanvas
  23. # Configure jupyter
  24. RUN jupyter nbextension enable --py widgetsnbextension
  25. RUN jupyter serverextension enable --py jupyterlab
  26. RUN jupyter notebook --generate-config
  27. RUN mkdir notebooks
  28. RUN sed -i "/c.NotebookApp.open_browser/c c.NotebookApp.open_browser = False" /root/.jupyter/jupyter_notebook_config.py \
  29. && sed -i "/c.NotebookApp.ip/c c.NotebookApp.ip = '*'" /root/.jupyter/jupyter_notebook_config.py \
  30. && sed -i "/c.NotebookApp.notebook_dir/c c.NotebookApp.notebook_dir = '/root'" /root/.jupyter/jupyter_notebook_config.py \
  31. && sed -i "/c.NotebookApp.password/c c.NotebookApp.password = 'sha1:5815fb7ca805:f09ed218dfcc908acb3e29c3b697079fea37486a'" /root/.jupyter/jupyter_notebook_config.py
  32. VOLUME /root/notebooks
  33. # Add Tini. Tini operates as a process subreaper for jupyter. This prevents kernel crashes.
  34. ENV TINI_VERSION 0.18.0
  35. ENV CFLAGS="-DPR_SET_CHILD_SUBREAPER=36 -DPR_GET_CHILD_SUBREAPER=37"
  36. ADD https://github.com/krallin/tini/archive/v${TINI_VERSION}.tar.gz /root/v${TINI_VERSION}.tar.gz
  37. RUN apt-get install -y cmake
  38. RUN tar zxvf v${TINI_VERSION}.tar.gz \
  39. && cd tini-${TINI_VERSION} \
  40. && cmake . \
  41. && make \
  42. && cp tini /usr/bin/. \
  43. && cd .. \
  44. && rm -rf "./tini-${TINI_VERSION}" \
  45. && rm "./v${TINI_VERSION}.tar.gz"
  46. ENTRYPOINT ["/usr/bin/tini", "--"]
  47. EXPOSE 8888
  48. # passwd is "code"
  49. CMD ["jupyter", "lab", "--allow-root", "--NotebookApp.token=''", "--NotebookApp.password='argon2:$argon2id$v=19$m=10240,t=10,p=8$GXZHXm2yFviNanoy9hyULw$1YLbN5ymQxuwvwPVN5e0hA'"]
  50. # local flaschen-taschen terminal
  51. RUN mkdir /opt/ft \
  52. && cd /opt/ft \
  53. && git clone --recursive https://github.com/hzeller/flaschen-taschen.git \
  54. && cd flaschen-taschen/server \
  55. && make FT_BACKEND=terminal
  56. RUN echo '/opt/ft/flaschen-taschen/server/ft-server -D64x64 --hd-terminal --layer-timeout 60' >> /bin/ft64
  57. RUN chmod 777 /bin/ft64
  58. RUN ln -s /opt/ft/flaschen-taschen/server/ft-server /bin/ft
  59. RUN chmod 777 /bin/ft
  60. # some custom libs for jlab
  61. COPY ./matrix_ft.py /usr/local/lib/python3.8/site-packages/matrix_ft.py