FROM python:3.10-slim # Set environment variables ENV PYTHONUNBUFFERED=1 \ PYTHONDONTWRITEBYTECODE=1 \ PORT=7860 # Create a non-root user with UID 1000 to comply with Hugging Face Spaces requirements RUN useradd -m -u 1000 user # Set up working directory WORKDIR /home/user/app # Install basic system dependencies and aria2 for BitTorrent downloads RUN apt-get update && apt-get install -y --no-install-recommends \ curl \ git \ aria2 \ && rm -rf /var/lib/apt/lists/* # Install python dependencies directly RUN pip install --no-cache-dir fastapi uvicorn requests huggingface_hub python-multipart telethon # Copy the rest of the application files and set ownership to 'user' COPY --chown=user:user . . # Create local data directory and set permissions RUN mkdir -p /home/user/app/data && chown -R user:user /home/user/app/data # Switch to the non-root user USER user # Expose port 7860 (Hugging Face Spaces default) EXPOSE 7860 # Command to run the application using uvicorn CMD ["python", "-m", "uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]