Replace the direct Anthropic API call in score.py with a pluggable backend (BLAAAI_BACKEND=cli|api, default cli). The CLI path shells out to `claude -p` authed by CLAUDE_CODE_OAUTH_TOKEN, so scoring counts against the Claude subscription instead of API billing. - _call_cli forces a tool-free, JSON-only role (--append-system-prompt, --disallowed-tools) and retries the intermittently-failing `claude -p` - lower default concurrency (3) since each call spawns a heavy Node process - metrics use the CLI's reported total_cost_usd and full token load - batch failures no longer crash the whole scoring run - remove the hardcoded live ANTHROPIC_API_KEY fallback (rotate it in console) - Dockerfile installs Node + @anthropic-ai/claude-code - Nomad injects CLAUDE_CODE_OAUTH_TOKEN via Consul, bumps memory for Node
45 lines
1.2 KiB
Docker
45 lines
1.2 KiB
Docker
FROM python:3.12-slim
|
|
|
|
ARG BUILD_VERSION=unknown
|
|
ARG GIT_COMMIT=unknown
|
|
ARG BUILD_TIME=unknown
|
|
|
|
ENV PYTHONUNBUFFERED=1 \
|
|
PYTHONDONTWRITEBYTECODE=1 \
|
|
BUILD_VERSION=${BUILD_VERSION} \
|
|
GIT_COMMIT=${GIT_COMMIT} \
|
|
BUILD_TIME=${BUILD_TIME}
|
|
|
|
WORKDIR /app
|
|
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
curl \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
COPY requirements.txt .
|
|
RUN pip install --no-cache-dir -r requirements.txt
|
|
|
|
# Install Playwright browsers
|
|
RUN playwright install chromium && playwright install-deps chromium
|
|
|
|
# Install Node + the Claude CLI (used by the default BLAAAI_BACKEND=cli scoring path)
|
|
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
|
|
&& apt-get install -y --no-install-recommends nodejs \
|
|
&& npm install -g @anthropic-ai/claude-code \
|
|
&& npm cache clean --force \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Claude CLI needs a writable config dir; keep it on the mounted data volume
|
|
ENV CLAUDE_CONFIG_DIR=/app/data/.claude
|
|
|
|
COPY . .
|
|
|
|
RUN mkdir -p data static templates
|
|
|
|
EXPOSE 8000
|
|
|
|
HEALTHCHECK --interval=10s --timeout=5s --start-period=30s --retries=3 \
|
|
CMD curl -f http://localhost:${PORT:-8000}/health || exit 1
|
|
|
|
CMD ["sh", "-c", "uvicorn app:app --host 0.0.0.0 --port ${PORT:-8000}"]
|