Your Name 4 years ago
parent
commit
d680b401a4
5 changed files with 58 additions and 13 deletions
  1. 11 7
      mopidy/Dockerfile
  2. 7 5
      mopidy/docker-compose.yml
  3. 6 1
      mopidy/mopidy.conf
  4. 5 0
      rfidac/Dockerfile
  5. 29 0
      rfidac/rfid-test.py

+ 11 - 7
mopidy/Dockerfile

@@ -1,18 +1,22 @@
 FROM arm32v6/alpine
 
+RUN apk add --no-cache py-pip mopidy gstreamer sudo python3-dev \
+ && pip install --upgrade pip
+
+RUN python3 -m pip install Mopidy-Iris \
+ && python3 -m pip install Mopidy-MPD \
+ && python3 -m pip install Mopidy-Youtube
+
 ADD mopidy.conf /home/mopidy/.config/mopidy/mopidy.conf
 ADD asound.conf /etc/asound.conf
+RUN adduser -S mopidy -G audio \
+ && chown -R mopidy /home/mopidy \
+ && echo "mopidy ALL=NOPASSWD: /usr/lib/python?.?/site-packages/mopidy_iris/system.sh" >> /etc/sudoers
 
-RUN adduser -S mopidy \
-  && apk add --no-cache py-pip mopidy gstreamer sudo python-dev \
-  && python3 -m pip install Mopidy-Iris \
-  && python3 -m pip install Mopidy-MPD \
-  && python3 -m pip install Mopidy-Youtube \
-  && chown -R mopidy:mopidy /home/mopidy/
 
 USER mopidy
 
 EXPOSE 6680/tcp
 EXPOSE 6600/tcp
 
-ENTRYPOINT ["/usr/bin/mopidy"]
+ENTRYPOINT ["/usr/bin/mopidy"]

+ 7 - 5
mopidy/docker-compose.yml

@@ -1,11 +1,13 @@
 version: '3.3'
 services:
   mopidy:
-    container_name: mpd
-    image: arm32v6/alpine
+    build: .
+    container_name: mopidy 
+    image: toastie/mopidy 
     ports:
       - '6600:6600'
-      - '6680:80'
+      - '80:6680'
+    devices:
+      - '/dev/snd:/dev/snd'
 
-
-#docker run -it --rm --privileged --device=/dev/snd:/dev/snd --name mpd -p 6600:6600 -p 8000:8000 -p 6680:6680 arm32v6/alpine
+#docker run -it --rm --privileged --device=/dev/snd:/dev/snd --name mpd -p 6600:6600 -p 8000:8000 -p 6680:6680 arm32v6/alpine

+ 6 - 1
mopidy/mopidy.conf

@@ -6,4 +6,9 @@ hostname = ::
 
 [audio]
 mixer = software
-output = alsasink
+output = alsasink
+
+[youtube]
+threads_max = 2 
+search_results = 10
+playlist_max_videos = 20

+ 5 - 0
rfidac/Dockerfile

@@ -0,0 +1,5 @@
+FROM arm32v6/alpine:edge
+
+RUN apk add --no-cache python3 linux-headers \
+ && pip install --upgrade pip
+ && pip3 install evdev

+ 29 - 0
rfidac/rfid-test.py

@@ -0,0 +1,29 @@
+#! /usr/bin/python3
+
+import os
+import subprocess
+import logging
+from shutil import copyfile
+from datetime import datetime
+from evdev import InputDevice, ecodes
+
+logging.basicConfig(level=logging.DEBUG)
+
+def read_rfid():
+    combined_string = ""
+    for event in InputDevice("/dev/input/event0").read_loop():
+        if event.type == ecodes.EV_KEY and event.value == 0:  # value 0 = release key
+            if event.code == 28:  # code 28 = KEY_ENTER
+                return combined_string
+            # [4:5]? .. KEY[] starts with 'KEY_' and we expect one char
+            combined_string += ecodes.KEY[event.code][4:5] 
+
+last_rfid = None
+last_ts = datetime.now()
+while True:
+    rfid = read_rfid()
+    seconds_gone = (datetime.now() - last_ts).total_seconds()
+    print(rfid)
+    last_ts = datetime.now()
+    last_rfid = rfid
+    run_action(script)