# waggle v0.3 — Python orchestrator owns the runtime; claude is spawned as
# its own subprocess in stream-json mode. claude loads waggle's tools_server
# (also Python, in this same image) via --mcp-config to handle outbound.

FROM python:3.12-slim AS waggle

RUN apt-get update \
 && apt-get install -y --no-install-recommends curl ca-certificates tini \
 && curl -fsSL https://deb.nodesource.com/setup_22.x | bash - \
 && apt-get install -y --no-install-recommends nodejs \
 && rm -rf /var/lib/apt/lists/*

RUN npm install -g @anthropic-ai/claude-code \
 && rm -rf /root/.npm

RUN groupadd --gid 1000 node \
 && useradd  --uid 1000 --gid 1000 --create-home --shell /bin/bash node

WORKDIR /app
COPY pyproject.toml README.md ./
COPY waggle/ waggle/
RUN pip install --no-cache-dir .[telegram]

RUN mkdir -p /home/node/workspace \
 && chown -R node:node /home/node /app

USER 1000:1000
WORKDIR /home/node/workspace

ENV CLAUDE_CODE_SKIP_ONBOARDING=1 \
    CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1 \
    NO_COLOR=1 \
    TERM=dumb \
    LANG=C.UTF-8

ENTRYPOINT ["/usr/bin/tini", "--", "python", "-m", "waggle.cli"]
CMD ["-c", "/etc/waggle/config.yaml", "-v"]
