diff --git a/Dockerfile b/Dockerfile old mode 100755 new mode 100644 index 983170fb..89930082 --- a/Dockerfile +++ b/Dockerfile @@ -1,46 +1,109 @@ -FROM debian:buster +FROM rust:slim-bullseye +LABEL org.opencontainers.image.authors="https://github.com/seppi91" +ARG TARGETPLATFORM +ARG TARGETARCH +ARG TARGETVARIANT +RUN printf "I'm building for TARGETPLATFORM=${TARGETPLATFORM}" \ + && printf ", TARGETARCH=${TARGETARCH}" \ + && printf ", TARGETVARIANT=${TARGETVARIANT} \n" \ + && printf "With uname -s : " && uname -s \ + && printf "and uname -m : " && uname -mm # Switch to the root user while we do our changes USER root -# Install GStreamer and other required Debian packages +# Install all libraries and needs RUN apt-get update \ - && apt-get install -y --no-install-recommends \ + && apt-get install -y --no-install-recommends \ + sudo \ + build-essential \ + curl \ + git \ wget \ gnupg2 \ - git \ - python3-setuptools \ - python3-pip \ + tar \ dumb-init \ graphviz-dev \ - gstreamer1.0-plugins-bad \ - gstreamer1.0-plugins-good \ - gstreamer1.0-plugins-ugly \ - gstreamer1.0-pulseaudio \ + pulseaudio \ libasound2-dev \ - python3-dev \ - python3-gst-1.0 \ - build-essential \ libdbus-glib-1-dev \ libgirepository1.0-dev \ + # DLNA Server dleyna-server \ - sudo \ - && rm -rf /var/lib/apt/lists/* + # Install Python + python3-dev \ + python3-gst-1.0 \ + python3-setuptools \ + python3-pip \ + python3-venv \ + # GStreamer (Plugins) + libgstreamer1.0-dev \ + libgstreamer-plugins-base1.0-dev \ + libgstreamer-plugins-bad1.0-dev \ + libgstrtspserver-1.0-dev \ + gstreamer1.0-plugins-base \ + gstreamer1.0-plugins-good \ + gstreamer1.0-plugins-bad \ + gstreamer1.0-plugins-ugly \ + gstreamer1.0-libav \ + #gstreamer1.0-alsa \ + gstreamer1.0-pulseaudio \ + # GStreamer build dependencies see + # https://github.com/Kynothon/gst-plugins-rs-docker/blob/master/XDockerfile + llvm-dev \ + libclang-dev \ + clang \ + gcc \ + libssl-dev \ + libcsound64-dev \ + libpango1.0-dev \ + libdav1d-dev \ + libwebp-dev + # libgtk-4-dev # Only in bookworm -# Install libspotify-dev from apt.mopidy.com +# Install gstreamer-spotify (EXPERIMENTAL) +# Note: For spotify with upgraded version number of dependency librespot to 0.4.2 +#RUN cargo install cargo-c +WORKDIR /build +RUN git clone --depth 1 --single-branch -b main https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git +WORKDIR /build/gst-plugins-rs +RUN sed -i 's/librespot = { version = "0.4", default-features = false }/librespot = { version = "0.4.2", default-features = false }/g' audio/spotify/Cargo.toml +RUN MULTIARCHTUPLE=$(dpkg-architecture -qDEB_HOST_MULTIARCH) \ + #&& cargo cbuild --no-default-features -p gst-plugin-spotify --prefix=/usr --libdir=/usr/lib/$MULTIARCHTUPLE/ -r \ + #&& cargo cinstall -p gst-plugin-spotify --prefix=/usr --libdir=/usr/lib/$MULTIARCHTUPLE/ + && cargo build --no-default-features -p gst-plugin-spotify -r \ + && cp ./target/release/libgstspotify.so /usr/lib/$MULTIARCHTUPLE/gstreamer-1.0/ + #&& ln -s /usr/lib/$MULTIARCHTUPLE/gstreamer-1.0/libgstspotify.so /usr/lib64/$MULTIARCHTUPLE/gstreamer-1.0/libgstspotify.so || true \ +WORKDIR /build +RUN rm -rf gst-plugins-rs +WORKDIR / + +# Install mopidy from apt.mopidy.com +# see https://docs.mopidy.com/en/latest/installation/debian/ RUN mkdir -p /usr/local/share/keyrings \ - && wget -q -O /usr/local/share/keyrings/mopidy-archive-keyring.gpg https://apt.mopidy.com/mopidy.gpg \ - && wget -q -O /etc/apt/sources.list.d/mopidy.list https://apt.mopidy.com/buster.list \ - && apt-get update \ - && apt-get install -y libspotify-dev mopidy-spotify \ - && rm -rf /var/lib/apt/lists/* + && wget -q -O /usr/local/share/keyrings/mopidy-archive-keyring.gpg https://apt.mopidy.com/mopidy.gpg \ + && wget -q -O /etc/apt/sources.list.d/mopidy.list https://apt.mopidy.com/buster.list \ + && apt-get update \ + && apt-get install -y mopidy \ + && rm -rf /var/lib/apt/lists/* -# Clone Iris from the repository and install in development mode. -# This allows a binding at "/iris" to map to your local folder for development, rather than -# installing using pip. -# Note using ADD helps prevent caching issues. When HEAD changes, our cache is invalidated, whee! +# Upgrade Python package manager pip +# https://pypi.org/project/pip/ +RUN python3 -m pip install --upgrade pip + +# Install PyGObject +# https://pypi.org/project/PyGObject/ +RUN python3 -m pip install pygobject + +# Install cffi from source +# Note: In some distributions libffi-devel is too old, hardcoded stuff +# https://pypi.org/project/cffi/ +RUN python3 -m pip install cffi + +# Install Iris +# Note: ADD helps prevent RUN caching issues. When HEAD changes in repo, our cache will be invalidated! ADD https://api.github.com/repos/jaedb/Iris/git/refs/heads/master version.json -RUN git clone --depth 1 -b master https://github.com/jaedb/Iris.git /iris \ +RUN git clone --depth 1 --single-branch -b master https://github.com/jaedb/Iris.git /iris \ && cd /iris \ && python3 setup.py develop \ && mkdir -p /var/lib/mopidy/.config \ @@ -48,33 +111,37 @@ RUN git clone --depth 1 -b master https://github.com/jaedb/Iris.git /iris \ # Allow mopidy user to run system commands (restart, local scan, etc) && echo "mopidy ALL=NOPASSWD: /iris/mopidy_iris/system.sh" >> /etc/sudoers -# Install additional Python dependencies -RUN python3 -m pip install --no-cache \ - tox \ - mopidy-mpd \ - mopidy-local - -# Start helper script. -COPY docker/entrypoint.sh /entrypoint.sh - -# Default configuration. -COPY docker/mopidy/mopidy.example.conf /config/mopidy.conf - -# Copy the pulse-client configuratrion. -COPY docker/mopidy/pulse-client.conf /etc/pulse/client.conf - -# Add version info to image COPY VERSION / +COPY mopidy_iris/ /iris/mopidy_iris +COPY docker/mopidy/mopidy.example.conf /config/mopidy.conf +COPY docker/mopidy/pulse-client.conf /etc/pulse/client.conf +RUN echo "1" >> /IS_CONTAINER + +# Install mopidy-spotify-gstspotify (Hack, not released yet!) +# (https://github.com/kingosticks/mopidy-spotify/tree/gstspotifysrc-hack) +RUN git clone --depth 1 -b gstspotifysrc-hack https://github.com/kingosticks/mopidy-spotify.git mopidy-spotify \ + && cd mopidy-spotify \ + && python3 setup.py install \ + && cd .. \ + && rm -rf mopidy-spotify + +# Install additional Python dependencies +COPY docker/requirements.txt . +RUN python3 -m pip install -r requirements.txt + +# Cleanup +RUN apt-get clean all && rm -rf /var/lib/apt/lists/* && rm -rf /root/.cache + +COPY docker/entrypoint.sh /entrypoint.sh # Allows any user to run mopidy, but runs by default as a randomly generated UID/GID. # RUN useradd -ms /bin/bash mopidy ENV HOME=/var/lib/mopidy RUN set -ex \ - && usermod -G audio,sudo mopidy \ + && usermod -G audio,sudo,pulse-access mopidy \ && mkdir /var/lib/mopidy/local \ - && chown mopidy:audio -R $HOME /entrypoint.sh /iris \ - && chmod go+rwx -R $HOME /entrypoint.sh /iris \ - && echo "1" >> /IS_CONTAINER + && chown mopidy:audio -R $HOME /entrypoint.sh \ + && chmod go+rwx -R $HOME /entrypoint.sh # Runs as mopidy user by default. USER mopidy:audio diff --git a/docker-compose.example.yml b/docker-compose.example.yml index 82aaadb3..3d703863 100755 --- a/docker-compose.example.yml +++ b/docker-compose.example.yml @@ -23,6 +23,7 @@ services: - 6600:6600 - 6680:6680 volumes: + # - ./mopidy/iris:/iris/mopidy/iris # To use a locally-built UI - ./docker/mopidy/iris:/var/lib/mopidy/iris # Iris-specific storage - ./docker/mopidy/m3u:/var/lib/mopidy/m3u # To persist local playlists - ./docker/mopidy/mopidy.conf:/config/mopidy.conf diff --git a/docker/requirements.txt b/docker/requirements.txt new file mode 100644 index 00000000..3be2d1a1 --- /dev/null +++ b/docker/requirements.txt @@ -0,0 +1,9 @@ +Mopidy-Local +Mopidy-Mpd +Mopidy-MusicBox-Webclient +Mopidy-Soundcloud +Mopidy-Youtube +Mopidy-YTMusic +ytmusicapi +youtube_dl +tox \ No newline at end of file