Debian Codegraph @

docker/Dockerfile

raw
1 # Fluster - testing framework for decoders conformance
2 # Copyright (C) 2025, Fluendo, S.A.
3 # Author: Ruben Sanchez Sanchez <[email protected]>, Fluendo, S.A.
4 #
5 # This library is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU Lesser General Public License
7 # as published by the Free Software Foundation, either version 3
8 # of the License, or (at your option) any later version.
9 #
10 # This library is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # Lesser General Public License for more details.
14 #
15 # You should have received a copy of the GNU Lesser General Public
16 # License along with this library. If not, see <https://www.gnu.org/licenses/>.
17
18 # Fluster Docker Image with Hardware Acceleration Support
19 # Supports VAAPI, VDPAU, NVDEC, and Intel QuickSync
20
21 ARG UBUNTU_VERSION=24.04
22 FROM ubuntu:${UBUNTU_VERSION}
23
24 # A user is required by Ubuntu 24.04 to install meson as non-root
25 ARG USERNAME='mock'
26 ARG PASSWORD='mock'
27
28 # Re-declare args after FROM to make them available in build stages
29 ARG UBUNTU_VERSION
30 ARG NVIDIA_DRIVER_VERSION
31 # FFmpeg installation method: "system" (default), "static", "source"
32 ARG FFMPEG_INSTALL_METHOD=system
33 # FFmpeg version for "source" method
34 ARG FFMPEG_VERSION=8.0
35 # GStreamer installation method: "system" (default), "source"
36 ARG GSTREAMER_INSTALL_METHOD=system
37 # GStreamer version for "source" method
38 ARG GSTREAMER_VERSION=1.24.2
39
40 ENV DEBIAN_FRONTEND=noninteractive \
41 TERM=xterm-256color \
42 LANG=C.UTF-8 \
43 LC_ALL=C.UTF-8
44
45 WORKDIR /fluster
46
47 # Base dependencies
48 RUN apt-get update && apt-get install -y \
49 git \
50 wget \
51 curl \
52 ca-certificates \
53 software-properties-common \
54 sudo \
55 python3 \
56 python3-pip \
57 python3-venv \
58 pciutils \
59 && rm -rf /var/lib/apt/lists/*
60
61 # VAAPI support, Intel and AMD drivers
62 RUN apt-get update && apt-get install -y \
63 libva-dev \
64 libva-drm2 \
65 libva-x11-2 \
66 vainfo \
67 i965-va-driver \
68 mesa-va-drivers \
69 && (apt-get install -y intel-media-va-driver-non-free || \
70 apt-get install -y intel-media-va-driver || true) \
71 && rm -rf /var/lib/apt/lists/*
72
73 # VAAPI driver for NVIDIA (Ubuntu 24.04+)
74 RUN if [ "${UBUNTU_VERSION}" = "24.04" ]; then \
75 apt-get update && \
76 apt-get install -y nvidia-vaapi-driver && \
77 rm -rf /var/lib/apt/lists/*; \
78 fi
79
80 # VDPAU support and GPU drivers
81 RUN apt-get update && apt-get install -y \
82 libvdpau-dev \
83 libvdpau1 \
84 vdpauinfo \
85 libvdpau-va-gl1 \
86 mesa-vdpau-drivers \
87 && rm -rf /var/lib/apt/lists/*
88
89 # NVIDIA VDPAU libraries (must match host driver version)
90 RUN if [ -n "${NVIDIA_DRIVER_VERSION}" ]; then \
91 apt-get update && \
92 apt-get install -y \
93 libnvidia-decode-${NVIDIA_DRIVER_VERSION} \
94 libnvidia-encode-${NVIDIA_DRIVER_VERSION} && \
95 rm -rf /var/lib/apt/lists/*; \
96 fi
97
98 # Intel QuickSync support via Media SDK and oneVPL
99 RUN apt-get update && apt-get install -y \
100 libmfx1 \
101 libmfx-tools \
102 && (apt-get install -y libmfx-gen1.2 || true) \
103 && (apt-get install -y libvpl-dev libvpl2 || true) \
104 && rm -rf /var/lib/apt/lists/*
105
106 # FFmpeg installation (3 methods: system, static, source)
107 # Method "source": Build FFmpeg from source with all backends (VAAPI, VDPAU, QuickSync)
108 # Method "static": Download pre-built static FFmpeg binary
109 # Method "system": Install FFmpeg from system packages (default)
110 RUN if [ "${FFMPEG_INSTALL_METHOD}" = "source" ]; then \
111 apt-get update -qq && apt-get install -y \
112 autoconf \
113 automake \
114 build-essential \
115 cmake \
116 git-core \
117 libass-dev \
118 libfreetype6-dev \
119 libgnutls28-dev \
120 libmp3lame-dev \
121 libsdl2-dev \
122 libtool \
123 libva-dev \
124 libvdpau-dev \
125 libvorbis-dev \
126 libxcb1-dev \
127 libxcb-shm0-dev \
128 libxcb-xfixes0-dev \
129 meson \
130 ninja-build \
131 pkg-config \
132 texinfo \
133 wget \
134 yasm \
135 zlib1g-dev \
136 nasm \
137 libx264-dev \
138 libx265-dev \
139 libnuma-dev \
140 libvpx-dev \
141 libfdk-aac-dev \
142 libopus-dev \
143 libmfx-dev \
144 libunistring-dev \
145 && rm -rf /var/lib/apt/lists/* && \
146 mkdir /tmp/aom && \
147 cd /tmp/aom && \
148 git -C aom pull 2> /dev/null || git clone --depth 1 https://aomedia.googlesource.com/aom && \
149 mkdir -p aom_build && \
150 cd aom_build && \
151 cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="/usr/local" -DENABLE_TESTS=OFF -DENABLE_NASM=on ../aom && \
152 make && \
153 make install && \
154 cd / && rm -rf /tmp/aom && \
155 mkdir /tmp/dav1d && \
156 cd /tmp/dav1d && \
157 git -C dav1d pull 2> /dev/null || git clone --depth 1 https://code.videolan.org/videolan/dav1d.git && \
158 mkdir -p dav1d/build && \
159 cd dav1d/build && \
160 meson setup -Denable_tools=false -Denable_tests=false --default-library=static .. --prefix "/usr/local" --libdir="/usr/local/lib" && \
161 ninja && \
162 ninja install && \
163 cd / && rm -rf /tmp/dav1d && \
164 git clone --depth 1 --branch n${FFMPEG_VERSION} https://github.com/FFmpeg/FFmpeg.git /tmp/ffmpeg && \
165 cd /tmp/ffmpeg && \
166 export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/local/lib/x86_64-linux-gnu/pkgconfig:${PKG_CONFIG_PATH:-} && \
167 export LD_LIBRARY_PATH=/usr/local/lib:/usr/local/lib/x86_64-linux-gnu:${LD_LIBRARY_PATH:-} && \
168 ./configure \
169 --prefix=/usr/local \
170 --pkg-config-flags="--static" \
171 --extra-cflags="-I$HOME/ffmpeg_build/include" \
172 --extra-ldflags="-L$HOME/ffmpeg_build/lib" \
173 --extra-libs="-lpthread -lm" \
174 --ld="g++" \
175 --enable-gpl \
176 --enable-vaapi \
177 --enable-vdpau \
178 --enable-version3 \
179 --enable-nonfree \
180 --enable-libx264 \
181 --enable-libx265 \
182 --enable-libmfx \
183 --enable-gnutls \
184 --enable-libaom \
185 --enable-libass \
186 --enable-libfdk-aac \
187 --enable-libfreetype \
188 --enable-libmp3lame \
189 --enable-libopus \
190 --enable-libdav1d \
191 --enable-libvorbis \
192 --enable-libvpx \
193 && make -j$(nproc) \
194 && make install \
195 && ldconfig \
196 && cd / && rm -rf /tmp/ffmpeg /tmp/ffmpeg_sources; \
197 elif [ "${FFMPEG_INSTALL_METHOD}" = "static" ]; then \
198 wget -q https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-amd64-static.tar.xz && \
199 tar -xf ffmpeg-release-amd64-static.tar.xz && \
200 mv ffmpeg-*-amd64-static /opt/ffmpeg && \
201 ln -sf /opt/ffmpeg/ffmpeg /usr/local/bin/ffmpeg && \
202 ln -sf /opt/ffmpeg/ffprobe /usr/local/bin/ffprobe && \
203 rm ffmpeg-release-amd64-static.tar.xz; \
204 else \
205 apt-get update && \
206 apt-get install -y --no-install-recommends \
207 ffmpeg \
208 libavcodec-dev \
209 libavformat-dev \
210 libavutil-dev \
211 libswscale-dev \
212 && rm -rf /var/lib/apt/lists/*; \
213 fi
214
215 # Update python packages depending on Ubuntu version
216 RUN if [ "${GSTREAMER_INSTALL_METHOD}" = "source" ]; then \
217 if [ "${UBUNTU_VERSION}" = "24.04" ]; then \
218 pip3 install --upgrade pip setuptools; \
219 apt update && apt install -y pipx ninja-build && rm -rf /var/lib/apt/lists/*; \
220 else \
221 pip3 install --upgrade pip setuptools meson; \
222 fi; \
223 fi
224
225
226 # Ubuntu 24.04: Remove default user
227 RUN if [ "${UBUNTU_VERSION}" = "24.04" ] && id ubuntu &>/dev/null; then \
228 userdel -r ubuntu; \
229 fi
230
231 # Create USERNAME user and add it to sudoers without password
232 RUN addgroup ${USERNAME} && \
233 useradd -rm -s /bin/bash -m -g ${USERNAME} -u 1000 -G sudo ${USERNAME} && \
234 echo ${USERNAME}':'${PASSWORD} | chpasswd && echo "${USERNAME} ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers;
235
236 # Change to USERNAME user
237 USER ${USERNAME}
238
239 # Set PATH to include pipx bin directory - only necessary for meson in Ubuntu 24.04
240 ARG PATH="/home/${USERNAME}/.local/bin:${PATH}"
241
242 # Ubuntu 24.04: install python packages for non-root user
243 RUN if [ "${GSTREAMER_INSTALL_METHOD}" = "source" ] && [ "${UBUNTU_VERSION}" = "24.04" ]; then \
244 echo "export PATH=/home/${USERNAME}/.local/bin:\${PATH}" >> /home/${USERNAME}/.bashrc; \
245 pipx install meson; \
246 fi
247
248 # GStreamer installation (2 methods: system, source)
249 # Method "source": Build GStreamer from source (needed for new versions on old distros)
250 # Note: gst-libav is disabled when building from source to avoid FFmpeg API incompatibilities
251 # (GStreamer 1.24.x is not compatible with FFmpeg 7+/8+ APIs)
252 # Use GStreamer native decoders or FFmpeg directly for decoding.
253 # Method "system": Install GStreamer from system packages (default)
254 RUN if [ "${GSTREAMER_INSTALL_METHOD}" = "source" ]; then \
255 sudo apt-get update && sudo apt-get install -y --no-install-recommends \
256 build-essential \
257 cmake \
258 ninja-build \
259 pkg-config \
260 python3-pip \
261 bison \
262 flex \
263 nasm \
264 libglib2.0-dev \
265 liborc-0.4-dev \
266 libpthread-stubs0-dev \
267 libva-dev \
268 libvdpau-dev \
269 libmfx-dev \
270 libx11-dev \
271 libxext-dev \
272 libxv-dev \
273 libdrm-dev \
274 libgudev-1.0-dev \
275 libasound2-dev \
276 libopus-dev \
277 libvorbis-dev \
278 libtheora-dev \
279 libvpx-dev \
280 libpng-dev \
281 libjpeg-dev \
282 libxml2-dev \
283 && sudo rm -rf /var/lib/apt/lists/* \
284 && mkdir -p /tmp/gstreamer && cd /tmp/gstreamer \
285 && curl -L "https://gitlab.freedesktop.org/gstreamer/gstreamer/-/archive/${GSTREAMER_VERSION}/gstreamer-${GSTREAMER_VERSION}.tar.gz" | tar xz \
286 && cd gstreamer-${GSTREAMER_VERSION} \
287 && meson setup build \
288 --prefix=/usr/local \
289 --buildtype=release \
290 -Dgpl=enabled \
291 -Dugly=enabled \
292 -Dvaapi=enabled \
293 -Dlibav=disabled \
294 -Dbase=enabled \
295 -Dgood=enabled \
296 -Dbad=enabled \
297 -Dgst-plugins-base:gl=disabled \
298 -Dgst-plugins-bad:gl=disabled \
299 -Ddevtools=disabled \
300 -Dges=disabled \
301 -Drtsp_server=disabled \
302 -Dsharp=disabled \
303 -Dpython=disabled \
304 -Dtests=disabled \
305 -Dexamples=disabled \
306 -Dintrospection=disabled \
307 -Ddoc=disabled \
308 -Dqt5=disabled \
309 && meson compile -C build -j$(nproc) \
310 && sudo ninja install -C build \
311 && sudo ldconfig \
312 && cd / && sudo rm -rf /tmp/gstreamer \
313 && sudo apt-get purge -y 'libgstreamer*' 'gstreamer1.0-*' 2>/dev/null || true \
314 && sudo apt-get autoremove -y 2>/dev/null || true; \
315 else \
316 sudo DEBIAN_FRONTEND=noninteractive apt-get update && \
317 sudo DEBIAN_FRONTEND=noninteractive apt-get install -y \
318 libgstreamer1.0-dev \
319 libgstreamer-plugins-base1.0-dev \
320 libgstreamer-plugins-bad1.0-dev \
321 gstreamer1.0-plugins-base \
322 gstreamer1.0-plugins-good \
323 gstreamer1.0-plugins-bad \
324 gstreamer1.0-plugins-ugly \
325 gstreamer1.0-libav \
326 gstreamer1.0-tools \
327 gstreamer1.0-vaapi \
328 && (sudo apt-get install -y gstreamer1.0-va || true) \
329 && (sudo apt-get install -y gstreamer1.0-msdk || true) \
330 && sudo rm -rf /var/lib/apt/lists/*; \
331 fi
332
333 USER root
334
335 # Set library paths - /usr/local MUST come first to prioritize compiled versions
336 ENV LD_LIBRARY_PATH=/usr/local/lib/x86_64-linux-gnu:/usr/local/lib:/usr/lib/x86_64-linux-gnu \
337 GST_PLUGIN_PATH=/usr/local/lib/x86_64-linux-gnu/gstreamer-1.0:/usr/local/lib/gstreamer-1.0:/usr/lib/x86_64-linux-gnu/gstreamer-1.0 \
338 PKG_CONFIG_PATH=/usr/local/lib/x86_64-linux-gnu/pkgconfig:/usr/local/lib/pkgconfig:/usr/lib/x86_64-linux-gnu/pkgconfig \
339 PATH=/usr/local/bin:/usr/bin:/bin
340
341 COPY . /fluster/
342
343 # Install Fluster
344 RUN pip3 install . --no-cache-dir --break-system-packages 2>/dev/null || \
345 pip3 install . --no-cache-dir
346
347 RUN mkdir -p /fluster/resources /fluster/test_suites
348
349 # Additional environment variables
350 ENV PYTHONPATH=/fluster \
351 LIBVA_DRIVERS_PATH=/usr/lib/x86_64-linux-gnu/dri \
352 MFX_HOME=/opt/intel/mediasdk
353
354 COPY docker/hw-info.sh /usr/local/bin/hw-info
355 RUN chmod +x /usr/local/bin/hw-info
356
357 CMD ["/bin/bash"]