File size: 1,095 Bytes
cca9b49 3e10f09 cca9b49 3e10f09 cca9b49 500c084 cca9b49 | 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 | 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"]
|