Spaces:
Sleeping
Sleeping
| # Use official Python image with a slim footprint | |
| FROM python:3.10-slim | |
| # Set the working directory inside the container | |
| WORKDIR /app | |
| # Install system dependencies (required for some Python ML packages and OpenCV if needed later) | |
| RUN apt-get update && apt-get install -y \ | |
| build-essential \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Create a non-root user required by Hugging Face Spaces | |
| RUN useradd -m -u 1000 user | |
| # Copy requirements first to leverage Docker cache | |
| COPY requirements.txt . | |
| # Install Python dependencies | |
| # We use --no-cache-dir to keep the image size small | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # Copy the rest of the application code | |
| COPY . . | |
| # Create the storage directories explicitly and ensure appropriate permissions | |
| RUN mkdir -p /app/storage/uploads /app/storage/processed | |
| RUN chown -R user:user /app | |
| # Switch to the non-root user | |
| USER user | |
| # Hugging Face Spaces exposes port 7860 by default | |
| EXPOSE 7860 | |
| # Start the FastAPI application | |
| # Hugging Face expects the server to run on 0.0.0.0:7860 | |
| CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"] | |