Skip to content

Commit

Permalink
Update docker env
Browse files Browse the repository at this point in the history
  • Loading branch information
Groovylein committed Nov 18, 2023
1 parent c8bc8c0 commit d0e851f
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 50 deletions.
3 changes: 2 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
.git
.githooks
.github
.dockerignore
.DS_Store

# Application
docker
docs
installation
src
shared

# webapp
Expand Down
4 changes: 2 additions & 2 deletions docker/config/docker.pulse.mpd.conf
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# be disabled and audio files will only be accepted over ipc socket (using
# file:// protocol) or streaming files over an accepted protocol.
#
music_directory "/home/pi/RPi-Jukebox-RFID/shared/audiofolders"
music_directory "~/RPi-Jukebox-RFID/shared/audiofolders"
#
# This setting sets the MPD internal playlist directory. The purpose of this
# directory is storage for playlists created by MPD. The server will use
Expand Down Expand Up @@ -67,7 +67,7 @@ sticker_file "~/.config/mpd/sticker.sql"
# initialization. This setting is disabled by default and MPD is run as the
# current user.
#
user "root"
#user "root"
#
# This setting specifies the group that MPD will run as. If not specified
# primary group of user specified with "user" setting will be used (if set).
Expand Down
5 changes: 0 additions & 5 deletions docker/config/jukebox.overrides.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,2 @@
playermpd:
host: mpd
mpd_conf: /etc/mpd.conf
pulse:
outputs:
primary:
pulse_sink_name: Channel_1__Channel_2.2
27 changes: 23 additions & 4 deletions docker/docker-compose.linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,28 @@ version: "3.9"

services:
mpd:
devices:
- /dev/snd
build:
args:
- UID=${UID:-1000}
- USER=pi
- HOME=/home/pi
environment:
- PULSE_SERVER=unix:/tmp/pulse-sock
volumes:
- ../shared/audiofolders:/home/pi/RPi-Jukebox-RFID/shared/audiofolders
- ../shared/playlists:/home/pi/.config/mpd/playlists
- ./config/docker.pulse.mpd.conf:/home/pi/.config/mpd/mpd.conf
- $XDG_RUNTIME_DIR/pulse/native:/tmp/pulse-sock

jukebox:
devices:
- /dev/snd
build:
args:
- UID=${UID:-1000}
- USER=pi
- HOME=/home/pi
environment:
- PULSE_SERVER=unix:/tmp/pulse-sock
volumes:
- ../shared:/home/pi/RPi-Jukebox-RFID/shared
- ./config/docker.pulse.mpd.conf:/home/pi/.config/mpd/mpd.conf
- $XDG_RUNTIME_DIR/pulse/native:/tmp/pulse-sock
32 changes: 18 additions & 14 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,43 @@ version: "3.9"
services:
mpd:
build:
args:
- UID=0
- USER=root
- HOME=/root
context: ../
dockerfile: ./docker/mpd.Dockerfile
container_name: mpd
ports:
- 6600:6600
- 8800:8800
environment:
- PULSE_SERVER=tcp:host.docker.internal:4713
restart: unless-stopped
volumes:
- ../shared/audiofolders:/home/pi/RPi-Jukebox-RFID/shared/audiofolders:rw
- ../shared/playlists:/root/.config/mpd/playlists:rw
- ./config/docker.mpd.conf:/root/.config/mpd/mpd.conf:rw
- ../shared/audiofolders:/root/RPi-Jukebox-RFID/shared/audiofolders
- ../shared/playlists:/root/.config/mpd/playlists
- ./config/docker.pulse.mpd.conf:/root/.config/mpd/mpd.conf

jukebox:
build:
args:
- UID=0
- USER=root
- HOME=/root
context: ../
dockerfile: ./docker/jukebox.Dockerfile
container_name: jukebox
depends_on:
- mpd
links:
- mpd
environment:
- PULSE_SERVER=tcp:host.docker.internal:4713
ports:
- 5555:5555
- 5556:5556
- 5557:5557
restart: unless-stopped
tty: true
volumes:
- ../src/jukebox:/home/pi/RPi-Jukebox-RFID/src/jukebox
- ../shared:/home/pi/RPi-Jukebox-RFID/shared
- ./config/docker.mpd.conf:/etc/mpd.conf
- ../shared:/root/RPi-Jukebox-RFID/shared
- ./config/docker.pulse.mpd.conf:/root/.config/mpd/mpd.conf

webapp:
build:
Expand All @@ -44,10 +50,8 @@ services:
- jukebox
environment:
- CHOKIDAR_USEPOLLING=true
links:
- jukebox
ports:
- 3001:3000
- 3000:3000
restart: unless-stopped
volumes:
- ../src/webapp:/home/node/webapp
Expand Down
22 changes: 12 additions & 10 deletions docker/jukebox.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,36 +5,38 @@ FROM debian:bullseye-slim
# These are only dependencies that are required to get as close to the
# Raspberry Pi environment as possible.
RUN apt-get update && apt-get install -y \
alsa-utils \
libasound2-dev \
libasound2-plugins \
pulseaudio \
pulseaudio-utils \
--no-install-recommends \
&& rm -rf /var/lib/apt/lists/*

RUN usermod -aG audio,pulse,pulse-access root
ARG UID
ARG USER
ARG HOME
ENV INSTALLATION_PATH ${HOME}/RPi-Jukebox-RFID

ENV HOME /root
ENV INSTALLATION_PATH /home/pi/RPi-Jukebox-RFID

WORKDIR $INSTALLATION_PATH
RUN test ${UID} -gt 0 && useradd -m -u ${UID} ${USER} || continue
RUN usermod -aG pulse ${USER}

# Jukebox
# Install all Jukebox dependencies
RUN apt-get update && apt-get install -qq -y \
--allow-downgrades --allow-remove-essential --allow-change-held-packages \
gcc at wget \
espeak mpc mpg123 git ffmpeg spi-tools netcat alsa-tools \
espeak mpc mpg123 git ffmpeg spi-tools netcat \
python3 python3-dev python3-pip python3-mutagen python3-gpiozero

COPY . ${INSTALLATION_PATH}
USER ${USER}
WORKDIR ${INSTALLATION_PATH}
COPY --chown=${USER}:${USER} . ${INSTALLATION_PATH}/

RUN pip3 install --no-cache-dir -r ${INSTALLATION_PATH}/requirements.txt
RUN pip3 install pyzmq

EXPOSE 5555 5556

WORKDIR ${INSTALLATION_PATH}/src/jukebox

# Run Jukebox
# CMD bash
CMD python3 ${INSTALLATION_PATH}/src/jukebox/run_jukebox.py
21 changes: 9 additions & 12 deletions docker/mpd.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,23 @@ FROM debian:bullseye-slim

RUN set -eux ; \
apt-get update && apt-get install -y \
alsa-utils \
libasound2-dev \
libasound2-plugins \
pulseaudio \
pulseaudio-utils \
mpd mpc \
--no-install-recommends \
; \
rm -rf /var/lib/apt/lists/*

ENV HOME /root

RUN mkdir ${HOME}/.config ${HOME}/.config/mpd ; \
touch ${HOME}/.config/mpd/state
RUN mkdir -p /home/pi/RPi-Jukebox-RFID/shared/audiofolders

RUN usermod -aG audio,pulse,pulse-access root
ARG UID
ARG USER
ARG HOME

VOLUME ${HOME}/.config/mpd
RUN useradd -m -u ${UID} ${USER} || continue
RUN usermod -aG pulse ${USER}

EXPOSE 6600
USER ${USER}
RUN mkdir -p ${HOME}/.config/mpd ; \
touch ${HOME}/.config/mpd/state

CMD [ ! -s ~/.config/mpd/pid ] && mpd --stdout --no-daemon ${HOME}/.config/mpd/mpd.conf
CMD mpd --stdout --no-daemon ${HOME}/.config/mpd/mpd.conf
3 changes: 1 addition & 2 deletions src/jukebox/components/playern/core/player_content.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import logging
import os.path

import yaml

Expand All @@ -14,7 +13,7 @@ class PlayerData:

def __init__(self):
self.audiofile = cfg.setndefault('players', 'content', 'audiofile', value='../../shared/audiofolders/audiofiles.yaml')
self._database = {'music': [{}],
self._database = {'file': [{}],
'podcasts': [{}],
'livestreams': [{}]}
self._fill_database(self.audiofile)
Expand Down

0 comments on commit d0e851f

Please sign in to comment.