# Use an official lightweight Python image FROM python:3.11-slim # Create a non-root user for Hugging Face Spaces compatibility RUN useradd -m -u 1000 user USER user ENV PATH="/home/user/.local/bin:" # Set working directory WORKDIR /app # Copy all files into the container, changing ownership COPY --chown=user . /app/ # Set working directory to the API directory WORKDIR /app/services/governance-gateway # Set Hugging Face cache to the user's home directory so models can download ENV HF_HOME="/home/user/.cache/huggingface" ENV TRANSFORMERS_CACHE="/home/user/.cache/huggingface" # Install requirements RUN pip install --no-cache-dir -r requirements.txt # Expose port 7860 which Hugging Face Spaces requires EXPOSE 7860 # Run the FastAPI server on port 7860 CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]