build: multi-stage dockerfile with linuxserver/ffmpeg for full hardware encoding support
This commit is contained in:
+65
-13
@@ -1,15 +1,67 @@
|
|||||||
FROM node:20-alpine
|
# NodeCast TV Docker Image
|
||||||
|
#
|
||||||
|
# Multi-stage build for FFmpeg with full hardware acceleration support.
|
||||||
|
# Uses linuxserver/ffmpeg which includes NVENC, VAAPI, and QSV.
|
||||||
|
#
|
||||||
|
# Hardware acceleration:
|
||||||
|
# - VAAPI (Intel/AMD): Mount /dev/dri and add video/render groups
|
||||||
|
# - NVIDIA NVENC: Requires nvidia-container-toolkit on host + --gpus flag
|
||||||
|
# - Intel QSV: Mount /dev/dri
|
||||||
|
#
|
||||||
|
# Build: docker compose build
|
||||||
|
# Run with VAAPI: docker run --device /dev/dri:/dev/dri --group-add video ...
|
||||||
|
# Run with NVENC: docker run --gpus all ...
|
||||||
|
|
||||||
# Install build dependencies for better-sqlite3 and FFmpeg for streaming
|
# Stage 1: Get FFmpeg with all hardware encoders from linuxserver
|
||||||
# Using system FFmpeg instead of ffmpeg-static for better Docker DNS compatibility
|
FROM linuxserver/ffmpeg:latest AS ffmpeg
|
||||||
# Hardware acceleration packages:
|
|
||||||
# - mesa-va-gallium: AMD VAAPI (Radeon/Vega)
|
# Stage 2: Node.js runtime with app
|
||||||
# - intel-media-driver: Intel VAAPI/QSV (newer Intel GPUs)
|
FROM node:20-slim
|
||||||
# - libva-intel-driver: Intel VAAPI (older Intel GPUs, Haswell-Skylake)
|
|
||||||
# - libva-utils: vainfo tool for debugging
|
# Install runtime dependencies for FFmpeg and hardware acceleration
|
||||||
# Note: NVIDIA requires nvidia-container-toolkit on host + --gpus flag
|
ENV DEBIAN_FRONTEND=noninteractive
|
||||||
RUN apk add --no-cache python3 make g++ ffmpeg \
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||||
mesa-va-gallium intel-media-driver libva-intel-driver libva-utils
|
# Build dependencies for better-sqlite3
|
||||||
|
python3 \
|
||||||
|
make \
|
||||||
|
g++ \
|
||||||
|
# VAAPI runtime libraries (AMD/Intel)
|
||||||
|
libva2 \
|
||||||
|
libva-drm2 \
|
||||||
|
libvdpau1 \
|
||||||
|
mesa-va-drivers \
|
||||||
|
# Intel VAAPI/QSV drivers
|
||||||
|
intel-media-va-driver \
|
||||||
|
i965-va-driver \
|
||||||
|
# VA-API utilities for debugging
|
||||||
|
vainfo \
|
||||||
|
# FFmpeg shared library dependencies
|
||||||
|
libx264-164 \
|
||||||
|
libx265-199 \
|
||||||
|
libfdk-aac2 \
|
||||||
|
libvpx7 \
|
||||||
|
libmp3lame0 \
|
||||||
|
libopus0 \
|
||||||
|
libvorbis0a \
|
||||||
|
libass9 \
|
||||||
|
libfreetype6 \
|
||||||
|
libfontconfig1 \
|
||||||
|
libssl3 \
|
||||||
|
# NVIDIA libraries (for NVENC when using --gpus)
|
||||||
|
libnvidia-encode1 \
|
||||||
|
&& rm -rf /var/lib/apt/lists/* || true
|
||||||
|
|
||||||
|
# Copy FFmpeg binaries from linuxserver/ffmpeg
|
||||||
|
COPY --from=ffmpeg /usr/local/bin/ffmpeg /usr/local/bin/ffmpeg
|
||||||
|
COPY --from=ffmpeg /usr/local/bin/ffprobe /usr/local/bin/ffprobe
|
||||||
|
|
||||||
|
# Also try to copy from standard location if above fails
|
||||||
|
COPY --from=ffmpeg /usr/bin/ffmpeg /usr/local/bin/ffmpeg 2>/dev/null || true
|
||||||
|
COPY --from=ffmpeg /usr/bin/ffprobe /usr/local/bin/ffprobe 2>/dev/null || true
|
||||||
|
|
||||||
|
# Verify FFmpeg works and show capabilities
|
||||||
|
RUN ffmpeg -version || echo "FFmpeg copy failed, checking alternate location..." && \
|
||||||
|
ls -la /usr/local/bin/ff* || true
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
@@ -22,8 +74,8 @@ RUN npm ci --only=production
|
|||||||
# Copy application files
|
# Copy application files
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
# Create data directory
|
# Create data and cache directories
|
||||||
RUN mkdir -p /app/data
|
RUN mkdir -p /app/data /app/transcode-cache && chmod 777 /app/transcode-cache
|
||||||
|
|
||||||
# Expose port
|
# Expose port
|
||||||
EXPOSE 3000
|
EXPOSE 3000
|
||||||
|
|||||||
Reference in New Issue
Block a user