Mopidy3

Mopidy3

Docker app from daredoes' Repository

Overview

Mopidy is an extensible music server written in Python.
Mopidy plays music from local disk, Spotify, SoundCloud, Google Play Music, and more. You edit the playlist from any phone, tablet, or computer using a range of MPD and web clients.

This is Mopidy3 for Unraid with support for snapcast and multiple instances with automatic snapcast stream management.

  • set up the docker
  • set up volume mount to /mnt/user/appdata/mopidy/ >> /config/
  • add TCP ports for MPD, HTTP and TCP ports for each additional instance you want

A configuration has been autogenerated with basic settings. The template for it can be found in the container in /home/templates. It is located in /etc/mopidy

Do NOT modify the part of the audio output setting that says port=4953. This is automatically replaced for each instance generated to fill in the host and port.

To configure the instance and snapcast settings, copy the template to your config folder and modify it. cp /home/templates/server.json /config/.

This container packages mopidy3

Comes pre-loaded with spotify, youtube, gstreamer, iris, etc

Built on Ubuntu.

Made because the only other option wasn't working for me :(

Examples

Run Mopidy3 with in host mode with a /music folder in the present working directory, and mapping mopidy's internal data to /data:

docker run --network host -d \
    -v $(pwd)/music:/media \
    -v $(pwd)/data:/home/.local/share/mopidy \
    daredoes/mopidy3

Run Mopidy3 with specified ports with a `/music`` folder in the present working directory:

docker run --network host -d \
    -p 9001:9001 \
    -p 6680:6680 \
    -p 6600:6600 \
    -p 4953:4953 \
    -v $(pwd)/music:/media \
    -v $(pwd)/data:/home/.local/share/mopidy \
    daredoes/mopidy3

How It Works

Here's a detailed explanation of how the Mopidy Docker container and its components interact:

  1. Dockerfile Setup: The Dockerfile sets up the Mopidy environment by installing essential dependencies, including Mopidy with YouTube support, Supervisor, and other required packages. It also copies necessary files into the container. Additionally, a custom sed hack is applied to enable library scanning from Iris.

  2. Entrypoint Execution: When the Docker container is started, it executes an entrypoint script. This script triggers a Python script responsible for creating a Supervisord configuration entry for each server defined in the servers.json file. Each configuration entry stores unique information specific to the instance as environment variables.

  3. Supervisor Initialization: Supervisor is launched and listens on port 9001. It orchestrates the following tasks:

    • Initiates a library scan using scan_library.sh and the configuration from /etc/mopidy/mopidy.conf. This step ensures that Mopidy has up-to-date information about available music.
    • Starts each Mopidy instance defined in the Supervisord configuration. These instances are configured based on the environment variables set during entrypoint execution.
  4. Instance Startup: The Mopidy instances start by executing start_mopidy.sh. This script performs the following actions:

    • Logs relevant information to the console for debugging and monitoring purposes.
    • Attempts to install Python packages listed in the requirements.txt file, with the file path specified in the REQUIREMENTS_FILE environment variable.
    • Triggers start.py, which serves several key functions:
      • It checks for and terminates any processes already running on the specified ports, ensuring a clean start.
      • Removes any streams in Snapcast with the same ID as the current instance to prevent conflicts.
      • Sends Snapcast information about the new stream, allowing synchronized audio playback.
  5. Mopidy Execution: With all the necessary preparations complete, Mopidy starts running. Users can access it via the specified web port. Note that issues with Mopidy's configuration file (mopidy.conf) can lead to connectivity problems. Be cautious when modifying this file, as adding a ; to a line renders the entire line invalid. Ensure that any changes made are properly configured to avoid disruptions in Mopidy's operation.

Environment Variables

Here's a table describing the environment variables used in the Dockerfile and how they are utilized in the Python file:

Environment Variable Description Usage in Python File
XDG_CACHE_DIR Cache directory path Used to define the cache directory where Mopidy and other components can store cached data.
XDG_CONFIG_DIR Configuration directory path Specifies the directory where Mopidy should look for its configuration file (mopidy.conf).
XDG_DATA_DIR Data directory path Indicates the directory where Mopidy stores data, such as databases and other persistent information, except sometimes it just puts it in /home/.local/share/mopidy instead.
REQUIREMENTS_FILE Requirements file path Points to the location of the requirements.txt file, which is used for installing Python dependencies.
IRIS_USE_SUDO Boolean flag (true or false) Determines whether Mopidy Iris should use sudo when executing certain commands (typically set to false).
TEMPLATES_DIR Templates directory path Specifies the directory where various templates, including mopidy.conf, are stored for configuration purposes.

These environment variables are utilized in the Python file to configure and customize the behavior of the Mopidy and related services. They are used for various purposes such as defining file paths, configuring Mopidy, and specifying options for different components.

Install Mopidy3 on Unraid in a few clicks.

Find Mopidy3 in Community Apps on your Unraid server, review the template, and click Install. Unraid handles the Docker app or plugin setup from the published template.

Open the Apps tab on your Unraid server Search Community Apps for Mopidy3 Review the template variables and paths Click Install

Download Statistics

5,372
Total Downloads

Related apps

Details

Repository
daredoes/mopidy3:stable
Last Updated2023-09-05
First Seen2023-08-24

Runtime arguments

Web UI
http://[IP]:[PORT:9001]/
Network
bridge
Shell
bash
Privileged
false

Template configuration

configPathrw

Where the config files live

Target
/etc/mopidy/
Default
/mnt/user/appdata/Mopidy3/config
Value
/mnt/user/appdata/mopidy/config
dataPathrw

Where the Mopidy Data lives

Target
/data/
Default
/mnt/user/appdata/Mopidy3/data
Value
/mnt/user/appdata/mopidy/data
MusicPathrw

The location of your music

Target
/media
SharePathrw

The location where DB files are stored. If you don't add this, your docker image will bloat.

Target
/home/.local/share/mopidy/
Default
/mnt/user/appdata/Mopidy3/share
MPD PortPorttcp

This should match whats in your config

Target
6600
Default
6600
Value
6600
HTTP PortPorttcp

Where the webserver lives

Target
6680
Default
6680
Value
6680
HTTP PortPorttcp

The default port for TCP Streams in Snapcast

Target
4593
Default
4593
Value
4593
Supervisord PortPorttcp

Where the supervisord web UI lives

Target
9001
Default
9001
Value
9001
Templates DirVariable

The folder location where template files are accessed

Target
TEMPLATES_DIR
Default
/home/templates
Requirements FileVariable

The file location of a custom requirements.txt you want installed at the start of each mopidy instance.

Target
REQUIREMENTS_FILE
Default
/etc/mopidy/requirements.txt