FROM python:3.11.9-slim # Install necessary system packages RUN apt-get update && apt-get install -y \ build-essential \ libpq-dev \ gcc \ && rm -rf /var/lib/apt/lists/* WORKDIR /app # Upgrade pip RUN pip install --upgrade pip # Copy requirements and install dependencies COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # Create cache directory for Hugging Face Transformers ENV TRANSFORMERS_CACHE=/tmp/huggingface_cache RUN mkdir -p /tmp/huggingface_cache && chmod 777 /tmp/huggingface_cache # Copy application code COPY . . # Set permissions for Hugging Face Space (requires non-root user or open permissions for /app/data if any) RUN chmod -R 777 /app # Run migrations and start FastAPI server CMD uvicorn server:app --host 0.0.0.0 --port 7860