File size: 2,265 Bytes
96c346b 8c61f1a 2718526 96c346b 428a953 96c346b 2718526 b7ed1b3 428a953 b7ed1b3 96c346b 428a953 2718526 96c346b 428a953 96c346b 428a953 96c346b 428a953 96c346b 428a953 96c346b 428a953 96c346b b104291 96c346b 8c61f1a 428a953 dde337b b7ed1b3 96c346b b104291 96c346b b104291 428a953 96c346b b7ed1b3 96c346b 2718526 96c346b 428a953 b7ed1b3 96c346b b7ed1b3 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | # Dockerfile simplificado y robusto para Hugging Face Spaces
FROM python:3.10-slim
# Variables de entorno
ENV DEBIAN_FRONTEND=noninteractive
ENV PYTHONUNBUFFERED=1
ENV PYTHONDONTWRITEBYTECODE=1
# Directorio de trabajo
WORKDIR /app
# Instalar dependencias del sistema críticas
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
gcc \
g++ \
make \
pkg-config \
python3-dev \
libffi-dev \
libssl-dev \
libcurl4-openssl-dev \
ca-certificates \
ffmpeg \
git \
git-lfs \
curl \
wget \
cargo \
rustc \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Instalar Rust para curl-cffi
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
ENV PATH="/root/.cargo/bin:${PATH}"
# Actualizar pip
RUN pip install --no-cache-dir --upgrade pip setuptools wheel
# Instalar dependencias críticas en orden
RUN pip install --no-cache-dir certifi requests brotli websockets
# Instalar curl-cffi específicamente
RUN pip install --no-cache-dir curl-cffi
# Instalar yt-dlp con curl-cffi
RUN pip install --no-cache-dir "yt-dlp[default,curl-cffi]"
# Crear usuario
RUN useradd -m -u 1000 user
# Configurar directorios
RUN mkdir -p /app/.cache /app/.config
RUN chown -R user:user /app
# Variables de entorno para el usuario
ENV HF_HOME="/app/.cache"
ENV MPLCONFIGDIR="/app/.cache"
# Cambiar a usuario
USER user
# Copiar requirements y instalar resto de dependencias
COPY --chown=user:user requirements.txt .
RUN pip install --no-cache-dir --user -r requirements.txt
# Configurar yt-dlp
RUN mkdir -p ~/.config/yt-dlp
RUN echo "--user-agent 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36'" > ~/.config/yt-dlp/config
RUN echo "--sleep-interval 3" >> ~/.config/yt-dlp/config
RUN echo "--geo-bypass" >> ~/.config/yt-dlp/config
# Copiar aplicación
COPY --chown=user:user app.py .
# Script de inicio simple
RUN echo '#!/bin/bash\necho "🚀 Starting App..."\necho "yt-dlp: $(yt-dlp --version)"\npython app.py' > start.sh && chmod +x start.sh
# Puerto
EXPOSE 7860
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=20s --retries=3 \
CMD curl -f http://localhost:7860/ || exit 1
# Ejecutar
CMD ["./start.sh"] |