FROM python:3.13-slim

WORKDIR /app

# System dependencies
RUN apt-get update && apt-get install -y \
    gcc \
    g++ \
    make \
    && rm -rf /var/lib/apt/lists/*

# Install llama.cpp for efficient inference
RUN pip install --no-cache-dir \
    llama-cpp-python \
    flask \
    flask-cors \
    waitress \
    requests

# Copy application
COPY inference/ /app/
COPY model/ /app/model/

# Expose web interface
EXPOSE 8080

# Health check
HEALTHCHECK --interval=30s --timeout=10s --retries=3 \
    CMD curl -f http://localhost:8080/health || exit 1

CMD ["python", "/app/server.py"]