FROM python:3.11-slim

WORKDIR /app

RUN apt-get update && apt-get install -y --no-install-recommends \
    gcc \
    && rm -rf /var/lib/apt/lists/*

# Instalar MiroFlow e suas dependências direto do submodule
COPY server/modules/miroflow/ ./server/modules/miroflow/
RUN pip install --no-cache-dir -e ./server/modules/miroflow/

# Copiar o service script
COPY server/python/miroflow_service.py ./server/python/miroflow_service.py

ENV MIROFLOW_PORT=8006
ENV OLLAMA_BASE_URL=http://host.docker.internal:11434

EXPOSE 8006

HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \
  CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:8006/health')" || exit 1

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