fabio revised this gist . Go to revision
1 file changed, 3 insertions, 1 deletion
mopidy-generate-docker.sh
@@ -70,10 +70,12 @@ RUN apt update && apt upgrade -y \\ | |||
70 | 70 | && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* ~/.cache /root/.cache | |
71 | 71 | ||
72 | 72 | # Needed to map the audio group to the host audio group, | |
73 | - | # and that the mopidy user is part of it, and that the user has the same UID as the host user. | |
73 | + | # and the mopidy user to the current user, so we won't get permission issues | |
74 | + | # while trying to access externally mounted sound devices | |
74 | 75 | RUN usermod -u $(id -u) mopidy | |
75 | 76 | RUN groupmod -g $(grep audio /etc/group | sed -r -e 's/^([^:]+:){2}([0-9]+):.*/\2/') audio | |
76 | 77 | RUN usermod -aG audio mopidy | |
78 | + | ||
77 | 79 | RUN sh -c 'echo "mopidy ALL=NOPASSWD: /usr/local/lib/python3.11/dist-packages/mopidy_iris/system.sh" >> /etc/sudoers' | |
78 | 80 | ||
79 | 81 | USER mopidy |
fabio revised this gist . Go to revision
1 file changed, 5 insertions
mopidy-generate-docker.sh
@@ -14,6 +14,11 @@ | |||
14 | 14 | # directories from the host system ($HOME/.config/mopidy and | |
15 | 15 | # $HOME/.local/share/mopidy). | |
16 | 16 | ||
17 | + | # Content of the companion start.sh script: | |
18 | + | #!/usr/bin/dumb-init /bin/sh | |
19 | + | # set -x | |
20 | + | # mopidy --config /mopidy/mopidy.conf | |
21 | + | ||
17 | 22 | cat <<EOF > Dockerfile | |
18 | 23 | FROM debian:12-slim | |
19 | 24 | LABEL Author="Fabio Manganiello" |
Fabio Manganiello revised this gist . Go to revision
1 file changed, 113 insertions
mopidy-generate-docker.sh(file created)
@@ -0,0 +1,113 @@ | |||
1 | + | #!/bin/bash | |
2 | + | ||
3 | + | # This script generates a Dockerfile and a docker-compose.yml file for running | |
4 | + | # Mopidy with various extensions. | |
5 | + | # | |
6 | + | # This is customized for my setup, so you may need to adjust it to fit the | |
7 | + | # extensions that you actually need. | |
8 | + | # | |
9 | + | # You may also want to use a Pulse sink for audio output if you already have | |
10 | + | # PulseAudio running on the host system, otherwise ALSA won't to | |
11 | + | # control the audio output. | |
12 | + | # | |
13 | + | # Also note that the docker-compose.yml will mount the configuration and work | |
14 | + | # directories from the host system ($HOME/.config/mopidy and | |
15 | + | # $HOME/.local/share/mopidy). | |
16 | + | ||
17 | + | cat <<EOF > Dockerfile | |
18 | + | FROM debian:12-slim | |
19 | + | LABEL Author="Fabio Manganiello" | |
20 | + | ||
21 | + | # Change the architecture if needed, e.g. arm64, armhf, etc. | |
22 | + | ARG ARCH=amd64 | |
23 | + | ||
24 | + | ENV DEBIAN_FRONTEND=noninteractive | |
25 | + | ENV PIP_NO_CACHE_DIR=1 | |
26 | + | ||
27 | + | RUN apt update && apt upgrade -y \\ | |
28 | + | && apt install -y \\ | |
29 | + | alsa-utils \\ | |
30 | + | cmake \\ | |
31 | + | curl \\ | |
32 | + | dumb-init \\ | |
33 | + | gstreamer1.0-alsa \\ | |
34 | + | gstreamer1.0-pulseaudio \\ | |
35 | + | libcairo2-dev \\ | |
36 | + | mopidy \\ | |
37 | + | pkg-config \\ | |
38 | + | pulseaudio-utils \\ | |
39 | + | python3-pip \\ | |
40 | + | sudo \\ | |
41 | + | && mkdir -p ~/.config/pip && printf "[global]\nbreak-system-packages = true\n" | tee ~/.config/pip/pip.conf \\ | |
42 | + | && pip install --no-cache-dir \\ | |
43 | + | tidalapi==0.8.3 \\ | |
44 | + | mopidy-bandcamp \\ | |
45 | + | mopidy-funkwhale \\ | |
46 | + | mopidy-iris \\ | |
47 | + | mopidy-jellyfin \\ | |
48 | + | mopidy-local \\ | |
49 | + | mopidy-mobile \\ | |
50 | + | mopidy-mpd \\ | |
51 | + | mopidy-podcast \\ | |
52 | + | mopidy-scrobbler \\ | |
53 | + | mopidy-soundcloud \\ | |
54 | + | mopidy-tidal \\ | |
55 | + | mopidy-tunein \\ | |
56 | + | mopidy-youtube \\ | |
57 | + | yt-dlp \\ | |
58 | + | && apt purge --auto-remove -y \\ | |
59 | + | cmake \\ | |
60 | + | gcc \\ | |
61 | + | libcairo2-dev \\ | |
62 | + | pkg-config \\ | |
63 | + | && apt clean \\ | |
64 | + | && apt autoremove -y \\ | |
65 | + | && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* ~/.cache /root/.cache | |
66 | + | ||
67 | + | # Needed to map the audio group to the host audio group, | |
68 | + | # and that the mopidy user is part of it, and that the user has the same UID as the host user. | |
69 | + | RUN usermod -u $(id -u) mopidy | |
70 | + | RUN groupmod -g $(grep audio /etc/group | sed -r -e 's/^([^:]+:){2}([0-9]+):.*/\2/') audio | |
71 | + | RUN usermod -aG audio mopidy | |
72 | + | RUN sh -c 'echo "mopidy ALL=NOPASSWD: /usr/local/lib/python3.11/dist-packages/mopidy_iris/system.sh" >> /etc/sudoers' | |
73 | + | ||
74 | + | USER mopidy | |
75 | + | ||
76 | + | EXPOSE 6600 | |
77 | + | EXPOSE 6680 | |
78 | + | EXPOSE 5555/udp | |
79 | + | ||
80 | + | ADD ./start.sh /start.sh | |
81 | + | ||
82 | + | ENTRYPOINT ["dumb-init", "--"] | |
83 | + | CMD ["/start.sh"] | |
84 | + | ||
85 | + | HEALTHCHECK --interval=60s --timeout=5s --retries=3 \\ | |
86 | + | CMD curl --connect-timeout 5 --silent --show-error --fail http://localhost:6680/ || exit 1 | |
87 | + | EOF | |
88 | + | ||
89 | + | cat <<EOF > docker-compose.yml | |
90 | + | services: | |
91 | + | mopidy: | |
92 | + | build: | |
93 | + | context: . | |
94 | + | dockerfile: Dockerfile | |
95 | + | container_name: mopidy | |
96 | + | ports: | |
97 | + | - "6600:6600" # MPD port | |
98 | + | - "6680:6680" # HTTP port | |
99 | + | - "5555:5555" # Streaming UDP port | |
100 | + | devices: | |
101 | + | - /dev/snd:/dev/snd # Audio device | |
102 | + | hostname: mopidy | |
103 | + | environment: | |
104 | + | PULSE_SERVER: unix:/run/user/$(id -u)/pulse/native # Adjust user ID as needed | |
105 | + | volumes: | |
106 | + | - /run/user/$(id -u)/pulse:/run/user/$(id -u)/pulse # Adjust user ID as needed | |
107 | + | - /run/user/$(id -u)/pulse/native:/run/user/$(id -u)/pulse/native # Adjust user ID as needed | |
108 | + | # - /mnt/hd/media/music:/mnt/hd/media/music # Music library path | |
109 | + | - $HOME/.config/mopidy/mopidy.conf:/mopidy/mopidy.conf # Configuration file | |
110 | + | - $HOME/.local/share/mopidy:/var/lib/mopidy/.local/share/mopidy # Local data storage | |
111 | + | - ./cache:/var/lib/mopidy/.cache/mopidy | |
112 | + | restart: unless-stopped | |
113 | + | EOF |