/
/
/
1# syntax=docker/dockerfile:1
2
3# BASE docker image for music assistant container
4# This image forms the base for the final image and is not meant to be used directly
5# NOTE that the dev add-on is also based on this base image
6
7FROM python:3.13-slim-bookworm AS ffmpeg-builder
8
9# Enable non-free and contrib repositories for FDK-AAC and other codecs
10RUN echo "deb http://deb.debian.org/debian bookworm main contrib non-free non-free-firmware" > /etc/apt/sources.list && \
11 echo "deb http://deb.debian.org/debian-security bookworm-security main contrib non-free non-free-firmware" >> /etc/apt/sources.list && \
12 echo "deb http://deb.debian.org/debian bookworm-updates main contrib non-free non-free-firmware" >> /etc/apt/sources.list
13
14# Install build dependencies for FFmpeg
15RUN apt-get update && apt-get install -y --no-install-recommends \
16 build-essential \
17 pkg-config \
18 yasm \
19 nasm \
20 git \
21 wget \
22 ca-certificates \
23 # Audio codec libraries
24 libfdk-aac-dev \
25 libmp3lame-dev \
26 libopus-dev \
27 libvorbis-dev \
28 libsoxr-dev \
29 libspeex-dev \
30 libtwolame-dev \
31 libvo-amrwbenc-dev \
32 libopencore-amrnb-dev \
33 libopencore-amrwb-dev \
34 libshine-dev \
35 # Audio processing and filters
36 librubberband-dev \
37 libbs2b-dev \
38 libsamplerate0-dev \
39 libmysofa-dev \
40 libjack-jackd2-dev \
41 libpulse-dev \
42 # Additional libraries
43 libbluray-dev \
44 libxml2-dev \
45 libssh-dev \
46 liblzma-dev \
47 # SSL/TLS support for HTTPS
48 libssl-dev \
49 && rm -rf /var/lib/apt/lists/*
50
51# Build FFmpeg 7.1.2 from source with comprehensive audio codec support
52ARG FFMPEG_VERSION=7.1.2
53RUN set -x \
54 && wget -q "https://ffmpeg.org/releases/ffmpeg-${FFMPEG_VERSION}.tar.xz" -O /tmp/ffmpeg.tar.xz \
55 && tar -xJf /tmp/ffmpeg.tar.xz -C /tmp \
56 && cd /tmp/ffmpeg-${FFMPEG_VERSION} \
57 && ./configure \
58 --prefix=/usr/local \
59 --enable-gpl \
60 --enable-nonfree \
61 --enable-version3 \
62 # Audio codecs (comprehensive support)
63 --enable-libfdk-aac \
64 --enable-libmp3lame \
65 --enable-libopus \
66 --enable-libvorbis \
67 --enable-libspeex \
68 --enable-libtwolame \
69 --enable-libshine \
70 --enable-libopencore-amrnb \
71 --enable-libopencore-amrwb \
72 --enable-libvo-amrwbenc \
73 # Audio filters and resampling
74 --enable-libsoxr \
75 --enable-librubberband \
76 --enable-libbs2b \
77 --enable-libmysofa \
78 --enable-libjack \
79 --enable-libpulse \
80 # SSL/TLS support for HTTPS
81 --enable-openssl \
82 # Additional libraries for playlist and network support
83 --enable-libxml2 \
84 --enable-libssh \
85 --enable-lzma \
86 # Optimizations
87 --enable-runtime-cpudetect \
88 # Disable unnecessary features for smaller build
89 --disable-doc \
90 --disable-htmlpages \
91 --disable-manpages \
92 --disable-podpages \
93 --disable-txtpages \
94 --disable-debug \
95 --disable-static \
96 --enable-shared \
97 && make -j$(nproc) \
98 && make install \
99 && strip /usr/local/bin/ffmpeg /usr/local/bin/ffprobe \
100 && rm -rf /tmp/ffmpeg*
101
102##################################################################################################
103
104# PyAV wheel builder - builds PyAV against the custom FFmpeg
105FROM python:3.13-slim-bookworm AS pyav-builder
106
107RUN apt-get update && apt-get install -y --no-install-recommends \
108 gcc g++ python3-dev pkg-config && rm -rf /var/lib/apt/lists/*
109
110COPY --from=ffmpeg-builder /usr/local/lib/libav*.so* /usr/local/lib/
111COPY --from=ffmpeg-builder /usr/local/lib/libsw*.so* /usr/local/lib/
112COPY --from=ffmpeg-builder /usr/local/lib/libpostproc.so* /usr/local/lib/
113COPY --from=ffmpeg-builder /usr/local/include/ /usr/local/include/
114COPY --from=ffmpeg-builder /usr/local/lib/pkgconfig/ /usr/local/lib/pkgconfig/
115
116RUN ldconfig
117ENV PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
118
119# Resolve PyAV version from aiosendspin's dependencies and build wheel
120RUN PYAV_VERSION=$(pip install --dry-run aiosendspin 2>&1 | grep -oP 'av-\K[0-9.]+' | head -1) && \
121 if [ -z "$PYAV_VERSION" ]; then \
122 echo "ERROR: Failed to detect PyAV version from aiosendspin dependencies" >&2; \
123 exit 1; \
124 fi && \
125 echo "Building PyAV version: ${PYAV_VERSION}" && \
126 pip wheel --no-binary av av==${PYAV_VERSION} -w /wheels/
127
128##################################################################################################
129
130FROM python:3.13-slim-bookworm
131
132# Enable non-free and contrib repositories for codec libraries
133RUN echo "deb http://deb.debian.org/debian bookworm main contrib non-free non-free-firmware" > /etc/apt/sources.list && \
134 echo "deb http://deb.debian.org/debian-security bookworm-security main contrib non-free non-free-firmware" >> /etc/apt/sources.list && \
135 echo "deb http://deb.debian.org/debian bookworm-updates main contrib non-free non-free-firmware" >> /etc/apt/sources.list
136
137# Install runtime dependencies
138RUN set -x \
139 && apt-get update \
140 && apt-get install -y --no-install-recommends \
141 ca-certificates \
142 libjemalloc2 \
143 tzdata \
144 wget \
145 # cifs utils and libnfs are needed for smb and nfs support (file provider)
146 cifs-utils \
147 libnfs13 \
148 # airplay libraries
149 openssl \
150 libssl-dev \
151 libuuid1 \
152 libcurl4 \
153 libsodium23 \
154 libconfuse2 \
155 libunistring2 \
156 libxml2 \
157 libevent-dev \
158 libjson-c5 \
159 libplist3 \
160 libgcrypt20 \
161 libavfilter8 \
162 # libsndfile needed for librosa audio file support (smartfades)
163 libsndfile1 \
164 # Audio codec runtime libraries (needed for FFmpeg)
165 libfdk-aac2 \
166 libmp3lame0 \
167 libopus0 \
168 libvorbis0a \
169 libvorbisenc2 \
170 libsoxr0 \
171 libspeex1 \
172 libtwolame0 \
173 libshine3 \
174 libopencore-amrnb0 \
175 libopencore-amrwb0 \
176 libvo-amrwbenc0 \
177 # Audio processing libraries
178 librubberband2 \
179 libbs2b0 \
180 libsamplerate0 \
181 libmysofa1 \
182 libjack-jackd2-0 \
183 libpulse0 \
184 # Additional libraries
185 libbluray2 \
186 libxml2 \
187 libssh-4 \
188 liblzma5 \
189 # Snapcast dependencies
190 libasound2 \
191 libvorbisidec1 \
192 libflac12 \
193 libavahi-client3 \
194 libavahi-common3 \
195 # AirPlay receiver dependencies (shairport-sync)
196 libconfig9 \
197 libpopt0 \
198 && apt-get clean \
199 && rm -rf /var/lib/apt/lists/*
200
201# Install Snapcast 0.34.0 from GitHub releases (requires at least 0.27)
202ARG SNAPCAST_VERSION=0.34.0
203ARG TARGETARCH
204RUN set -x \
205 && if [ "$TARGETARCH" = "arm64" ]; then \
206 SNAPCAST_ARCH="arm64"; \
207 else \
208 SNAPCAST_ARCH="amd64"; \
209 fi \
210 && wget -q "https://github.com/badaix/snapcast/releases/download/v${SNAPCAST_VERSION}/snapserver_${SNAPCAST_VERSION}-1_${SNAPCAST_ARCH}_bookworm.deb" -O /tmp/snapserver.deb \
211 && wget -q "https://github.com/badaix/snapcast/releases/download/v${SNAPCAST_VERSION}/snapclient_${SNAPCAST_VERSION}-1_${SNAPCAST_ARCH}_bookworm.deb" -O /tmp/snapclient.deb \
212 && dpkg -i /tmp/snapserver.deb /tmp/snapclient.deb \
213 && rm /tmp/snapserver.deb /tmp/snapclient.deb
214
215# Copy FFmpeg binaries and libraries from builder stage
216COPY --from=ffmpeg-builder /usr/local/bin/ffmpeg /usr/local/bin/
217COPY --from=ffmpeg-builder /usr/local/bin/ffprobe /usr/local/bin/
218COPY --from=ffmpeg-builder /usr/local/lib/libav*.so* /usr/local/lib/
219COPY --from=ffmpeg-builder /usr/local/lib/libsw*.so* /usr/local/lib/
220COPY --from=ffmpeg-builder /usr/local/lib/libpostproc.so* /usr/local/lib/
221
222# Copy pre-built PyAV wheel for use by downstream images
223COPY --from=pyav-builder /wheels/ /usr/local/share/pyav-wheels/
224
225# Update shared library cache and verify FFmpeg
226RUN ldconfig && ffmpeg -version && ffprobe -version
227
228# Copy widevine client files to container
229RUN mkdir -p /usr/local/bin/widevine_cdm
230COPY widevine_cdm/* /usr/local/bin/widevine_cdm/
231
232# we need to set (very permissive) permissions to the workdir
233# and /tmp to allow running the container as non-root
234RUN chmod -R 777 /tmp
235
236LABEL \
237 org.opencontainers.image.title="Music Assistant Base Image" \
238 org.opencontainers.image.description="Base Image for Music Assistant server - not to be used directly" \
239 org.opencontainers.image.source="https://github.com/music-assistant/server" \
240 org.opencontainers.image.authors="The Music Assistant Team" \
241 org.opencontainers.image.licenses="Apache License 2.0"
242