forked from music-assistant/server
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile.base
More file actions
333 lines (304 loc) · 12.3 KB
/
Copy pathDockerfile.base
File metadata and controls
333 lines (304 loc) · 12.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
# syntax=docker/dockerfile:1
# Python version is centralized in .python-version at repo root.
# Workflows read that file and pass it here via --build-arg PYTHON_VERSION=...
# The default below is a safety net for manual `docker build` without --build-arg.
ARG PYTHON_VERSION=3.14
# BASE docker image for music assistant container
# This image forms the base for the final image and is not meant to be used directly
# NOTE that the dev add-on is also based on this base image
FROM python:${PYTHON_VERSION}-slim-trixie AS ffmpeg-builder
# Enable non-free and contrib repositories for FDK-AAC and other codecs
# (trixie uses the deb822 sources format)
RUN sed -i 's/^Components: .*/Components: main contrib non-free non-free-firmware/' /etc/apt/sources.list.d/debian.sources
# Install build dependencies for FFmpeg
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
pkg-config \
yasm \
nasm \
git \
wget \
ca-certificates \
# Audio codec libraries
libfdk-aac-dev \
libmp3lame-dev \
libopus-dev \
libvorbis-dev \
libsoxr-dev \
libspeex-dev \
libtwolame-dev \
libvo-amrwbenc-dev \
libopencore-amrnb-dev \
libopencore-amrwb-dev \
libshine-dev \
# Audio processing and filters
librubberband-dev \
libbs2b-dev \
libsamplerate0-dev \
libmysofa-dev \
libjack-jackd2-dev \
libpulse-dev \
# Additional libraries
libbluray-dev \
libxml2-dev \
libssh-dev \
liblzma-dev \
# SSL/TLS support for HTTPS
libssl-dev \
&& rm -rf /var/lib/apt/lists/*
# Build FFmpeg 7.1.2 from source with comprehensive audio codec support
ARG FFMPEG_VERSION=7.1.2
RUN set -x \
&& wget -q "https://ffmpeg.org/releases/ffmpeg-${FFMPEG_VERSION}.tar.xz" -O /tmp/ffmpeg.tar.xz \
&& tar -xJf /tmp/ffmpeg.tar.xz -C /tmp \
&& cd /tmp/ffmpeg-${FFMPEG_VERSION} \
&& ./configure \
--prefix=/usr/local \
--enable-gpl \
--enable-nonfree \
--enable-version3 \
# Audio codecs (comprehensive support)
--enable-libfdk-aac \
--enable-libmp3lame \
--enable-libopus \
--enable-libvorbis \
--enable-libspeex \
--enable-libtwolame \
--enable-libshine \
--enable-libopencore-amrnb \
--enable-libopencore-amrwb \
--enable-libvo-amrwbenc \
# Audio filters and resampling
--enable-libsoxr \
--enable-librubberband \
--enable-libbs2b \
--enable-libmysofa \
--enable-libjack \
--enable-libpulse \
# SSL/TLS support for HTTPS
--enable-openssl \
# Additional libraries for playlist and network support
--enable-libxml2 \
--enable-libssh \
--enable-lzma \
# Optimizations
--enable-runtime-cpudetect \
# Disable unnecessary features for smaller build
--disable-doc \
--disable-htmlpages \
--disable-manpages \
--disable-podpages \
--disable-txtpages \
--disable-debug \
--disable-static \
--enable-shared \
&& make -j$(nproc) \
&& make install \
&& strip /usr/local/bin/ffmpeg /usr/local/bin/ffprobe \
&& rm -rf /tmp/ffmpeg*
##################################################################################################
# PyAV wheel builder - builds PyAV against the custom FFmpeg
FROM python:${PYTHON_VERSION}-slim-trixie AS pyav-builder
RUN apt-get update && apt-get install -y --no-install-recommends \
gcc g++ python3-dev pkg-config && rm -rf /var/lib/apt/lists/*
COPY --from=ffmpeg-builder /usr/local/lib/libav*.so* /usr/local/lib/
COPY --from=ffmpeg-builder /usr/local/lib/libsw*.so* /usr/local/lib/
COPY --from=ffmpeg-builder /usr/local/lib/libpostproc.so* /usr/local/lib/
COPY --from=ffmpeg-builder /usr/local/include/ /usr/local/include/
COPY --from=ffmpeg-builder /usr/local/lib/pkgconfig/ /usr/local/lib/pkgconfig/
RUN ldconfig
ENV PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
# Build PyAV wheel against the custom FFmpeg with the in the Sendspin provider manifest pinned version
COPY music_assistant/providers/sendspin/manifest.json /tmp/sendspin_manifest.json
RUN PYAV_VERSION=$(python -c "import json; reqs=json.load(open('/tmp/sendspin_manifest.json'))['requirements']; print(next(r.split('==')[1] for r in reqs if r.startswith('av==')))") && \
echo "Building PyAV version: ${PYAV_VERSION}" && \
pip wheel --no-binary av av==${PYAV_VERSION} -w /wheels/
##################################################################################################
# Build shairport-sync (airplay receiver provider) from source against this image's
# libraries, using the same configuration as music_assistant/providers/airplay_receiver/bin/build_binaries.sh:
# tinysvcmdns as embedded mDNS backend (no avahi), stdout/pipe outputs and metadata support.
FROM python:${PYTHON_VERSION}-slim-trixie AS shairport-builder
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
git \
autoconf \
automake \
libtool \
pkg-config \
libconfig-dev \
libpopt-dev \
libssl-dev \
libdbus-1-dev \
libglib2.0-dev \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Version and its commit SHA are the single source of truth (also read by
# build_binaries.sh). Tags are mutable, so the fetched tag is verified against the
# pinned SHA. Bump both when changing the version.
ARG SHAIRPORT_VERSION=4.3.7
ARG SHAIRPORT_SHA=0b1c4391ffd398e7b145eb4b98416261380adeea
RUN set -x \
&& git init /tmp/shairport-sync \
&& cd /tmp/shairport-sync \
&& git remote add origin https://github.com/mikebrady/shairport-sync.git \
&& git fetch --depth 1 origin refs/tags/${SHAIRPORT_VERSION} \
&& git checkout FETCH_HEAD \
&& test "$(git rev-parse HEAD)" = "${SHAIRPORT_SHA}" \
&& autoreconf -fi \
&& ./configure \
--with-pipe \
--with-metadata \
--without-avahi \
--without-dns-sd \
--with-tinysvcmdns \
--with-ssl=openssl \
--with-stdout \
--sysconfdir=/etc \
&& make -j$(nproc) \
&& strip shairport-sync \
&& cp shairport-sync /usr/local/bin/shairport-sync \
&& rm -rf /tmp/shairport-sync
##################################################################################################
FROM python:${PYTHON_VERSION}-slim-trixie
# Enable non-free and contrib repositories for codec libraries
# (trixie uses the deb822 sources format)
RUN sed -i 's/^Components: .*/Components: main contrib non-free non-free-firmware/' /etc/apt/sources.list.d/debian.sources
# Install runtime dependencies
RUN set -x \
&& apt-get update \
&& apt-get install -y --no-install-recommends \
ca-certificates \
libjemalloc2 \
tzdata \
wget \
# cifs utils and libnfs are needed for smb and nfs support (file provider)
cifs-utils \
libnfs14 \
nfs-common \
# airplay libraries
openssl \
libssl-dev \
libuuid1 \
libcurl4 \
libsodium23 \
libconfuse2 \
libevent-dev \
libjson-c5 \
libgcrypt20 \
# glib is needed by the shairport-sync binary (previously pulled in only
# indirectly via the pipewire/pulseaudio utils)
libglib2.0-0 \
# libsndfile needed for librosa audio file support (smartfades)
libsndfile1 \
# libchromaprint needed for AcoustID fingerprinting (acoustid_lookup)
libchromaprint1 \
# Audio codec runtime libraries (needed for FFmpeg)
libfdk-aac2 \
libmp3lame0 \
libopus0 \
libvorbis0a \
libvorbisenc2 \
libsoxr0 \
libspeex1 \
libtwolame0 \
libshine3 \
libopencore-amrnb0 \
libopencore-amrwb0 \
libvo-amrwbenc0 \
# Audio processing libraries
librubberband2 \
libbs2b0 \
libsamplerate0 \
libmysofa1 \
libjack-jackd2-0 \
libpulse0 \
# Additional libraries
libbluray2 \
libxml2 \
libssh-4 \
liblzma5 \
# Snapcast dependencies
libasound2 \
# PortAudio for local audio output (sounddevice)
libportaudio2 \
# Allows pipewire devices to be detected when running in docker container. (local audio)
pipewire-alsa \
# Allows pulse audio devices to be detected using pactl. (local audio)
pulseaudio-utils \
libvorbisidec1 \
libflac14 \
libavahi-client3 \
libavahi-common3 \
# AirPlay receiver dependencies (shairport-sync)
libconfig11 \
libpopt0 \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
&& rm -f \
/usr/bin/parecord \
/usr/bin/paplay \
/usr/bin/parec \
/usr/bin/pamon \
/usr/bin/pacat \
/usr/bin/pasuspender \
/usr/bin/pacmd
# Install Snapcast 0.34.0 from GitHub releases (requires at least 0.27)
ARG SNAPCAST_VERSION=0.34.0
ARG TARGETARCH
RUN set -x \
&& if [ "$TARGETARCH" = "arm64" ]; then \
SNAPCAST_ARCH="arm64"; \
else \
SNAPCAST_ARCH="amd64"; \
fi \
&& wget -q "https://github.com/badaix/snapcast/releases/download/v${SNAPCAST_VERSION}/snapserver_${SNAPCAST_VERSION}-1_${SNAPCAST_ARCH}_trixie.deb" -O /tmp/snapserver.deb \
&& wget -q "https://github.com/badaix/snapcast/releases/download/v${SNAPCAST_VERSION}/snapclient_${SNAPCAST_VERSION}-1_${SNAPCAST_ARCH}_trixie.deb" -O /tmp/snapclient.deb \
# install via apt so any missing dependencies of the debs are resolved as well
&& apt-get update \
&& apt-get install -y --no-install-recommends /tmp/snapserver.deb /tmp/snapclient.deb \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
&& rm /tmp/snapserver.deb /tmp/snapclient.deb
# Install go-librespot (used by the Spotify Connect provider) from GitHub releases.
# The release binaries statically link libvorbis/libogg/libFLAC, so the only dynamic
# dependency is libasound2 (already installed above for Snapcast).
# The pinned SHA256 per arch is verified before extraction; bump both when changing the version.
ARG GO_LIBRESPOT_VERSION=0.7.4
RUN set -x \
&& if [ "$TARGETARCH" = "arm64" ]; then \
GO_LIBRESPOT_ARCH="arm64"; \
GO_LIBRESPOT_SHA256="62b6c7ebee6abb1f59fa3cf20a9374dd5e8c5c1ca5dab329dd312f66b59faa8d"; \
else \
GO_LIBRESPOT_ARCH="x86_64"; \
GO_LIBRESPOT_SHA256="ee521eed02100ee4aa9919a147304aed5afc908c5a0c99f515c3da0aed89acf7"; \
fi \
&& wget -q "https://github.com/devgianlu/go-librespot/releases/download/v${GO_LIBRESPOT_VERSION}/go-librespot_linux_${GO_LIBRESPOT_ARCH}.tar.gz" -O /tmp/go-librespot.tar.gz \
&& echo "${GO_LIBRESPOT_SHA256} /tmp/go-librespot.tar.gz" | sha256sum -c - \
&& tar -xzf /tmp/go-librespot.tar.gz -C /usr/local/bin go-librespot \
&& chmod +x /usr/local/bin/go-librespot \
&& rm /tmp/go-librespot.tar.gz
# Copy FFmpeg binaries and libraries from builder stage
COPY --from=ffmpeg-builder /usr/local/bin/ffmpeg /usr/local/bin/
COPY --from=ffmpeg-builder /usr/local/bin/ffprobe /usr/local/bin/
COPY --from=ffmpeg-builder /usr/local/lib/libav*.so* /usr/local/lib/
COPY --from=ffmpeg-builder /usr/local/lib/libsw*.so* /usr/local/lib/
COPY --from=ffmpeg-builder /usr/local/lib/libpostproc.so* /usr/local/lib/
# Copy shairport-sync binary from builder stage (found by the airplay receiver
# provider via its system PATH lookup)
COPY --from=shairport-builder /usr/local/bin/shairport-sync /usr/local/bin/
# Copy pre-built PyAV wheel for use by downstream images
COPY --from=pyav-builder /wheels/ /usr/local/share/pyav-wheels/
# Update shared library cache and verify FFmpeg
RUN ldconfig && ffmpeg -version && ffprobe -version
# Copy widevine client files to container
RUN mkdir -p /usr/local/bin/widevine_cdm
COPY widevine_cdm/* /usr/local/bin/widevine_cdm/
# we need to set (very permissive) permissions to the workdir
# and /tmp to allow running the container as non-root
RUN chmod -R 777 /tmp
LABEL \
org.opencontainers.image.title="Music Assistant Base Image" \
org.opencontainers.image.description="Base Image for Music Assistant server - not to be used directly" \
org.opencontainers.image.source="https://github.com/music-assistant/server" \
org.opencontainers.image.authors="The Music Assistant Team" \
org.opencontainers.image.licenses="Apache License 2.0"