# ============================================================================= # Docker Space for the YouTube Translator & Speaker. # Bakes in a PINNED deno JS runtime + Python deps so there is NO runtime # curl|sh install, no cold-start download penalty, and no unpinned drift. # ============================================================================= FROM python:3.11-slim # --- System deps: curl (to fetch deno once, at build time) + certs + unzip --- RUN apt-get update && apt-get install -y --no-install-recommends \ curl ca-certificates unzip \ && rm -rf /var/lib/apt/lists/* # --- Install a PINNED deno version into a system path ------------------------- # deno is required by yt-dlp to solve YouTube's JS "n-challenge". ENV DENO_VERSION=2.9.3 ENV DENO_INSTALL=/usr/local RUN curl -fsSL https://deno.land/install.sh | sh -s "v${DENO_VERSION}" \ && deno --version # --- Hugging Face Spaces runs as a non-root user (uid 1000) ------------------- RUN useradd -m -u 1000 user ENV HOME=/home/user \ PATH=/home/user/.local/bin:$PATH \ # yt-dlp / EJS cache + HF model cache in a writable location HF_HOME=/home/user/.cache/huggingface \ XDG_CACHE_HOME=/home/user/.cache WORKDIR /home/user/app # --- Python deps (pinned) ----------------------------------------------------- COPY --chown=user:user requirements.txt . RUN pip install --no-cache-dir --upgrade pip \ && pip install --no-cache-dir -r requirements.txt # --- App code ----------------------------------------------------------------- COPY --chown=user:user app.py . # Ensure the working directory is writable by the runtime user. Gradio (and # some libs) may create files/dirs in the cwd at startup (e.g. a 'flagged/' # dir), which fails if the dir is root-owned. RUN chown -R user:user /home/user/app USER user # Gradio must bind 0.0.0.0:7860 for HF Spaces to route to it. EXPOSE 7860 ENV GRADIO_SERVER_NAME=0.0.0.0 \ GRADIO_SERVER_PORT=7860 CMD ["python", "app.py"]