ARG BASE_IMAGE=investibook-backend-base:latest
FROM ${BASE_IMAGE}

# Node.js 20 (required by Claude CLI)
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && \
    apt-get install -y --no-install-recommends nodejs && \
    rm -rf /var/lib/apt/lists/*

# Claude CLI
RUN npm install -g @anthropic-ai/claude-code && \
    mkdir -p /root/.claude && \
    touch /root/.claude/.terms-accepted

# Copy the repo from build context (CI has already checked out the code)
COPY . /app/repo

WORKDIR /app/repo

COPY deployment/evolver/entrypoint.sh /app/entrypoint.sh
COPY deployment/evolver/webhook_server.py /app/webhook_server.py
RUN chmod +x /app/entrypoint.sh

EXPOSE 8080

ENTRYPOINT ["/app/entrypoint.sh"]
