ARG DEBIAN_VERSION=stable-slim # ========================================== # Stage 1: Runtime (Fully Cached) # ========================================== FROM debian:${DEBIAN_VERSION} AS base RUN apt-get update && apt-get install -y --no-install-recommends \ ffmpeg python3 python3-pip python3-venv curl ca-certificates unzip \ && rm -rf /var/lib/apt/lists/* # Virtualenv so pip doesn't clash with Debian's system Python. # yt-dlp and the bgutil plugin MUST live in the same environment # for entry-point plugin discovery to work. RUN python3 -m venv /opt/venv ENV PATH="/opt/venv/bin:${PATH}" # Version pins matter here: # - curl-cffi < 0.16 : yt-dlp's impersonation bridge rejects newer # releases as "unsupported" and silently disables # browser fingerprinting. # - yt-dlp-get-pot is intentionally OMITTED. That package is archived # and its last release (0.3.0) predates the built-in PO Token # provider framework in yt-dlp >= 2025.05.22. The bgutil plugin # now registers directly with yt-dlp; installing the old framework # would conflict with the built-in one. # - bgutil-ytdlp-pot-provider >= 1.3 : HTTP mode support, compatible # with yt-dlp's built-in PO Token provider framework. RUN pip install --no-cache-dir --upgrade pip && \ pip install --no-cache-dir \ "curl-cffi>=0.10,<0.16" \ requests \ yt-dlp \ "bgutil-ytdlp-pot-provider>=1.3" # ========================================== # Stage 2: Fetcher (Cache busted for deno only) # ========================================== FROM alpine:latest AS fetcher ARG TARGETARCH RUN apk add --no-cache curl unzip # Declaring CACHE_BUST and referencing it inside the RUN forces # Docker to rebuild the download layer on every build. ARG CACHE_BUST RUN echo "Cache bust: ${CACHE_BUST}" && \ DETECTED_ARCH="${TARGETARCH:-$(uname -m)}" && \ if [ "$DETECTED_ARCH" = "amd64" ] || [ "$DETECTED_ARCH" = "x86_64" ]; then \ D_ARCH="x86_64"; \ else \ D_ARCH="aarch64"; \ fi && \ curl -fsSL "https://github.com/denoland/deno/releases/latest/download/deno-${D_ARCH}-unknown-linux-gnu.zip" -o /deno.zip && \ unzip /deno.zip -d / && chmod a+rx /deno # ========================================== # Stage 3: Final # ========================================== FROM base AS final COPY --from=fetcher /deno /usr/local/bin/deno # Fallback for the bgutil HTTP plugin when no extractor-arg is forwarded. # Both this and the --extractor-args in tuber.py point at the same server. ENV BGW_HTTP_BASE_URL="http://pot:4416" ENV XDG_CONFIG_HOME=/dev/shm/yt-dlp/config ENV XDG_CACHE_HOME=/dev/shm/yt-dlp/cache