FROM python:3.11-slim # SO deps necesarias para audio/vídeo/OCR RUN apt-get update && apt-get install -y --no-install-recommends \ ffmpeg libsndfile1 libsm6 libxext6 libgl1 tesseract-ocr build-essential sqlite3 libsqlite3-dev \ && rm -rf /var/lib/apt/lists/* WORKDIR /app # Crear directorios para caché y dar permisos RUN mkdir -p /app/data/.cache /app/data/.deepface /app/data/.config/matplotlib \ && chmod -R 777 /app/data # Variables de entorno para que librerías escriban en /app/data ENV HOME=/app/data \ DEEPFACE_HOME=/app/data/.deepface \ MPLCONFIGDIR=/app/data/.config/matplotlib \ TRANSFORMERS_CACHE=/app/data/.cache/huggingface \ HF_HOME=/app/data/.cache/huggingface \ XDG_CACHE_HOME=/app/data/.cache \ PORT=7860 # Mejora estabilidad de instalación de wheels RUN pip install --no-cache-dir --upgrade pip setuptools wheel # Instala deps primero (mejor cacheo) COPY requirements.txt /app/ RUN pip install --no-cache-dir -r requirements.txt # Copia el código COPY . /app # Lanza FastAPI CMD ["uvicorn", "api:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "1"]