|
1 | | -FROM debian:buster |
| 1 | +# --- Build Node --- |
| 2 | +FROM rust:slim-bullseye AS Builder |
| 3 | +LABEL org.opencontainers.image.authors="https://github.com/seppi91" |
| 4 | +ARG TARGETPLATFORM |
| 5 | +ARG TARGETARCH |
| 6 | +ARG TARGETVARIANT |
| 7 | + |
| 8 | +# Print Info about current build Target |
| 9 | +RUN printf "I'm building for TARGETPLATFORM=${TARGETPLATFORM}" \ |
| 10 | + && printf ", TARGETARCH=${TARGETARCH}" \ |
| 11 | + && printf ", TARGETVARIANT=${TARGETVARIANT} \n" \ |
| 12 | + && printf "With uname -s : " && uname -s \ |
| 13 | + && printf "and uname -m : " && uname -mm |
| 14 | + |
| 15 | +# Switch to the root user while we do our changes |
| 16 | +USER root |
| 17 | + |
| 18 | +# Install all libraries and needs |
| 19 | +RUN apt update \ |
| 20 | + && apt install -yq --no-install-recommends \ |
| 21 | + git \ |
| 22 | + patch \ |
| 23 | + libgstreamer-plugins-base1.0-dev \ |
| 24 | + libgstreamer1.0-dev \ |
| 25 | + libcsound64-dev \ |
| 26 | + libclang-11-dev \ |
| 27 | + libpango1.0-dev \ |
| 28 | + libdav1d-dev \ |
| 29 | + # libgtk-4-dev \ Only in bookworm |
| 30 | + && rm -rf /var/lib/apt/lists/* |
| 31 | + |
| 32 | +WORKDIR /usr/src/gst-plugins-rs |
| 33 | + |
| 34 | +# Clone source of gst-plugins-rs to workdir |
| 35 | +ARG GST_PLUGINS_RS_TAG=main |
| 36 | +RUN git clone -c advice.detachedHead=false \ |
| 37 | + --single-branch --depth 1 \ |
| 38 | + --branch ${GST_PLUGINS_RS_TAG} \ |
| 39 | + https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git ./ |
| 40 | +# EXPERIMENTAL: For gstreamer-spotify set upgraded version number of dependency librespot to 0.4.2 |
| 41 | +RUN sed -i 's/librespot = { version = "0.4", default-features = false }/librespot = { version = "0.4.2", default-features = false }/g' audio/spotify/Cargo.toml |
| 42 | + |
| 43 | +# Build GStreamer plugins written in Rust (optional with --no-default-features) |
| 44 | +ENV DEST_DIR /target/gst-plugins-rs |
| 45 | +ENV CARGO_PROFILE_RELEASE_DEBUG false |
| 46 | +RUN export CSOUND_LIB_DIR="/usr/lib/$(uname -m)-linux-gnu" \ |
| 47 | + && export PLUGINS_DIR=$(pkg-config --variable=pluginsdir gstreamer-1.0) \ |
| 48 | + && export SO_SUFFIX=so \ |
| 49 | + && cargo build --release --no-default-features \ |
| 50 | + # List of packages to build |
| 51 | + --package gst-plugin-spotify \ |
| 52 | + # Use install command to create directory (-d), copy and print filenames (-v), and set attributes/permissions (-m) |
| 53 | + && install -v -d ${DEST_DIR}/${PLUGINS_DIR} \ |
| 54 | + && install -v -m 755 target/release/*.${SO_SUFFIX} ${DEST_DIR}/${PLUGINS_DIR} |
| 55 | + |
| 56 | + |
| 57 | +# --- Release Node --- |
| 58 | +FROM debian:bullseye-slim as Release |
2 | 59 |
|
3 | 60 | # Switch to the root user while we do our changes |
4 | 61 | USER root |
| 62 | +WORKDIR / |
5 | 63 |
|
6 | 64 | # Install GStreamer and other required Debian packages |
7 | 65 | RUN apt-get update \ |
8 | | - && apt-get install -y --no-install-recommends \ |
| 66 | + && apt-get install -y --no-install-recommends \ |
| 67 | + sudo \ |
| 68 | + build-essential \ |
| 69 | + curl \ |
| 70 | + git \ |
9 | 71 | wget \ |
10 | 72 | gnupg2 \ |
11 | | - git \ |
12 | | - python3-setuptools \ |
13 | | - python3-pip \ |
14 | 73 | dumb-init \ |
15 | 74 | graphviz-dev \ |
16 | | - gstreamer1.0-plugins-bad \ |
17 | | - gstreamer1.0-plugins-good \ |
18 | | - gstreamer1.0-plugins-ugly \ |
19 | | - gstreamer1.0-pulseaudio \ |
| 75 | + pulseaudio \ |
20 | 76 | libasound2-dev \ |
21 | | - python3-dev \ |
22 | | - python3-gst-1.0 \ |
23 | | - build-essential \ |
24 | 77 | libdbus-glib-1-dev \ |
25 | 78 | libgirepository1.0-dev \ |
26 | | - dleyna-server \ |
27 | | - sudo \ |
28 | | - && rm -rf /var/lib/apt/lists/* |
| 79 | + # Install Python |
| 80 | + python3-dev \ |
| 81 | + python3-gst-1.0 \ |
| 82 | + python3-setuptools \ |
| 83 | + python3-pip \ |
| 84 | + # GStreamer (Plugins) |
| 85 | + gstreamer1.0-plugins-good \ |
| 86 | + gstreamer1.0-plugins-bad \ |
| 87 | + gstreamer1.0-plugins-ugly \ |
| 88 | + gstreamer1.0-libav \ |
| 89 | + gstreamer1.0-pulseaudio \ |
| 90 | + && rm -rf /var/lib/apt/lists/* |
| 91 | + |
| 92 | +# Copy builded target data from Builder DEST_DIR to root |
| 93 | +# Note: target directory tree links directly to $GST_PLUGIN_PATH |
| 94 | +COPY --from=Builder /target/gst-plugins-rs/ / |
| 95 | + |
| 96 | +# Install Node, to build Iris JS application |
| 97 | +RUN curl -fsSL https://deb.nodesource.com/setup_14.x | bash - && \ |
| 98 | + apt-get install -y nodejs |
29 | 99 |
|
30 | | -# Install libspotify-dev from apt.mopidy.com |
| 100 | +# Install mopidy and (optional) DLNA-server dleyna from apt.mopidy.com |
| 101 | +# see https://docs.mopidy.com/en/latest/installation/debian/ |
31 | 102 | RUN mkdir -p /usr/local/share/keyrings \ |
32 | | - && wget -q -O /usr/local/share/keyrings/mopidy-archive-keyring.gpg https://apt.mopidy.com/mopidy.gpg \ |
33 | | - && wget -q -O /etc/apt/sources.list.d/mopidy.list https://apt.mopidy.com/buster.list \ |
34 | | - && apt-get update \ |
35 | | - && apt-get install -y libspotify-dev mopidy-spotify \ |
36 | | - && rm -rf /var/lib/apt/lists/* |
| 103 | + && wget -q -O /usr/local/share/keyrings/mopidy-archive-keyring.gpg https://apt.mopidy.com/mopidy.gpg \ |
| 104 | + && wget -q -O /etc/apt/sources.list.d/mopidy.list https://apt.mopidy.com/buster.list \ |
| 105 | + && apt-get update \ |
| 106 | + && apt-get install -y \ |
| 107 | + mopidy \ |
| 108 | + && rm -rf /var/lib/apt/lists/* |
| 109 | + |
| 110 | +# Upgrade Python package manager pip |
| 111 | +# https://pypi.org/project/pip/ |
| 112 | +RUN python3 -m pip install --upgrade pip |
37 | 113 |
|
38 | 114 | # Clone Iris from the repository and install in development mode. |
39 | 115 | # This allows a binding at "/iris" to map to your local folder for development, rather than |
40 | 116 | # installing using pip. |
41 | | -# Note using ADD helps prevent caching issues. When HEAD changes, our cache is invalidated, whee! |
| 117 | +# Note: ADD helps prevent RUN caching issues. When HEAD changes in repo, our cache will be invalidated! |
42 | 118 | ADD https://api.github.com/repos/jaedb/Iris/git/refs/heads/master version.json |
43 | | -RUN git clone --depth 1 -b master https://github.com/jaedb/Iris.git /iris \ |
| 119 | +ENV IRIS_VERSION=develop |
| 120 | +RUN git clone --depth 1 --single-branch -b ${IRIS_VERSION} https://github.com/jaedb/Iris.git /iris \ |
44 | 121 | && cd /iris \ |
| 122 | + && npm install \ |
| 123 | + && npm run prod \ |
45 | 124 | && python3 setup.py develop \ |
46 | 125 | && mkdir -p /var/lib/mopidy/.config \ |
47 | 126 | && ln -s /config /var/lib/mopidy/.config/mopidy \ |
48 | 127 | # Allow mopidy user to run system commands (restart, local scan, etc) |
49 | | - && echo "mopidy ALL=NOPASSWD: /iris/mopidy_iris/system.sh" >> /etc/sudoers |
| 128 | + && echo "mopidy ALL=NOPASSWD: /iris/mopidy_iris/system.sh" >> /etc/sudoers \ |
| 129 | + # Enable container mode (disable restart option, etc.) |
| 130 | + && echo "1" >> /IS_CONTAINER \ |
| 131 | + # Copy Version file |
| 132 | + && cp /iris/VERSION / |
| 133 | + |
| 134 | +# Install mopidy-spotify-gstspotify (Hack, not released yet!) |
| 135 | +# (https://github.com/kingosticks/mopidy-spotify/tree/gstspotifysrc-hack) |
| 136 | +RUN git clone --depth 1 -b gstspotifysrc-hack https://github.com/kingosticks/mopidy-spotify.git mopidy-spotify \ |
| 137 | + && cd mopidy-spotify \ |
| 138 | + && python3 setup.py install \ |
| 139 | + && cd .. \ |
| 140 | + && rm -rf mopidy-spotify |
50 | 141 |
|
51 | | -# Install additional Python dependencies |
52 | | -RUN python3 -m pip install --no-cache \ |
53 | | - tox \ |
54 | | - mopidy-mpd \ |
55 | | - mopidy-local |
| 142 | +# Install additional mopidy extensions and Python dependencies via pip |
| 143 | +COPY docker/requirements.txt . |
| 144 | +RUN python3 -m pip install -r requirements.txt |
| 145 | + |
| 146 | +# Cleanup |
| 147 | +RUN apt-get clean all \ |
| 148 | + && rm -rf /var/lib/apt/lists/* \ |
| 149 | + && rm -rf /root/.cache \ |
| 150 | + && rm -rf /iris/node_modules |
56 | 151 |
|
57 | 152 | # Start helper script. |
58 | 153 | COPY docker/entrypoint.sh /entrypoint.sh |
59 | 154 |
|
60 | | -# Default configuration. |
| 155 | +# Copy Default configuration for mopidy |
61 | 156 | COPY docker/mopidy/mopidy.example.conf /config/mopidy.conf |
62 | 157 |
|
63 | | -# Copy the pulse-client configuratrion. |
| 158 | +# Copy the pulse-client configuratrion |
64 | 159 | COPY docker/mopidy/pulse-client.conf /etc/pulse/client.conf |
65 | 160 |
|
66 | | -# Add version info to image |
67 | | -COPY VERSION / |
68 | | - |
69 | 161 | # Allows any user to run mopidy, but runs by default as a randomly generated UID/GID. |
70 | 162 | # RUN useradd -ms /bin/bash mopidy |
71 | 163 | ENV HOME=/var/lib/mopidy |
72 | 164 | RUN set -ex \ |
73 | | - && usermod -G audio,sudo mopidy \ |
| 165 | + && usermod -G audio,sudo,pulse-access mopidy \ |
74 | 166 | && mkdir /var/lib/mopidy/local \ |
75 | 167 | && chown mopidy:audio -R $HOME /entrypoint.sh /iris \ |
76 | | - && chmod go+rwx -R $HOME /entrypoint.sh /iris \ |
77 | | - && echo "1" >> /IS_CONTAINER |
| 168 | + && chmod go+rwx -R $HOME /entrypoint.sh /iris |
78 | 169 |
|
79 | 170 | # Runs as mopidy user by default. |
80 | 171 | USER mopidy:audio |
|
0 commit comments