Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Build libzmq locally to work on all host types #2307

Merged
merged 11 commits into from
Apr 6, 2024
25 changes: 9 additions & 16 deletions docker/jukebox.Dockerfile → docker/Dockerfile.jukebox
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
FROM libzmq:local as libzmq
FROM debian:bullseye-slim

# These are only dependencies that are required to get as close to the
Expand All @@ -6,8 +7,7 @@ RUN apt-get update && apt-get install -y \
libasound2-dev \
pulseaudio \
pulseaudio-utils \
--no-install-recommends \
&& rm -rf /var/lib/apt/lists/*
--no-install-recommends

ARG UID
ARG USER
Expand All @@ -21,7 +21,7 @@ RUN usermod -aG pulse ${USER}
# Install all Jukebox dependencies
RUN apt-get update && apt-get install -qq -y \
--allow-downgrades --allow-remove-essential --allow-change-held-packages \
g++ at wget \
build-essential at wget \
espeak mpc mpg123 git ffmpeg spi-tools netcat \
python3 python3-venv python3-dev python3-mutagen

Expand All @@ -37,21 +37,14 @@ ENV VIRTUAL_ENV=${INSTALLATION_PATH}/.venv
RUN python3 -m venv $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"


# Install all Python dependencies
RUN pip install --no-cache-dir -r ${INSTALLATION_PATH}/requirements.txt

ENV ZMQ_TMP_DIR libzmq
ENV ZMQ_VERSION 4.3.5
ENV ZMQ_PREFIX /usr/local

RUN [ "$(uname -m)" = "aarch64" ] && ARCH="arm64" || ARCH="$(uname -m)"; \
wget https://github.com/pabera/libzmq/releases/download/v${ZMQ_VERSION}/libzmq5-${ARCH}-${ZMQ_VERSION}.tar.gz -O libzmq.tar.gz; \
tar -xzf libzmq.tar.gz -C ${ZMQ_PREFIX}; \
rm -f libzmq.tar.gz;

RUN export ZMQ_PREFIX=${PREFIX} && export ZMQ_DRAFT_API=1
RUN pip install -v --no-binary pyzmq pyzmq
# Install pyzmq Python dependency separately
ENV ZMQ_PREFIX /opt/libzmq
ENV ZMQ_DRAFT_API 1
COPY --from=libzmq ${ZMQ_PREFIX} ${ZMQ_PREFIX}
RUN pip install -v pyzmq --no-binary pyzmq

EXPOSE 5555 5556

WORKDIR ${INSTALLATION_PATH}/src/jukebox
25 changes: 25 additions & 0 deletions docker/Dockerfile.libzmq
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
FROM debian:bullseye-slim

# Install necessary build dependencies
RUN apt-get update && apt-get install -y \
build-essential wget tar

# Define environment variables for libzmq
ENV ZMQ_VERSION 4.3.5
ENV ZMQ_PREFIX /opt/libzmq

# Download, compile, and install libzmq
RUN mkdir -p ${ZMQ_PREFIX}; \
wget https://github.com/zeromq/libzmq/releases/download/v${ZMQ_VERSION}/zeromq-${ZMQ_VERSION}.tar.gz -O libzmq.tar.gz; \
tar -xzf libzmq.tar.gz; \
cd zeromq-${ZMQ_VERSION}; \
./configure --prefix=${ZMQ_PREFIX} --enable-drafts; \
make -j$(nproc) && make install

# Cleanup unnecessary files
RUN rm -rf /zeromq-${ZMQ_VERSION} libzmq.tar.gz
pabera marked this conversation as resolved.
Show resolved Hide resolved

# Create final image with only the libzmq build fragments
FROM scratch
ENV ZMQ_PREFIX /opt/libzmq
COPY --from=0 ${ZMQ_PREFIX} ${ZMQ_PREFIX}
File renamed without changes.
File renamed without changes.
25 changes: 14 additions & 11 deletions docker/config/docker.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 Expand Up @@ -225,6 +225,10 @@ decoder {
# gapless "no"
}

decoder {
plugin "wildmidi"
enabled "no"
}
#
###############################################################################

Expand All @@ -239,12 +243,11 @@ decoder {
#
audio_output {
type "alsa"
name "My ALSA Device"
# device "pulse" # optional
mixer_type "software" # optional
# mixer_device "default" # optional
# mixer_control "Master" # optional
# mixer_index "0" # optional
name "Global ALSA->Pulse stream"
# mixer_type "hardware"
mixer_control "Master"
mixer_device "pulse"
device "pulse"
}
#
# An example of an OSS output:
Expand Down Expand Up @@ -311,9 +314,9 @@ audio_output {
# Please see README.Debian if you want mpd to play through the pulseaudio
# daemon started as part of your graphical desktop session!
#
# audio_output {
# type "pulse"
# name "My Pulse Output"
#audio_output {
# type "pulse"
# name "My Pulse Output"
# server "remote_server" # optional
# sink "remote_server_sink" # optional
# }
Expand Down
Loading
Loading