FROM python:3.12-slim

LABEL org.opencontainers.image.title="sofiia-supervisor"
LABEL org.opencontainers.image.description="LangGraph Supervisor Service for DAARION.city"

WORKDIR /app

# System deps (curl for healthcheck)
RUN apt-get update && apt-get install -y --no-install-recommends curl && \
    rm -rf /var/lib/apt/lists/*

# Python deps
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# Source
COPY app/ ./app/

# Non-root user
RUN useradd -m -u 1001 supervisor && chown -R supervisor:supervisor /app
USER supervisor

EXPOSE 8080

HEALTHCHECK --interval=30s --timeout=10s --start-period=15s --retries=3 \
    CMD curl -sf http://localhost:8080/healthz || exit 1

CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8080", "--workers", "1"]
