Skip to content

Commit

Permalink
Add Docker compose file
Browse files Browse the repository at this point in the history
  • Loading branch information
jjok committed Feb 10, 2023
1 parent 6c92e9f commit 7ebee83
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 30 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ IMAGE := jjok/mopidy
default: build-pi tag down run-bg save

upload-kitchen:
scp ./.dockerignore ./Dockerfile ./Makefile ./mopidy.conf ./requirements.txt pi@kitchen-musicbox.local:mopidy-build/
scp ./.dockerignore ./docker-compose.yml ./Dockerfile ./Makefile ./mopidy.conf ./requirements.txt jonathan@kitchen-musicbox.local:mopidy-build/

upload-office:
scp ./.dockerignore ./Dockerfile ./Makefile ./mopidy.conf ./requirements.txt jonathan@office-musicbox.local:mopidy-build/
scp ./.dockerignore ./docker-compose.yml ./Dockerfile ./Makefile ./mopidy.conf ./requirements.txt jonathan@office-musicbox.local:mopidy-build/

build-pc:
docker build --pull -t $(IMAGE):$(DATE) --build-arg BUILD_FROM=debian:stable-slim .
Expand All @@ -34,4 +34,4 @@ run-bg:
docker run --name mopidy --device /dev/snd --net host -v /home/$(USER)/music:/root/music --restart=unless-stopped -d $(IMAGE):latest

sync-music:
rsync -avP --recursive --files-from=music.txt /media/jonathan/77B9-F955/music/ jonathan@office-musicbox.local:music/
rsync -ahvP --recursive --files-from=music.txt /media/jonathan/77B9-F955/music/ jonathan@office-musicbox.local:music/
98 changes: 71 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,18 @@ My Mopidy Setup
===============

This is the Docker image that I'm currently using to run [Mopidy](https://www.mopidy.com/) on a Raspberry Pi Zero with
[PhatDAC](https://shop.pimoroni.com/products/phat-dac) and a Pi 2 with an IQAudio DAC.
[PhatDAC](https://shop.pimoroni.com/products/phat-dac) and a Pi 2 with an IQAudio Pi-DACZero.

It probably won't be exactly the setup you want, but feel free to create a fork for your own setup.

The Mopidy version and all extensions to be installed are defined in `requirements.txt`.

I have music files in `~/music` that I mount into the container.


Build
-----

Build on PC

docker build --pull -t jjok/mopidy --build-arg BUILD_FROM=debian:stable-slim .
Expand All @@ -14,25 +22,10 @@ Build on Raspberry Pi

docker build --pull -t jjok/mopidy --build-arg BUILD_FROM=balenalib/raspberry-pi:latest .

Run in foreground:
Run
---

docker run --rm \
--name mopidy \
--device /dev/snd \
--net host \
-v /home/jonathan/music/music:/root/music \
-it \
jjok/mopidy

Run in background:

docker run --restart=unless-stopped \
--name mopidy \
--device /dev/snd \
-p 6600:6600 -p 6680:6680 \
-v /home/pi/music/music:/root/music \
-d \
jjok/mopidy
docker compose up -d

View logs:

Expand All @@ -48,11 +41,62 @@ Execute any Mopidy command:
Raspberry PI Setup
------------------

1. Burn Raspberry PI OS to SD card (8GB+).
2. Put SD card in Raspberry Pi.
3. Install Docker CE.
4. Copy `Dockerfile`, `requirements.txt` and `mopidy.conf` to the Pi.
5. Run `build` command (takes around 30 minutes on Pi Zero)
6. Run "Run in background" command
7. Install [PhatDAC](https://learn.pimoroni.com/tutorial/phat/raspberry-pi-phat-dac-install) soundcard
8. Reboot
1. Burn Raspberry PI OS to SD card (8GB+). Put SD card in Raspberry Pi.
2. Install [Docker CE](https://docs.docker.com/engine/install/ubuntu/#install-using-the-convenience-script).
3. Copy files to the Pi.
* `.dockerignore`
* `docker-compose.yml`
* `Dockerfile`
* `Makefile`
* `mopidy.conf`
* `requirements.txt`
4. Run `build` command (takes around 30 minutes on Pi Zero)
5. Install soundcard (see below).
6. Run container
7. Reboot


Install PhatDAC
---------------

https://learn.pimoroni.com/tutorial/phat/raspberry-pi-phat-dac-install

Edit `/boot/config.txt`.

Remove this line:

dtparam=audio=on

Add this line:

dtoverlay=hifiberry-dac

You might need to do some other stuff too. I haven't tried this manually yet.


Install IQaudIO Pi-DACZero
--------------------------

https://github.com/iqaudio/UserDocs/blob/master/userguide.pdf

Edit `/boot/config.txt`.

Remove this line:

dtparam=audio=on

Add this line:

dtoverlay=iqaudio-dacplus


Mount music from USB
--------------------

mkdir ~/usb
mkdir ~/music

Add these lines to `/etc/fstab`.

/dev/sda1 /home/jonathan/usb vfat defaults 0 0
/home/jonathan/usb/music /home/jonathan/music none defaults,rbind 0 0
10 changes: 10 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
services:
mopidy:
container_name: mopidy
image: jjok/mopidy:latest
devices:
- /dev/snd
volumes:
- /home/jonathan/music:/root/music:ro
restart: unless-stopped
network_mode: host

0 comments on commit 7ebee83

Please sign in to comment.