diff --git a/Dockerfile b/Dockerfile index 79cb179..f3bfda1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -37,6 +37,11 @@ RUN pip install Mopidy-Mopify \ && pip install Mopidy-MusicBox-Webclient \ && pip install Mopidy-API-Explorer +ADD snapserver.deb /tmp/snapserver.deb +RUN apt-get install -y libavahi-client3 libavahi-common3 \ + && dpkg -i /tmp/snapserver.deb \ + && apt-get install -f \ + && rm /tmp/snapserver.deb ADD mopidy.conf /var/lib/mopidy/.config/mopidy/mopidy.conf @@ -53,6 +58,10 @@ VOLUME /var/lib/mopidy/.config/mopidy/account-config EXPOSE 6600 EXPOSE 6680 +EXPOSE 1704 +EXPOSE 1705 ENTRYPOINT ["/entrypoint.sh"] CMD ["/usr/bin/mopidy"] + +ADD audio.conf /var/lib/mopidy/.config/mopidy/audio.conf diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..2b5112e --- /dev/null +++ b/Makefile @@ -0,0 +1,21 @@ +all: snapcast pulseaudio + +snapcast: + cp audio-snapcast.conf audio.conf + docker build -t whhoesj/mopidy:snapcast . + docker build -t whhoesj/mopidy:latest . + +pulseaudio: + cp audio-pulseaudio.conf audio.conf + docker build -t whhoesj/mopidy:pulseaudio . + +push: + docker push whhoesj/mopidy:pulseaudio + docker push whhoesj/mopidy:snapcast + docker push whhoesj/mopidy:latest + +clean: + -rm -rfv audio.conf + -docker rmi whhoesj/mopidy:pulseaudio + -docker rmi whhoesj/mopidy:snapcast + -docker rmi whhoesj/mopidy:latest diff --git a/README.md b/README.md index ce5a559..7182bbf 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,23 @@ -Mopidy -====== -Image for running Mopidy in Docker. -Based on [wernight/docker-mopidy](https://github.com/wernight/docker-mopidy). +# Mopidy +Image for running [Mopidy](https://www.mopidy.com/) in Docker. +Supports audio output with Pulseaudio or [Snapcast](https://github.com/badaix/snapcast). + +## Tags +`latest` and `snapcast` uses Snapcast for audio output +`pulseaudio` uses Pulseaudio for audio output ## How to use ```bash docker run \ --name mopidy \ - -e PULSE_SERVER=tcp:127.0.0.1:4713 \ # Pulseaudio server for sound + -e PULSE_SERVER=tcp:127.0.0.1:4713 \ # (Optional) Pulseaudio server for sound + -e USE_SNAPCAST=true \ # Set true to activate Snapcast (event with the Snapcast image) -v $PWD/media:/var/lib/mopidy/media:ro \ # Media files - -v $PWD/local:/var/lib/mopidy/local \ # Some kind of music storage(?) + -v $PWD/local:/var/lib/mopidy/local \ # Some kind of music storage(?) -v $PWD/account-config:/var/lib/mopidy/.config/mopidy/account-config \ # Place here the account configurations (see account-config.conf) -p 6600:6600 \ # Port for MPD -p 6680:6680 \ # Port for the webinterface - whhoesj/mopidy-web -``` \ No newline at end of file + -p 1704:1704 \ # Port for Snapcast streaming + -p 1705:1705 \ # Port for Snapcast control + whhoesj/mopidy +``` diff --git a/audio-pulseaudio.conf b/audio-pulseaudio.conf new file mode 100644 index 0000000..678d215 --- /dev/null +++ b/audio-pulseaudio.conf @@ -0,0 +1,5 @@ +[output] +# USE THIS FOR PULSEAUDIO +output = autoaudiosink +# USE THIS FOR SNAPCAST +#output = audioresample ! audioconvert ! audio/x-raw,rate=48000,channels=2,format=S16LE ! wavenc ! filesink location=/tmp/snapfifo diff --git a/audio-snapcast.conf b/audio-snapcast.conf new file mode 100644 index 0000000..cd3036f --- /dev/null +++ b/audio-snapcast.conf @@ -0,0 +1,5 @@ +[output] +# USE THIS FOR PULSEAUDIO +#output = autoaudiosink +# USE THIS FOR SNAPCAST +output = audioresample ! audioconvert ! audio/x-raw,rate=48000,channels=2,format=S16LE ! wavenc ! filesink location=/tmp/snapfifo diff --git a/entrypoint.sh b/entrypoint.sh index bfb53fa..7dbfd6c 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,11 +1,7 @@ #!/bin/bash -mopidy local scan - -if [[ "$PULSE_COOKIE_DATA" != "" ]] -then - echo -ne $(echo $PULSE_COOKIE_DATA | sed -e 's/../\\x&/g') >$HOME/pulse.cookie - export PULSE_COOKIE=$HOME/pulse.cookie +if [ "$USE_SNAPCAST" = true ] ; then + snapserver -d fi -exec /usr/bin/mopidy --config /var/lib/mopidy/.config/mopidy/mopidy.conf:/var/lib/mopidy/.config/mopidy/account-config/accounts.conf +exec /usr/bin/mopidy --config /var/lib/mopidy/.config/mopidy/mopidy.conf:/var/lib/mopidy/.config/mopidy/account-config/accounts.conf:/var/lib/mopidy/.config/mopidy/account-config/audio.conf diff --git a/local-scan.sh b/local-scan.sh new file mode 100755 index 0000000..7fe6347 --- /dev/null +++ b/local-scan.sh @@ -0,0 +1,3 @@ +#! /bin/bash + +docker exec -it mopidy mopidy local scan diff --git a/mopidy.conf b/mopidy.conf index 1ab9ef5..ed14857 100644 --- a/mopidy.conf +++ b/mopidy.conf @@ -21,9 +21,9 @@ #config_file = [audio] +# Check audio.conf for audio output config #mixer = software mixer_volume = 10 -#output = autoaudiosink #visualizer = [proxy] @@ -55,7 +55,7 @@ data_dir = /var/lib/mopidy/local enabled = true hostname = 0.0.0.0 port = 6600 -#password = dada123 +#password = max_connections = 20 connection_timeout = 60 zeroconf = Mopidy MPD server on $hostname @@ -84,8 +84,8 @@ protocols = [spotify] enabled = true -#username = -#password = +#username = +#password = bitrate = 320 [spotify_tunigo] @@ -96,11 +96,11 @@ region = all enabled = false [soundcloud] -enabled = true +enabled = false #auth_token = [scrobbler] -enabled = true +enabled = false #username = #password = diff --git a/snapserver.deb b/snapserver.deb new file mode 100644 index 0000000..011f748 Binary files /dev/null and b/snapserver.deb differ