Spaces:
Sleeping
Sleeping
File size: 955 Bytes
336490c | 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 | # Use a slim Python image for the production environment
FROM python:3.9-slim
# Set working directory
WORKDIR /app
# Install system dependencies for OpenCV and YOLO
RUN apt-get update && apt-get install -y --no-install-recommends \
ffmpeg \
libsm6 \
libxext6 \
libgl1 \
&& rm -rf /var/lib/apt/lists/*
# Copy dependency list
COPY requirements.txt .
# Install dependencies
RUN pip install --no-cache-dir -r requirements.txt
# Copy the YOLO model and application code
COPY yolo11n.pt .
COPY fastapi_app.py .
# Create a non-root user for security (required by Hugging Face)
RUN useradd -m -u 1000 user
USER user
ENV HOME=/home/user \
PATH=/home/user/.local/bin:$PATH
WORKDIR $HOME/app
COPY --chown=user . $HOME/app
# Hugging Face uses port 7860 by default
EXPOSE 7860
# Command to run the FastAPI app with Uvicorn
CMD ["uvicorn", "fastapi_app:app", "--host", "0.0.0.0", "--port", "7860"]
|