# Use an official Python runtime as a parent image FROM python:3.10-slim # Set environment variables ENV PYTHONUNBUFFERED=1 \ PORT=7860 # Set the working directory in the container WORKDIR /app # Install system dependencies required for OpenCV and scientific Python libraries RUN apt-get update && apt-get install -y --no-install-recommends \ build-essential \ libgl1 \ libglib2.0-0 \ libxcb1 \ libhdf5-dev \ libnetcdf-dev \ && rm -rf /var/lib/apt/lists/* # Copy the requirements file into the container COPY requirements.txt . # Install Python dependencies RUN pip install --no-cache-dir -r requirements.txt # Copy the rest of the application code COPY . . # Expose the port Hugging Face Spaces expects EXPOSE 7860 # Command to run the FastAPI application CMD ["uvicorn", "api.main:app", "--host", "0.0.0.0", "--port", "7860"]