forked from music-assistant/server
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDockerfile.base
More file actions
241 lines (219 loc) · 8.48 KB
/
Dockerfile.base
File metadata and controls
241 lines (219 loc) · 8.48 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
# syntax=docker/dockerfile:1
# 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:3.13-slim-bookworm AS ffmpeg-builder
# Enable non-free and contrib repositories for FDK-AAC and other codecs
RUN echo "deb http://deb.debian.org/debian bookworm main contrib non-free non-free-firmware" > /etc/apt/sources.list && \
echo "deb http://deb.debian.org/debian-security bookworm-security main contrib non-free non-free-firmware" >> /etc/apt/sources.list && \
echo "deb http://deb.debian.org/debian bookworm-updates main contrib non-free non-free-firmware" >> /etc/apt/sources.list
# 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:3.13-slim-bookworm 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
# Resolve PyAV version from aiosendspin's dependencies and build wheel
RUN PYAV_VERSION=$(pip install --dry-run aiosendspin 2>&1 | grep -oP 'av-\K[0-9.]+' | head -1) && \
if [ -z "$PYAV_VERSION" ]; then \
echo "ERROR: Failed to detect PyAV version from aiosendspin dependencies" >&2; \
exit 1; \
fi && \
echo "Building PyAV version: ${PYAV_VERSION}" && \
pip wheel --no-binary av av==${PYAV_VERSION} -w /wheels/
##################################################################################################
FROM python:3.13-slim-bookworm
# Enable non-free and contrib repositories for codec libraries
RUN echo "deb http://deb.debian.org/debian bookworm main contrib non-free non-free-firmware" > /etc/apt/sources.list && \
echo "deb http://deb.debian.org/debian-security bookworm-security main contrib non-free non-free-firmware" >> /etc/apt/sources.list && \
echo "deb http://deb.debian.org/debian bookworm-updates main contrib non-free non-free-firmware" >> /etc/apt/sources.list
# 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 \
libnfs13 \
# airplay libraries
openssl \
libssl-dev \
libuuid1 \
libcurl4 \
libsodium23 \
libconfuse2 \
libunistring2 \
libxml2 \
libevent-dev \
libjson-c5 \
libplist3 \
libgcrypt20 \
libavfilter8 \
# libsndfile needed for librosa audio file support (smartfades)
libsndfile1 \
# 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 \
libvorbisidec1 \
libflac12 \
libavahi-client3 \
libavahi-common3 \
# AirPlay receiver dependencies (shairport-sync)
libconfig9 \
libpopt0 \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# 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}_bookworm.deb" -O /tmp/snapserver.deb \
&& wget -q "https://github.com/badaix/snapcast/releases/download/v${SNAPCAST_VERSION}/snapclient_${SNAPCAST_VERSION}-1_${SNAPCAST_ARCH}_bookworm.deb" -O /tmp/snapclient.deb \
&& dpkg -i /tmp/snapserver.deb /tmp/snapclient.deb \
&& rm /tmp/snapserver.deb /tmp/snapclient.deb
# 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 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"