FROM python:3.11-slim # Set environment variables for Hugging Face ENV PYTHONUNBUFFERED=1 ENV PORT=7860 WORKDIR /app # Install system dependencies RUN apt-get update && apt-get install -y \ build-essential \ libpq-dev \ && rm -rf /var/lib/apt/lists/* # Copy requirements and install dependencies COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # Copy the rest of the application code COPY . . # Hugging Face expects the app to run on port 7860 EXPOSE 7860 # Run the application CMD ["sh", "-c", "uvicorn app.main:app --host 0.0.0.0 --port ${PORT}"]