Bladeren bron

Initial commit

Kassim Benhaddad 6 jaren geleden
commit
fb0319a223
9 gewijzigde bestanden met toevoegingen van 222 en 0 verwijderingen
  1. 2 0
      .gitignore
  2. 17 0
      README.md
  3. 24 0
      docker-compose.yaml
  4. 21 0
      icecast/Dockerfile
  5. 58 0
      icecast/icecast.xml
  6. 0 0
      icecast/silence.mp3
  7. 23 0
      icecast/start.sh
  8. 47 0
      mopidy/Dockerfile
  9. 30 0
      mopidy/mopidy.conf

+ 2 - 0
.gitignore

@@ -0,0 +1,2 @@
+.DS_Store
+.vscode/**

+ 17 - 0
README.md

@@ -0,0 +1,17 @@
+# Mopidy with Icecast Docker Containers
+
+This is an effort to create a cohesive Docker container set that can be used to create a user friendly and Internet listenable Mopidy experience.
+
+## Setup
+
+1. Clone this repo somewhere
+2. Go to this link to get your Spotify authorisation details - [https://mopidy.com/ext/spotify/#authentication](https://mopidy.com/ext/spotify/#authentication)
+3. Copy those details in to the relevant part of `mopidy/mopidy.conf`
+4. Run `docker-compose up` in the root of the repo
+5. Once you get the `Starting GLib mainloop` message, navigate to [http://localhost:6680/iris](http://localhost:6680/iris) to start using
+6. Music will be streamed via Icecast at [http://localhost:8000/mopidy](http://localhost:8000/mopidy)
+
+## Things to note
+
+- This is using an experimental version of Mopidy-Iris, so will need to keep paths up to date
+- Sometimes Iris will bug when first opened. Refresh for it to work again

+ 24 - 0
docker-compose.yaml

@@ -0,0 +1,24 @@
+version: "3"
+
+services:
+
+  mopidy:
+    build:
+      context: mopidy/
+    command: mopidy
+    ports:
+     - 6600:6600
+     - 6680:6680
+    depends_on:
+      - icecast
+  
+  icecast:
+    build:
+      context: icecast/
+    environment:
+      - ICECAST_SOURCE_PASSWORD=mopidy
+      - ICECAST_ADMIN_PASSWORD=mopidy
+      - ICECAST_PASSWORD=mopidy
+      - ICECAST_RELAY_PASSWORD=mopidy
+    ports:
+    - 8000:8000

+ 21 - 0
icecast/Dockerfile

@@ -0,0 +1,21 @@
+
+FROM debian:stretch
+
+ENV DEBIAN_FRONTEND noninteractive
+
+RUN apt-get -qq -y update && \
+    apt-get -qq -y install icecast2 python-setuptools sudo && \
+    apt-get clean
+
+COPY "icecast.xml" "/usr/share/icecast2/icecast.xml"
+COPY "silence.mp3" "/usr/share/icecast2/web/silence.mp3"
+
+RUN chown -R icecast2 /usr/share/icecast2
+
+VOLUME ["/var/log/icecast2", "/usr/share/icecast2"]
+
+ADD ./start.sh /start.sh
+
+EXPOSE 8000
+
+CMD ["/start.sh"]

+ 58 - 0
icecast/icecast.xml

@@ -0,0 +1,58 @@
+<icecast>
+  <admin>mopidy@icecast</admin>
+  <fileserve>1</fileserve>
+  <hostname>localhost</hostname>
+  <location>Mopidy</location>
+  <shoutcast-mount>/mopidy</shoutcast-mount>
+
+  <limits>
+    <clients>100</clients>
+    <sources>2</sources>
+    <queue-size>524288</queue-size>
+    <client-timeout>30</client-timeout>
+    <header-timeout>15</header-timeout>
+    <source-timeout>10</source-timeout>
+    <burst-on-connect>1</burst-on-connect>
+    <burst-size>65535</burst-size>
+  </limits>
+
+  <authentication>
+    <source-password>mopidy</source-password>
+    <relay-password>mopidy</relay-password>
+    <admin-user>admin</admin-user>
+    <admin-password>mopidy</admin-password>
+  </authentication>
+
+  <listen-socket>
+    <port>8000</port>
+  </listen-socket>
+
+  <http-headers>
+    <header name="Access-Control-Allow-Origin" value="*" />
+  </http-headers>
+
+  <mount>
+    <mount-name>/mopidy</mount-name>
+    <fallback-mount>/silence.mp3</fallback-mount>
+    <fallback-override>1</fallback-override>
+  </mount>
+
+  <paths>
+    <basedir>/usr/share/icecast2</basedir>
+    <logdir>/var/log/icecast2</logdir>
+    <webroot>/usr/share/icecast2/web</webroot>
+    <adminroot>/usr/share/icecast2/admin</adminroot>
+    <alias source="/" destination="/status.xsl"/>
+  </paths>
+
+  <logging>
+    <accesslog>access.log</accesslog>
+    <errorlog>error.log</errorlog>
+    <loglevel>3</loglevel> <!-- 4 Debug, 3 Info, 2 Warn, 1 Error -->
+    <logsize>10000</logsize> <!-- Max size of a logfile -->
+  </logging>
+
+  <security>
+    <chroot>0</chroot>
+  </security>
+</icecast>

+ 0 - 0
icecast/silence.mp3


+ 23 - 0
icecast/start.sh

@@ -0,0 +1,23 @@
+#!/bin/sh
+
+env
+
+set -x
+
+if [ -n "$ICECAST_SOURCE_PASSWORD" ]; then
+    sed -i "s/<source-password>[^<]*<\/source-password>/<source-password>$ICECAST_SOURCE_PASSWORD<\/source-password>/g" /usr/share/icecast2/icecast.xml
+fi
+
+if [ -n "$ICECAST_RELAY_PASSWORD" ]; then
+    sed -i "s/<relay-password>[^<]*<\/relay-password>/<relay-password>$ICECAST_RELAY_PASSWORD<\/relay-password>/g" /usr/share/icecast2/icecast.xml
+fi
+
+if [ -n "$ICECAST_ADMIN_PASSWORD" ]; then
+    sed -i "s/<admin-password>[^<]*<\/admin-password>/<admin-password>$ICECAST_ADMIN_PASSWORD<\/admin-password>/g" /usr/share/icecast2/icecast.xml
+fi
+
+if [ -n "$ICECAST_PASSWORD" ]; then
+    sed -i "s/<password>[^<]*<\/password>/<password>$ICECAST_PASSWORD<\/password>/g" /usr/share/icecast2/icecast.xml
+fi
+
+sudo -Eu icecast2 icecast2 -n -c /usr/share/icecast2/icecast.xml

+ 47 - 0
mopidy/Dockerfile

@@ -0,0 +1,47 @@
+FROM debian:buster
+
+LABEL Author Kassim Benhaddad <kassim@kass.im>
+
+RUN apt-get update \
+       && DEBIAN_FRONTEND=noninteractive apt-get install -y --fix-missing \
+       gcc \
+       curl \
+       python-crypto \
+       python3-setuptools \
+       python-pip \
+       wget \
+       git
+
+RUN curl -L https://apt.mopidy.com/mopidy.gpg -o /tmp/mopidy.gpg \
+       && wget -q -O /etc/apt/sources.list.d/mopidy.list https://apt.mopidy.com/buster.list \
+       && apt-key add /tmp/mopidy.gpg \
+       && apt-get update \
+       && apt-get install -y mopidy \
+       && apt-get install -y mopidy-spotify \
+       && apt-get install -y mopidy-mpd \
+       && apt-get install -y mpc
+
+RUN cd /tmp/ \
+       && git clone --single-branch --branch develop https://github.com/jaedb/Iris.git \
+       && cd Iris \
+       && python3 setup.py install
+
+RUN echo "mopidy ALL=NOPASSWD: /usr/local/lib/python3.7/dist-packages/Mopidy_Iris-3.44.0-py3.7.egg/mopidy_iris/system.sh" >> /etc/sudoers
+
+RUN apt-get purge --auto-remove -y \
+       curl \
+       gcc \
+       && apt-get clean \
+       && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* ~/.cache \
+       && chown mopidy:audio -R /var/lib/mopidy/.config
+
+COPY mopidy.conf /var/lib/mopidy/.config/mopidy/mopidy.conf
+
+USER mopidy
+
+VOLUME /var/lib/mopidy
+
+EXPOSE 6600
+EXPOSE 6680
+
+CMD ["/usr/bin/mopidy"]

+ 30 - 0
mopidy/mopidy.conf

@@ -0,0 +1,30 @@
+[mpd]
+hostname = 0.0.0.0
+
+[http]
+hostname = 0.0.0.0
+
+[audio]
+output = lamemp3enc ! shout2send async=false mount=mopidy ip=icecast port=8000 password=mopidy
+mixer = none
+
+[webhooks]
+enabled = false
+
+[local]
+enabled = false
+
+[file]
+enabled = false
+
+[m3u]
+enabled = false
+
+[spotify]
+username = 
+password = 
+client_id = 
+client_secret = 
+volume_normalization = false
+bitrate = 320
+allow_playlists = false