Spaces:
Sleeping
Sleeping
| # Use a lightweight Python base image | |
| FROM python:3.9-slim | |
| # Set working directory | |
| WORKDIR /code | |
| # Install system dependencies required for OpenCV | |
| # libgl1-mesa-glx and libglib2.0-0 are critical for cv2 to work in Docker | |
| RUN apt-get update && apt-get install -y \ | |
| libgl1\ | |
| libglib2.0-0 \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Copy requirements file first to leverage Docker caching | |
| COPY requirements.txt . | |
| # Install Python dependencies | |
| # We use the CPU version of PyTorch to keep the image size small for deployment | |
| RUN pip install --no-cache-dir --upgrade -r requirements.txt | |
| # Copy the application code and the model | |
| COPY . . | |
| # Create a non-root user (Hugging Face security requirement) | |
| RUN useradd -m -u 1000 user | |
| USER user | |
| ENV HOME=/home/user \ | |
| PATH=/home/user/.local/bin:$PATH | |
| # Expose the port Hugging Face expects | |
| EXPOSE 7860 | |
| # Command to run the application | |
| CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"] |