111 lines
3.3 KiB
Docker
111 lines
3.3 KiB
Docker
FROM ubuntu:22.04
|
|
|
|
# Metadata
|
|
LABEL maintainer="encoderPro"
|
|
LABEL description="Intel Arc GPU-accelerated media encoding with web dashboard"
|
|
LABEL version="3.1.0"
|
|
|
|
# Prevent interactive prompts
|
|
ENV DEBIAN_FRONTEND=noninteractive
|
|
|
|
# Install basic dependencies
|
|
RUN apt-get update && apt-get install -y \
|
|
python3 \
|
|
python3-pip \
|
|
wget \
|
|
gpg \
|
|
software-properties-common \
|
|
procps \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Add Intel package repository for media drivers
|
|
RUN wget -qO - https://repositories.intel.com/gpu/intel-graphics.key | gpg --dearmor --output /usr/share/keyrings/intel-graphics.gpg && \
|
|
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/intel-graphics.gpg] https://repositories.intel.com/gpu/ubuntu jammy client" | \
|
|
tee /etc/apt/sources.list.d/intel-gpu-jammy.list
|
|
|
|
# Install Intel GPU drivers and compute runtime
|
|
RUN apt-get update && apt-get install -y \
|
|
intel-opencl-icd \
|
|
intel-level-zero-gpu \
|
|
level-zero \
|
|
intel-media-va-driver-non-free \
|
|
libmfx1 \
|
|
libmfxgen1 \
|
|
libvpl2 \
|
|
libva-drm2 \
|
|
libva2 \
|
|
vainfo \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Install FFmpeg with QSV support
|
|
RUN add-apt-repository ppa:ubuntuhandbook1/ffmpeg6 && \
|
|
apt-get update && \
|
|
apt-get install -y ffmpeg && \
|
|
rm -rf /var/lib/apt/lists/*
|
|
|
|
# Verify QSV support
|
|
RUN ffmpeg -hide_banner -encoders | grep qsv || echo "Warning: QSV encoders not found"
|
|
|
|
# Install Python dependencies
|
|
RUN pip3 install --no-cache-dir \
|
|
pyyaml \
|
|
flask \
|
|
flask-cors
|
|
|
|
# Create application directory
|
|
WORKDIR /app
|
|
|
|
# Copy application files
|
|
COPY reencode.py /app/reencode.py
|
|
COPY dashboard.py /app/dashboard.py
|
|
COPY quality_checker.py /app/quality_checker.py
|
|
COPY config.yaml /app/config.yaml.example
|
|
COPY config-nvidia.yaml /app/config-nvidia.yaml.example
|
|
COPY config-intel.yaml /app/config-intel.yaml.example
|
|
COPY config-cpu.yaml /app/config-cpu.yaml.example
|
|
COPY templates/ /app/templates/
|
|
COPY static/ /app/static/
|
|
|
|
# Create non-root user (needs to be in video group for GPU access)
|
|
# Note: render group may not exist in all base images, so we create it if needed
|
|
RUN groupadd -r encoder && useradd -r -g encoder -u 1000 encoder && \
|
|
(getent group render > /dev/null || groupadd -r render) && \
|
|
usermod -aG video encoder && \
|
|
usermod -aG render encoder
|
|
|
|
# Create mount points with proper ownership
|
|
RUN mkdir -p /movies /archive /work /config /logs /db && \
|
|
chown -R encoder:encoder /app /db /logs /config /work
|
|
|
|
# Set proper permissions
|
|
RUN chmod +x /app/reencode.py /app/dashboard.py
|
|
|
|
# Entry point script (must be done as root before USER switch)
|
|
COPY docker-entrypoint.sh /usr/local/bin/
|
|
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
|
|
|
|
# Switch to non-root user
|
|
USER encoder
|
|
|
|
# Environment variables with defaults
|
|
ENV MOVIES_DIR=/movies \
|
|
ARCHIVE_DIR=/archive \
|
|
WORK_DIR=/work \
|
|
STATE_DB=/db/state.db \
|
|
LOG_DIR=/logs \
|
|
CONFIG_FILE=/config/config.yaml \
|
|
REENCODE_SCRIPT=/app/reencode.py \
|
|
DASHBOARD_HOST=0.0.0.0 \
|
|
DASHBOARD_PORT=5000 \
|
|
GPU_TYPE=intel
|
|
|
|
# Expose dashboard port
|
|
EXPOSE 5000
|
|
|
|
# Health check
|
|
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
|
|
CMD wget --quiet --tries=1 --spider http://localhost:5000/api/health || exit 1
|
|
|
|
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
|
|
CMD ["dashboard"]
|