FROM localhost/base:latest

ARG CLAUDE_VERSION=2.1.218
ARG CLAUDE_SHA256=e12071751a9336b8af1012c103358ff04ac18f9aaff4a738cff7ba5cdfaf63f2

USER root

# nodejs is needed by Claude Code
RUN microdnf install -y --nodocs nodejs npm && microdnf clean all

RUN curl -fsSL -o /usr/bin/claude \
        "https://downloads.claude.ai/claude-code-releases/${CLAUDE_VERSION}/linux-x64/claude" \
    && echo "${CLAUDE_SHA256}  /usr/bin/claude" | sha256sum -c - \
    && chmod +x /usr/bin/claude

RUN mkdir -p /home/agent-ci/.claude \
    && ln -s ../AGENTS.md /home/agent-ci/.claude/CLAUDE.md \
    && chown -R agent-ci:agent-ci /home/agent-ci/.claude

USER agent-ci

# Build plugin seed using native Claude Code CLI.
# Force HTTPS for GitHub clones (no SSH keys during build); the override
# is removed at the end of the same RUN so the final layer has clean
# git config.
RUN git config --global url."https://github.com/".insteadOf "git@github.com:" \
    && export CLAUDE_CONFIG_DIR=/home/agent-ci/.claude \
    && export CLAUDE_CODE_PLUGIN_CACHE_DIR=/home/agent-ci/.claude-seed \
    && export DISABLE_AUTOUPDATER=1 \
    && claude plugin marketplace add opendatahub-io/skills-registry \
    && agentic-ci install-plugins \
    && git config --global --unset-all url."https://github.com/".insteadOf

ENV CLAUDE_CODE_PLUGIN_SEED_DIR=/home/agent-ci/.claude-seed
ENV CLAUDE_CODE_SYNC_PLUGIN_INSTALL=1
ENV DISABLE_AUTOUPDATER=1
ENV AGENT_TOOL=claude
ENV CLAUDE_CONFIG_DIR=/home/agent-ci/.claude
WORKDIR /home/agent-ci
ENTRYPOINT ["entrypoint.sh"]
CMD ["claude"]
