# Multi-architecture accelerated base image with hardware encoding support # Supports Intel QuickSync, NVIDIA CUDA, FFmpeg, and Python FROM ubuntu:22.04 # Prevent interactive prompts during package installation ENV DEBIAN_FRONTEND=noninteractive # Install base dependencies and development tools RUN apt-get update && apt-get install -y \ # Basic tools curl \ wget \ git \ build-essential \ pkg-config \ cmake \ # Python and pip python3 \ python3-pip \ python3-dev \ # Media libraries libavcodec-dev \ libavformat-dev \ libavutil-dev \ libswscale-dev \ libavdevice-dev \ libavfilter-dev \ # Intel Media SDK dependencies (for QuickSync) intel-media-va-driver-non-free \ vainfo \ libva-dev \ libva-drm2 \ libva-x11-2 \ # Additional libraries libglib2.0-0 \ libsm6 \ libxext6 \ libxrender-dev \ libgomp1 \ # Clean up && apt-get clean \ && rm -rf /var/lib/apt/lists/* # Install FFmpeg with hardware acceleration support # Using static build for consistency across architectures RUN ARCH=$(uname -m) && \ if [ "$ARCH" = "x86_64" ]; then \ wget -q https://github.com/BtbN/FFmpeg-Builds/releases/download/latest/ffmpeg-master-latest-linux64-gpl.tar.xz && \ tar -xf ffmpeg-master-latest-linux64-gpl.tar.xz && \ mv ffmpeg-master-latest-linux64-gpl/bin/* /usr/local/bin/ && \ rm -rf ffmpeg-master-latest-linux64-gpl*; \ elif [ "$ARCH" = "aarch64" ]; then \ wget -q https://github.com/BtbN/FFmpeg-Builds/releases/download/latest/ffmpeg-master-latest-linuxarm64-gpl.tar.xz && \ tar -xf ffmpeg-master-latest-linuxarm64-gpl.tar.xz && \ mv ffmpeg-master-latest-linuxarm64-gpl/bin/* /usr/local/bin/ && \ rm -rf ffmpeg-master-latest-linuxarm64-gpl*; \ fi # Install NVIDIA CUDA support (will be ignored on non-NVIDIA systems) # Using a minimal CUDA runtime that works on both architectures RUN ARCH=$(uname -m) && \ if [ "$ARCH" = "x86_64" ]; then \ apt-get update && \ apt-get install -y --no-install-recommends \ cuda-compat-11-8 \ libnvidia-encode-515 \ libnvidia-decode-515 \ || echo "CUDA packages not available, skipping"; \ elif [ "$ARCH" = "aarch64" ]; then \ echo "ARM64 CUDA support will be provided by host system if available"; \ fi && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* # Create non-root user for running applications RUN useradd -m -s /bin/bash appuser # Set up Python environment RUN pip3 install --no-cache-dir --upgrade pip setuptools wheel # Install commonly needed Python packages for media processing RUN pip3 install --no-cache-dir \ numpy \ Pillow \ opencv-python-headless \ imageio \ imageio-ffmpeg # Set working directory WORKDIR /app # Switch to non-root user by default USER appuser # Set environment variables for hardware acceleration ENV LIBVA_DRIVER_NAME=iHD ENV LIBVA_DRIVERS_PATH=/usr/lib/x86_64-linux-gnu/dri # Default command CMD ["/bin/bash"]