diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..6350f0f --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +test-data/ diff --git a/Dockerfile b/Dockerfile index f3bfda1..0991956 100644 --- a/Dockerfile +++ b/Dockerfile @@ -30,38 +30,35 @@ RUN pip install -U six \ && pip install Mopidy-Local-Images \ && pip install Mopidy-Party \ && pip install Mopidy-Simple-Webclient \ - && pip install --upgrade pafy - -RUN pip install Mopidy-Mopify \ - && pip install Mopidy-Spotmop \ + && pip install Mopidy-Iris \ && 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 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 +ADD mopidy.conf /etc/mopidy.conf ADD entrypoint.sh /entrypoint.sh -RUN chown mopidy:audio -R /var/lib/mopidy/.config \ +RUN chown mopidy:audio -R /var/lib/mopidy \ && chown mopidy:audio /entrypoint.sh -USER mopidy +ADD localscan /usr/bin/localscan +RUN chmod +x /usr/bin/localscan -VOLUME /var/lib/mopidy/local -VOLUME /var/lib/mopidy/media -VOLUME /var/lib/mopidy/.config/mopidy/account-config +VOLUME /var/lib/mopidy +VOLUME /media +VOLUME /mopidy.conf EXPOSE 6600 EXPOSE 6680 -EXPOSE 1704 -EXPOSE 1705 +EXPOSE 6681 + +USER mopidy ENTRYPOINT ["/entrypoint.sh"] -CMD ["/usr/bin/mopidy"] - -ADD audio.conf /var/lib/mopidy/.config/mopidy/audio.conf +CMD ["/usr/bin/mopidy"] \ No newline at end of file diff --git a/Makefile b/Makefile index 01fc380..e0d18e9 100644 --- a/Makefile +++ b/Makefile @@ -1,21 +1,14 @@ -all: snapcast pulseaudio - -snapcast: - cp audio-snapcast.conf audio.conf - docker build -t whhoesj/mopidy:snapcast . +all: pulseaudio pulseaudio: - cp audio-pulseaudio.conf audio.conf docker build -t whhoesj/mopidy:pulseaudio . docker build -t whhoesj/mopidy:latest . push: - docker push whhoesj/mopidy:snapcast docker push whhoesj/mopidy:pulseaudio docker push whhoesj/mopidy:latest clean: - -rm -rfv audio.conf - -docker rmi whhoesj/mopidy:snapcast -docker rmi whhoesj/mopidy:pulseaudio -docker rmi whhoesj/mopidy:latest + rm -rfv test-data/ diff --git a/README.md b/README.md index 907b787..b905c38 100644 --- a/README.md +++ b/README.md @@ -1,23 +1,59 @@ -# Mopidy +# Mopidy Docker image Image for running [Mopidy](https://www.mopidy.com/) in Docker. -Supports audio output with Pulseaudio or [Snapcast](https://github.com/badaix/snapcast). +Uses Pulseaudio for audio output. -## Tags -`snapcast` uses Snapcast for audio output -`latest` and `pulseaudio` uses Pulseaudio for audio output +## Contents +### Frontend extensions +* [Iris](https://github.com/jaedb/Iris) +* [Mopidy Musicbox Webclient](https://github.com/pimusicbox/mopidy-musicbox-webclient) +* [Mopidy Party](https://github.com/Lesterpig/mopidy-party) +* [Mopidy Simple webclient](https://github.com/xolox/mopidy-simple-webclient) +* [API explorer](https://github.com/dz0ny/mopidy-api-explorer) +* [Local images](https://github.com/tkem/mopidy-local-images) + +### Backend extensions +* Spotify +* Spotify tunigo +* Youtube +* Soundcloud +* Scrobbler +* Tunein +* Local SQLite ## How to use ```bash - docker run \ - --name mopidy \ - -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/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 - -p 1704:1704 \ # Port for Snapcast streaming - -p 1705:1705 \ # Port for Snapcast control - whhoesj/mopidy +docker run \ + --name mopidy \ + -e PULSE_SERVER=tcp:127.0.0.1:4713 \ # Pulseaudio server + -v $PWD/media:/media:ro \ # Media files + -v $PWD/data:/var/lib/mopidy \ # Mopidy data and cache + -v $PWD/mopidy.conf:/mopidyconf \ # Override config (for accounts) + -p 6600:6600 \ # Port for MPD + -p 6680:6680 \ # Port for the webinterface + -p 6681:6681 \ # (Optional) Port for Iris pusher service + whhoesj/mopidy ``` + +## Volumes +To keep the Mopidy data persistent, `/var/lib/mopidy` should be mounted as a volume. The Mopidy user must have write access to this directory. Set this with `chown -R 105 /path/to/data`. + +## Accounts +To add Spotify, Last.FM etc. accounts, use the `/mopidy.conf` file. Example: +``` +[spotify] +enabled = true +username = +password = + +[scrobbler] +enabled = true +username = +password = + +[soundcloud] +enabled = true +auth_token = +``` + +## Local media +To play local media files, mount `/media`. All meta data will be stored using Mopidy-Local-SQLite. To scan for new media files, run `docker exec -it mopidy localscan`. \ No newline at end of file diff --git a/accounts.conf b/accounts.conf deleted file mode 100644 index 41ce79f..0000000 --- a/accounts.conf +++ /dev/null @@ -1,10 +0,0 @@ -[spotify] -username= -password= - -[scrobbler] -username= -password= - -[soundcloud] -auth_token= diff --git a/audio-pulseaudio.conf b/audio-pulseaudio.conf deleted file mode 100644 index 678d215..0000000 --- a/audio-pulseaudio.conf +++ /dev/null @@ -1,5 +0,0 @@ -[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 deleted file mode 100644 index cd3036f..0000000 --- a/audio-snapcast.conf +++ /dev/null @@ -1,5 +0,0 @@ -[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 7dbfd6c..db4ad41 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,7 +1,7 @@ #!/bin/bash -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:/var/lib/mopidy/.config/mopidy/account-config/audio.conf +echo $PWD +cd ~ +echo $PWD +ls -lsa +exec /usr/bin/mopidy --config /etc/mopidy.conf:/mopidy.conf diff --git a/local-scan.sh b/local-scan.sh deleted file mode 100755 index 7fe6347..0000000 --- a/local-scan.sh +++ /dev/null @@ -1,3 +0,0 @@ -#! /bin/bash - -docker exec -it mopidy mopidy local scan diff --git a/localscan b/localscan new file mode 100644 index 0000000..1c1b025 --- /dev/null +++ b/localscan @@ -0,0 +1,2 @@ +#! /bin/bash +/usr/bin/mopidy --config /etc/mopidy.conf:/mopidy.conf local scan \ No newline at end of file diff --git a/mopidy.conf b/mopidy.conf index ed14857..89cbf73 100644 --- a/mopidy.conf +++ b/mopidy.conf @@ -1,73 +1,38 @@ -# For further information about options in this file see: -# http://docs.mopidy.com/ -# -# The initial commented out values reflect the defaults as of: -# Mopidy 0.19.4 -# Mopidy-HTTP 0.19.4 -# Mopidy-Local 0.19.4 -# Mopidy-MPD 0.19.4 -# Mopidy-SoftwareMixer 0.19.4 -# Mopidy-Stream 0.19.4 -# -# Available options and defaults might have changed since then, -# run `mopidy config` to see the current effective config and -# `mopidy --version` to check the current version. - -[logging] -#color = true -#console_format = %(levelname)-8s %(message)s -#debug_format = %(levelname)-8s %(asctime)s [%(process)d:%(threadName)s] %(name)s\n %(message)s -#debug_file = mopidy.log -#config_file = +[core] +data_dir = /var/lib/mopidy/data +cache_dir = /var/lib/mopidy/cache +config_dir = /var/lib/mopidy/config +restore_state = true [audio] -# Check audio.conf for audio output config -#mixer = software +mixer = software mixer_volume = 10 -#visualizer = - -[proxy] -#scheme = -#hostname = -#port = -#username = -#password = +#output = tee name=t t. ! queue ! autoaudiosink t. ! queue ! lamemp3enc ! shout2send mount=mopidy ip=127.0.0.1 port=8000 password=hackme +output = autoaudiosink [local] enabled = true -#library = json -media_dir = /var/lib/mopidy/media -data_dir = /var/lib/mopidy/local -#playlists_dir = /var/lib/mopidy/playlists -#scan_timeout = 1000 -#scan_flush_threshold = 1000 -#excluded_file_extensions = -# .directory -# .html -# .jpeg -# .jpg -# .log -# .nfo -# .png -# .txt +library = sqlite +media_dir = /media +data_dir = /var/lib/mopidy/local +scan_flush_threshold = 100 +scan_timeout = 5000 + +[file] +enabled = false [mpd] enabled = true hostname = 0.0.0.0 port = 6600 -#password = max_connections = 20 connection_timeout = 60 zeroconf = Mopidy MPD server on $hostname -[softwaremixer] -#enabled = true - [http] enabled = true hostname = 0.0.0.0 port = 6680 -#static_dir = zeroconf = Mopidy HTTP server on $hostname [stream] @@ -79,13 +44,9 @@ protocols = rtmp rtmps rtsp -#metadata_blacklist = -#timeout = 5000 [spotify] -enabled = true -#username = -#password = +enabled = false bitrate = 320 [spotify_tunigo] @@ -97,11 +58,9 @@ enabled = false [soundcloud] enabled = false -#auth_token = [scrobbler] enabled = false -#username = -#password = - +[musicbox_webclient] +on_track_click = PLAY_NOW \ No newline at end of file diff --git a/snapserver.deb b/snapserver.deb deleted file mode 100644 index 011f748..0000000 Binary files a/snapserver.deb and /dev/null differ diff --git a/test.sh b/test.sh new file mode 100755 index 0000000..5eec660 --- /dev/null +++ b/test.sh @@ -0,0 +1,13 @@ +#! /bin/bash +docker run \ + --rm \ + --name mopidy \ + -e PULSE_SERVER=tcp:10.10.0.1:4713 \ + -v /home/wouter/Muziek/Spotify:/media:ro \ + -v $PWD/test-data:/var/lib/mopidy \ + -v $PWD/accounts.conf:/mopidy.conf \ + -p 6600:6600 \ + -p 6680:6680 \ + -p 6681:6681 \ + whhoesj/mopidy:latest +