# File : Dockerfile # Purpose : Combined FastAPI + Streamlit in one container for HF Spaces FROM python:3.11-slim WORKDIR /app # System dependencies RUN apt-get update && apt-get install -y \ build-essential \ libpq-dev \ curl \ && rm -rf /var/lib/apt/lists/* # Install Python dependencies COPY requirements.txt . RUN pip install --no-cache-dir --upgrade pip && \ pip install --no-cache-dir -r requirements.txt && \ pip install --no-cache-dir streamlit # Copy application code COPY app/ ./app/ COPY streamlit_app.py . # Hugging Face Spaces runs as non-root user 1000 RUN useradd -m -u 1000 appuser && chown -R appuser:appuser /app USER appuser # Expose port 7860 (HF Spaces requirement) EXPOSE 7860 CMD ["/bin/bash", "-c", "uvicorn app.main:app --host 0.0.0.0 --port 8000 & sleep 5 && streamlit run streamlit_app.py --server.port 7860 --server.address 0.0.0.0"]