|
4 | 4 | # This image forms the base for the final image and is not meant to be used directly |
5 | 5 | # NOTE that the dev add-on is also based on this base image |
6 | 6 |
|
7 | | -FROM python:3.13-alpine3.21 |
| 7 | +FROM python:3.13-slim-bookworm AS ffmpeg-builder |
8 | 8 |
|
| 9 | +# Install build dependencies for FFmpeg |
| 10 | +RUN apt-get update && apt-get install -y --no-install-recommends \ |
| 11 | + build-essential \ |
| 12 | + pkg-config \ |
| 13 | + yasm \ |
| 14 | + nasm \ |
| 15 | + git \ |
| 16 | + wget \ |
| 17 | + ca-certificates \ |
| 18 | + # Audio codec libraries |
| 19 | + libfdk-aac-dev \ |
| 20 | + libmp3lame-dev \ |
| 21 | + libopus-dev \ |
| 22 | + libvorbis-dev \ |
| 23 | + libsoxr-dev \ |
| 24 | + libspeex-dev \ |
| 25 | + libwavpack-dev \ |
| 26 | + libflac-dev \ |
| 27 | + libtwolame-dev \ |
| 28 | + libvo-amrwbenc-dev \ |
| 29 | + libopencore-amrnb-dev \ |
| 30 | + libopencore-amrwb-dev \ |
| 31 | + libshine-dev \ |
| 32 | + # Additional audio processing |
| 33 | + libsamplerate0-dev \ |
| 34 | + libbluray-dev \ |
| 35 | + libxml2-dev \ |
| 36 | + && rm -rf /var/lib/apt/lists/* |
| 37 | + |
| 38 | +# Build FFmpeg 7.1.2 from source with comprehensive audio codec support |
| 39 | +# Using static linking for self-contained binaries |
| 40 | +ARG FFMPEG_VERSION=7.1.2 |
| 41 | +RUN set -x \ |
| 42 | + && wget -q "https://ffmpeg.org/releases/ffmpeg-${FFMPEG_VERSION}.tar.xz" -O /tmp/ffmpeg.tar.xz \ |
| 43 | + && tar -xJf /tmp/ffmpeg.tar.xz -C /tmp \ |
| 44 | + && cd /tmp/ffmpeg-${FFMPEG_VERSION} \ |
| 45 | + && ./configure \ |
| 46 | + --prefix=/usr/local \ |
| 47 | + --enable-gpl \ |
| 48 | + --enable-nonfree \ |
| 49 | + --enable-version3 \ |
| 50 | + --pkg-config-flags="--static" \ |
| 51 | + --extra-ldflags="-static" \ |
| 52 | + --extra-libs="-lpthread -lm -lz" \ |
| 53 | + # Audio codecs (comprehensive support) |
| 54 | + --enable-libfdk-aac \ |
| 55 | + --enable-libmp3lame \ |
| 56 | + --enable-libopus \ |
| 57 | + --enable-libvorbis \ |
| 58 | + --enable-libsoxr \ |
| 59 | + --enable-libspeex \ |
| 60 | + --enable-libwavpack \ |
| 61 | + --enable-libtwolame \ |
| 62 | + --enable-libshine \ |
| 63 | + --enable-libopencore-amrnb \ |
| 64 | + --enable-libopencore-amrwb \ |
| 65 | + --enable-libvo-amrwbenc \ |
| 66 | + # Audio filters and resampling |
| 67 | + --enable-libsamplerate \ |
| 68 | + # Basic video support (minimal) |
| 69 | + --enable-decoder=h264 \ |
| 70 | + --enable-decoder=hevc \ |
| 71 | + --enable-decoder=vp8 \ |
| 72 | + --enable-decoder=vp9 \ |
| 73 | + # Protocols needed for streaming |
| 74 | + --enable-protocol=file \ |
| 75 | + --enable-protocol=http \ |
| 76 | + --enable-protocol=https \ |
| 77 | + --enable-protocol=tcp \ |
| 78 | + --enable-protocol=udp \ |
| 79 | + --enable-protocol=rtp \ |
| 80 | + # Disable unnecessary features for smaller build |
| 81 | + --disable-doc \ |
| 82 | + --disable-htmlpages \ |
| 83 | + --disable-manpages \ |
| 84 | + --disable-podpages \ |
| 85 | + --disable-txtpages \ |
| 86 | + --disable-debug \ |
| 87 | + --disable-shared \ |
| 88 | + --enable-static \ |
| 89 | + && make -j$(nproc) \ |
| 90 | + && make install \ |
| 91 | + && strip /usr/local/bin/ffmpeg /usr/local/bin/ffprobe \ |
| 92 | + && rm -rf /tmp/ffmpeg* |
| 93 | + |
| 94 | +################################################################################################## |
| 95 | + |
| 96 | +FROM python:3.13-slim-bookworm |
| 97 | + |
| 98 | +# Install runtime dependencies |
9 | 99 | RUN set -x \ |
10 | | - && apk add --no-cache \ |
| 100 | + && apt-get update \ |
| 101 | + && apt-get install -y --no-install-recommends \ |
11 | 102 | ca-certificates \ |
12 | | - jemalloc \ |
| 103 | + libjemalloc2 \ |
13 | 104 | tzdata \ |
14 | | - dnscache \ |
15 | 105 | # cifs utils and libnfs are needed for smb and nfs support (file provider) |
16 | 106 | cifs-utils \ |
17 | | - libnfs \ |
18 | | - # openssl-dev is needed for airplay |
19 | | - openssl-dev \ |
20 | | - # install snapcast so the snapcast provider can run the builtin snapcast server |
21 | | - snapcast \ |
22 | | - # build tools and llvm support needed for librosa/numba/llvmlite (smartfades) |
23 | | - build-base \ |
24 | | - llvm15-dev \ |
| 107 | + libnfs13 \ |
| 108 | + # openssl is needed for airplay |
| 109 | + openssl \ |
| 110 | + libssl-dev \ |
25 | 111 | # libsndfile needed for librosa audio file support (smartfades) |
26 | | - libsndfile-dev |
| 112 | + libsndfile1 \ |
| 113 | + # snapcast server and client for snapcast provider |
| 114 | + snapserver \ |
| 115 | + snapclient \ |
| 116 | + && apt-get clean \ |
| 117 | + && rm -rf /var/lib/apt/lists/* |
| 118 | + |
| 119 | +# Copy statically-linked FFmpeg binaries from builder stage |
| 120 | +COPY --from=ffmpeg-builder /usr/local/bin/ffmpeg /usr/local/bin/ |
| 121 | +COPY --from=ffmpeg-builder /usr/local/bin/ffprobe /usr/local/bin/ |
27 | 122 |
|
28 | | -# Get static ffmpeg builds from https://hub.docker.com/r/mwader/static-ffmpeg/ |
29 | | -COPY --from=mwader/static-ffmpeg:7.1.1 /ffmpeg /usr/local/bin/ |
30 | | -COPY --from=mwader/static-ffmpeg:7.1.1 /ffprobe /usr/local/bin/ |
| 123 | +# Verify FFmpeg installation |
| 124 | +RUN ffmpeg -version && ffprobe -version |
31 | 125 |
|
32 | 126 | # Copy widevine client files to container |
33 | 127 | RUN mkdir -p /usr/local/bin/widevine_cdm |
34 | 128 | COPY widevine_cdm/* /usr/local/bin/widevine_cdm/ |
35 | 129 |
|
36 | 130 | # JEMalloc for more efficient memory management |
37 | | -ENV LD_PRELOAD="/usr/lib/libjemalloc.so.2" |
38 | | - |
39 | | -# Set LLVM config for llvmlite/numba |
40 | | -ENV LLVM_CONFIG="/usr/bin/llvm-config-15" |
| 131 | +# Dynamically set the correct path based on architecture |
| 132 | +ARG TARGETARCH |
| 133 | +RUN set -x \ |
| 134 | + && if [ "$TARGETARCH" = "arm64" ]; then \ |
| 135 | + echo "/usr/lib/aarch64-linux-gnu/libjemalloc.so.2" > /etc/ld.so.preload; \ |
| 136 | + else \ |
| 137 | + echo "/usr/lib/x86_64-linux-gnu/libjemalloc.so.2" > /etc/ld.so.preload; \ |
| 138 | + fi |
41 | 139 |
|
42 | 140 | # we need to set (very permissive) permissions to the workdir |
43 | 141 | # and /tmp to allow running the container as non-root |
|
0 commit comments