# harbor-llm — Dockerfile
# Builds av/harbor — LLM orchestrator CLI (2.9k★)
# CLI tool pattern — `harbor up/down` for managing LLM backends via Docker
# Requires Docker socket access (mounted in docker-compose.yml by T03)

FROM python:3.12-slim

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

WORKDIR /app

# Clone upstream harbor
RUN git clone --depth 1 https://github.com/av/harbor.git /tmp/harbor && \
    cp -r /tmp/harbor/* /app/ && \
    rm -rf /tmp/harbor

# Install harbor CLI and dependencies
RUN pip install --no-cache-dir \
    fastapi \
    uvicorn && \
    if [ -f pyproject.toml ]; then \
        pip install --no-cache-dir . 2>/dev/null || \
        echo "WARN: pyproject install had warnings — continuing"; \
    elif [ -f setup.py ]; then \
        pip install --no-cache-dir . 2>/dev/null || \
        echo "WARN: setup.py install had warnings — continuing"; \
    elif [ -f requirements.txt ]; then \
        pip install --no-cache-dir -r requirements.txt 2>/dev/null || \
        echo "WARN: requirements.txt install had warnings — continuing"; \
    fi

EXPOSE 8000

ENV HARBOR_LLM_PORT=8000

# NOTE: Harbor requires Docker socket access — mount /var/run/docker.sock at runtime
# This is configured in the docker-compose.yml generated by T03.

COPY scripts/dockerfiles/harbor-llm/server.py /app/server.py

CMD python3 /app/server.py
