FROM python:3.11-slim

WORKDIR /app

# Node.js + Claude Code CLI (AI_PROVIDER=claude_code 테스트 모드용 — `claude -p` 헤드리스 호출)
RUN apt-get update && apt-get install -y --no-install-recommends curl ca-certificates git \
    && curl -fsSL https://deb.nodesource.com/setup_22.x | bash - \
    && apt-get install -y --no-install-recommends nodejs \
    && npm install -g @anthropic-ai/claude-code \
    && apt-get purge -y curl && apt-get autoremove -y && rm -rf /var/lib/apt/lists/*

# Python 의존성 설치
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# 애플리케이션 코드 복사
COPY . .

# claude CLI는 root 실행 시 일부 기능 제한 → 전용 사용자로 실행
RUN useradd -m -u 1000 mcp && chown -R mcp:mcp /app
USER mcp
ENV HOME=/home/mcp

# 포트 노출
EXPOSE 8001

# 애플리케이션 실행
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8001"]
