FROM node:22-bookworm-slim

# System deps + Python (claude code is npm; our wrapper is Python)
RUN apt-get update && apt-get install -y --no-install-recommends \
        python3 python3-pip python3-venv \
        ca-certificates curl git \
    && rm -rf /var/lib/apt/lists/*

# Claude Code CLI
RUN npm install -g @anthropic-ai/claude-code

# Python deps in a venv
ENV VIRTUAL_ENV=/opt/venv
RUN python3 -m venv $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"

WORKDIR /app
COPY requirements.txt /app/requirements.txt
RUN pip install --no-cache-dir -r requirements.txt

COPY clawdforge /app/clawdforge

# Persistent volume mount points:
#   /data            -> sqlite + runs staging
#   /root/.claude    -> claude code auth (cobb runs `claude /login` once per container)
#   /root/.config/claude -> alt config path some claude versions use
RUN mkdir -p /data /root/.claude /root/.config/claude

EXPOSE 8800

CMD ["uvicorn", "clawdforge.server:app", \
     "--host", "0.0.0.0", "--port", "8800", \
     "--workers", "1", \
     "--proxy-headers", \
     "--access-log"]
