Jelajahi Sumber

latest matrix

dirkse 8 tahun lalu
induk
melakukan
8cafe974cf
4 mengubah file dengan 139 tambahan dan 30 penghapusan
  1. 4 3
      hosts.yml
  2. 6 3
      jupyter/Dockerfile
  3. 84 4
      matrix/Dockerfile
  4. 45 20
      services.yml

+ 4 - 3
hosts.yml

@@ -18,9 +18,10 @@ all:
 
   hosts:
     himbeere:
-      ansible_ssh_host: cere.duckdns.org
-      docker_engine_host: localhost
-      docker_engine_port: 10243
+      #~ ansible_ssh_host: cere.duckdns.org
+      #~ docker_engine_host: localhost
+      #~ docker_engine_port: 10243
+      ansible_ssh_host: 192.168.178.43
     blaubeere:
       ansible_ssh_host: 192.168.178.49
 

+ 6 - 3
jupyter/Dockerfile

@@ -3,7 +3,7 @@
 # Author: Max Jiang
 # Date 13/02/2017
 
-FROM resin/rpi-raspbian:jessie
+FROM resin/rpi-raspbian:jessie-20170531
 MAINTAINER Max Jiang <maxjiang@hotmail.com>
 
 # Set the variables
@@ -22,7 +22,10 @@ RUN apt-get update && apt-get upgrade && apt-get install -y \
         libsqlite3-dev \
         tk-dev \
         libssl-dev \
-        openssl
+        openssl \
+        curl \
+        vim \
+        mc
 
 # Download and compile python
 RUN apt-get install -y ca-certificates
@@ -39,7 +42,7 @@ RUN tar zxvf "Python-${PHTHON_VERSION}.tgz" \
 # Update pip and install jupyter
 RUN apt-get install -y libncurses5-dev
 RUN pip3 install --upgrade pip
-RUN pip3 install readline jupyter
+RUN pip3 install readline notebook==5.1.0
 
 # Configure jupyter
 # we run this manually after mounting /root/.jupyter

+ 84 - 4
matrix/Dockerfile

@@ -1,17 +1,97 @@
 FROM resin/rpi-raspbian:jessie-20170531
 
-RUN apt-get update && \
-    apt-get install -y git g++ make python-dev
+# Set the variables
+ENV DEBIAN_FRONTEND noninteractive
+
+WORKDIR /root
+
+# Install packages necessary for compiling python
+RUN apt-get update && apt-get install -y \
+        build-essential \
+        libncursesw5-dev \
+        libgdbm-dev \
+        libc6-dev \
+        zlib1g-dev \
+        libsqlite3-dev \
+        tk-dev \
+        libssl-dev \
+        openssl \
+        curl \
+        vim \
+        git \
+        mc \
+        python \
+        python-dev \
+        python-pip \
+        libncurses5-dev
+
 
 RUN sudo echo "Europe/Berlin" > /etc/timezone
 RUN sudo dpkg-reconfigure -f noninteractive tzdata
 
+# Update pip and install jupyter
+RUN pip install --upgrade pip
+RUN pip install readline notebook==5.1.0
+
+# Configure jupyter
+# we run this manually after mounting /root/.jupyter
+# 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/notebooks'" /root/.jupyter/jupyter_notebook_config.py
+
+# change to letscode.00
+# sudo vi /opt/fast/jupyter/config_root/jupyter_notebook_config.py
+
+
+VOLUME /root/notebooks
+
+# Add Tini. Tini operates as a process subreaper for jupyter. This prevents kernel crashes.
+ENV TINI_VERSION 0.14.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
+
+CMD ["jupyter", "notebook", "--allow-root"]
+
+HEALTHCHECK --interval=10s CMD curl -sS --fail http://localhost:8888 || exit 1
+
+# python-pip
+
+# install ipython2 kernel into jupyter
+# RUN pip install --upgrade pip
+# RUN python2 -m pip install ipykernel
+# RUN python2 -m ipykernel install --user
+
+# this version will be used by matrix python bindings
+RUN pyversions -d
+
 RUN git clone https://github.com/hzeller/rpi-rgb-led-matrix.git /matrix
 WORKDIR /matrix
 RUN sed -i "s/=regular/=adafruit-hat/g" lib/Makefile
 
-RUN  apt-get install -y
+# RUN  apt-get install -y
+# for C++-demos
 RUN make -C examples-api-use
 
-CMD sleep 1000000
+# for python interface
+RUN cd bindings/python && make build-python install-python
+
+RUN apt-get -y install python-pillow
 
+RUN pip install ipywidgets path.py requests
+RUN jupyter nbextension enable --py --sys-prefix widgetsnbextension

+ 45 - 20
services.yml

@@ -1,15 +1,28 @@
 ---
 
 jupyter: # pw: letscode.00
-  host: himbeere
-  fqdn: code.cere.duckdns.org
+  host:
+    himbeere:
+      fqdn: code.cere.duckdns.org
+      docker:
+        build: jupyter
+        ports: 17888:80
+        volumes:
+          - /mnt/ssdext/data/jupyter/notebooks:/root/notebooks
+          - /mnt/ssdext/data/jupyter/config:/root/.local
+          - /mnt/ssdext/data/jupyter/config_root:/root/.jupyter
+
+    #~ blaubeere:
+      #~ docker:
+        #~ build: jupyter
+        #~ ports: 17888:8888
+        #~ volumes:
+          #~ - /opt/jupyter/notebooks:/root/notebooks
+          #~ - /opt/jupyter/config:/root/.local
+          #~ - /opt/jupyter/config_root:/root/.jupyter
   docker:
     build: jupyter
-    ports: 17888:80
-    volumes:
-      - /mnt/ssdext/data/jupyter/notebooks:/root/notebooks
-      - /mnt/ssdext/data/jupyter/config:/root/.local
-      - /mnt/ssdext/data/jupyter/config_root:/root/.jupyter
+
 
 domoticz:
   host: himbeere
@@ -37,7 +50,7 @@ netdata:
     - /var/run/docker.sock:/var/run/docker.sock
     ports: 0.0.0.0:19999:19999
 
-# https://github.com/mkueper/rpi-svn/blob/master/Dockerfile
+# https://github.com/mkueper/rpi-svn
 svn:
   host: himbeere
   docker:
@@ -122,7 +135,7 @@ rsync:
 
 
 
-gogs:
+gogs: # git server with wiki
   host: himbeere
   fqdn: git.cere.duckdns.org
   docker:
@@ -145,36 +158,48 @@ graphite:
       - 8125:8125/udp
       - 8126:8126
 
-alexa:
+alexa: # https://alexa.amazon.de
   fqdn: alexa.cere.duckdns.org
   host: himbeere
   docker:
     build: alexa
 
-matrix:
+matrix: # interface with RGB LED-Matrix
   #~ fqdn: alexa.cere.duckdns.org
   host: blaubeere
   docker:
     build: matrix
     # matrix driver needs access to /dev/mem
     privileged: true
+    ports: 17888:8888
+    volumes:
+      - /opt/jupyter/notebooks:/root/notebooks
+      - /opt/jupyter/config:/root/.local
+      - /opt/jupyter/config_root:/root/.jupyter
+      - /opt/jupyter/config_ipy_root:/root/.ipython
   commands:
     # some rotating square
-    demo00: examples-api-use/demo -c 2 --led-show-refresh -D0
+    demo00: examples-api-use/demo -c 4 -L --led-show-refresh -D0
     # forward scrolling an image
-    demo01: examples-api-use/demo -c 2 --led-show-refresh -D1 examples-api-use/runtext.ppm
+    demo01: examples-api-use/demo -c 4 -L --led-show-refresh -D1 examples-api-use/runtext.ppm
     # test image
-    demo03: examples-api-use/demo -c 2 -D3
+    demo03: examples-api-use/demo -c 4 -L -D3
     # Abelian sandpile model (-m <time-step-ms>)
-    demo06: examples-api-use/demo -c 2 -D6
+    demo06: examples-api-use/demo -c 4 -L -D6
     # Conway's game of life (-m <time-step-ms>)
-    demo07: examples-api-use/demo -c 2 -b 50 -m 50 -D7
+    demo07: /bin/bash -c "while true; do examples-api-use/demo -c 4 -L -b 5 -D7 -t 15; done"
     # Langton's ant (-m <time-step-ms>)
-    demo08: examples-api-use/demo -c 2 -m 1  --led-show-refresh -D8
+    demo08: examples-api-use/demo -c 4 -L -m 1  --led-show-refresh -D8
     # Volume bars
-    demo09: examples-api-use/demo -c 2 -D9
+    demo09: examples-api-use/demo -c 4 -L -D9
     # Evolution of color
-    demo10: examples-api-use/demo -c 2 -D10
+    demo10: examples-api-use/demo -c 4 -L -D10
     # Brightness pulse generator
-    demo11: examples-api-use/demo -c 2 --led-pwm-bits=11 -D11
+    demo11: examples-api-use/demo -c 4 -L --led-pwm-bits=11 -D11
+    # python sample: rotatatin block
+    pydemo1: bindings/python/samples/rotating-block-generator.py -c 4 -L --led-show-refresh
+    # python sample: like demo01
+    pydemo2: bindings/python/samples/image-scroller.py -c 4 -L --led-show-refresh -i examples-api-use/runtext.ppm
+    # python sample: rotatatin block
+    pydemo3: bindings/python/samples/simple-square.py -c 4 -L --led-show-refresh