# This file creates a container that runs a jupyter lab server on Raspberry Pi # Originally from: https://github.com/mkjiang/rpi-jupyter/blob/master/Dockerfile and https://github.com/kidig/rpi-jupyter-lab/blob/master/Dockerfile FROM balenalib/raspberry-pi-python:3.10-buster-build WORKDIR /root # Update pip and install jupyter # RUN /bin/bash -c 'wget https://archive.raspbian.org/raspbian.public.key -O - | sudo apt-key add -' RUN apt-get update RUN apt-get install -y libncurses5-dev RUN apt-get install -y libzmq-dev RUN apt-get install -y libfreetype6-dev RUN apt-get install -y libpng-dev RUN apt-get install -y python-dev --fix-missing RUN apt-get install -y patch RUN apt-get install -y build-essential RUN pip3 install --upgrade pip RUN pip3 install cython RUN pip3 install readline ipywidgets jupyter jupyterlab RUN pip3 install numpy RUN pip3 install pillow RUN pip3 install pyzmq # needs to build orjson - does not work on armv7 #~ RUN pip3 install ipycanvas #~ RUN jupyter labextension install ipycanvas # Configure jupyter RUN jupyter nbextension enable --py widgetsnbextension RUN jupyter serverextension enable --py jupyterlab RUN jupyter notebook --generate-config RUN mkdir notebooks RUN sed -i "/c.NotebookApp.open_browser/c c.NotebookApp.open_browser = False" /root/.jupyter/jupyter_notebook_config.py \ && sed -i "/c.NotebookApp.ip/c c.NotebookApp.ip = '*'" /root/.jupyter/jupyter_notebook_config.py \ && sed -i "/c.NotebookApp.notebook_dir/c c.NotebookApp.notebook_dir = '/root'" /root/.jupyter/jupyter_notebook_config.py \ && sed -i "/c.NotebookApp.password/c c.NotebookApp.password = 'sha1:5815fb7ca805:f09ed218dfcc908acb3e29c3b697079fea37486a'" /root/.jupyter/jupyter_notebook_config.py # enables sublime mode on all cells (fixes ctrl+d multi select) RUN pip3 install jupyterlab_sublime VOLUME /root/notebooks # Add Tini. Tini operates as a process subreaper for jupyter. This prevents kernel crashes. ENV TINI_VERSION 0.18.0 ENV CFLAGS="-DPR_SET_CHILD_SUBREAPER=36 -DPR_GET_CHILD_SUBREAPER=37" ADD https://github.com/krallin/tini/archive/v${TINI_VERSION}.tar.gz /root/v${TINI_VERSION}.tar.gz RUN apt-get install -y cmake RUN tar zxvf v${TINI_VERSION}.tar.gz \ && cd tini-${TINI_VERSION} \ && cmake . \ && make \ && cp tini /usr/bin/. \ && cd .. \ && rm -rf "./tini-${TINI_VERSION}" \ && rm "./v${TINI_VERSION}.tar.gz" ENTRYPOINT ["/usr/bin/tini", "--"] EXPOSE 8888 # passwd is "code" CMD ["jupyter", "lab", "--collaborative", "--allow-root", "--NotebookApp.token=''", "--NotebookApp.password='argon2:$argon2id$v=19$m=10240,t=10,p=8$GXZHXm2yFviNanoy9hyULw$1YLbN5ymQxuwvwPVN5e0hA'"] # local flaschen-taschen terminal RUN mkdir /opt/ft \ && cd /opt/ft \ && git clone --recursive https://github.com/hzeller/flaschen-taschen.git \ && cd flaschen-taschen/server \ && make FT_BACKEND=terminal RUN echo '/opt/ft/flaschen-taschen/server/ft-server -D64x64 --hd-terminal --layer-timeout 60' >> /bin/ft64 RUN chmod 777 /bin/ft64 RUN ln -s /opt/ft/flaschen-taschen/server/ft-server /bin/ft RUN chmod 777 /bin/ft # some custom libs for jlab COPY ./matrix_ft.py /usr/local/lib/python3.9/site-packages/matrix_ft.py