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.
6 changes: 3 additions & 3 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ services:
- USER=root
- HOME=/root
context: ../
dockerfile: ./docker/mpd.Dockerfile
dockerfile: ./docker/Dockerfile.mpd
container_name: mpd
image: phoniebox/mpd
environment:
Expand All @@ -26,7 +26,7 @@ services:
- USER=root
- HOME=/root
context: ../
dockerfile: ./docker/jukebox.Dockerfile
dockerfile: ./docker/Dockerfile.jukebox
container_name: jukebox
image: phoniebox/jukebox
depends_on:
Expand All @@ -49,7 +49,7 @@ services:
webapp:
build:
context: ../
dockerfile: ./docker/webapp.Dockerfile
dockerfile: ./docker/Dockerfile.webapp
container_name: webapp
image: phoniebox/webapp
depends_on:
Expand Down
Loading
Loading