TubeScript-API/Dockerfile.api
Cesar Mendivil 2923510c51 Add Playwright tools for extracting M3U8 URLs and proxy management
- Introduced `playwright_extract_m3u8.py` to extract M3U8 URLs from YouTube videos using Playwright.
- Added `README_PLAYWRIGHT.md` for usage instructions and requirements.
- Created `expand_and_test_proxies.py` to expand user-provided proxies and test their validity.
- Implemented `generate_proxy_whitelist.py` to generate a whitelist of working proxies based on testing results.
- Added sample proxy files: `user_proxies.txt` for user-defined proxies and `proxies_sample.txt` as a template.
- Generated `expanded_proxies.txt`, `whitelist.json`, and `whitelist.txt` for storing expanded and valid proxies.
- Included error handling and logging for proxy testing results.
2026-03-17 00:29:51 -07:00

46 lines
1.5 KiB
Docker

# Dockerfile para la API (FastAPI) con yt-dlp y ffmpeg
FROM python:3.11-slim
ENV PYTHONUNBUFFERED=1
# Instalar ffmpeg, Node.js 20 LTS y herramientas necesarias
# Node.js es requerido por yt-dlp --js-runtimes para resolver n-challenge/signature de YouTube
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
ffmpeg \
curl \
ca-certificates \
gnupg \
&& curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
&& apt-get install -y --no-install-recommends nodejs \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Copiar requirements y instalar dependencias Python
COPY requirements.txt /app/requirements.txt
RUN pip install --no-cache-dir -r /app/requirements.txt
# Instalar yt-dlp desde el binario oficial más reciente (no pip) para siempre tener la última versión
RUN curl -L https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp -o /usr/local/bin/yt-dlp \
&& chmod a+rx /usr/local/bin/yt-dlp
# ARG para invalidar caché del COPY al hacer rebuild con --build-arg CACHEBUST=$(date +%s)
ARG CACHEBUST=1
# Copiar el resto del código
COPY . /app
# Crear carpeta data con permisos abiertos para que cualquier UID pueda leer/escribir
RUN mkdir -p /app/data && chmod 777 /app/data
# Crear usuario appuser (UID 1000) y darle acceso a /app
RUN groupadd -g 1000 appgroup && useradd -u 1000 -g appgroup -s /bin/sh appuser \
&& chown -R appuser:appgroup /app
USER appuser
EXPOSE 8000
# Comando para ejecutar la API
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]