Spaces:
Sleeping
Sleeping
# Use an official Python runtime as the base image | |
FROM python:3.9-slim | |
# Install system dependencies as root (including git for cloning repositories) | |
RUN apt-get update && apt-get install -y \ | |
libavformat-dev libavcodec-dev libavdevice-dev libavutil-dev \ | |
libswscale-dev libswresample-dev libavfilter-dev \ | |
git \ | |
&& rm -rf /var/lib/apt/lists/* | |
# Create a non-root user (Hugging Face Spaces requirement) | |
RUN useradd -m -u 1000 user | |
USER user | |
WORKDIR /app | |
ENV PATH="/home/user/.local/bin:$PATH" | |
# Copy requirements.txt and install dependencies | |
COPY --chown=user ./requirements.txt requirements.txt | |
RUN pip install --no-cache-dir --upgrade -r requirements.txt | |
# Copy the rest of the application files | |
COPY --chown=user . /app | |
# Expose the port (Hugging Face Spaces default is 7860) | |
EXPOSE 7860 | |
# Command to run the FastAPI app with Uvicorn | |
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"] |