FROM quay.io/fedora/fedora:latest

# Install Node.js, NPM, Python 3, development tools, and RPM tools
RUN dnf install -y nodejs \
	npm \
    python3 \
    python3-devel \
    fedora-packager \
    fedora-review \
    mock \
    rpm-build \
    rpmdevtools \
    curl \
    git \
    make \
    shellcheck \
    which \
    && dnf clean all


RUN echo '[google-cloud-cli]' > /etc/yum.repos.d/google-cloud-sdk.repo && \
echo 'name=Google Cloud CLI' >> /etc/yum.repos.d/google-cloud-sdk.repo && \
echo 'baseurl=https://packages.cloud.google.com/yum/repos/cloud-sdk-el10-$basearch' >> /etc/yum.repos.d/google-cloud-sdk.repo && \
echo 'enabled=1' >> /etc/yum.repos.d/google-cloud-sdk.repo && \
echo 'gpgcheck=1' >> /etc/yum.repos.d/google-cloud-sdk.repo && \
echo 'repo_gpgcheck=0' >> /etc/yum.repos.d/google-cloud-sdk.repo && \
echo 'gpgkey=https://packages.cloud.google.com/yum/doc/rpm-package-key-v10.gpg' >> /etc/yum.repos.d/google-cloud-sdk.repo && \
dnf install -y google-cloud-cli && \
dnf clean all

# Install uv for PEP 723 script dependency management
RUN curl -LsSf https://astral.sh/uv/install.sh | UV_INSTALL_DIR="/usr/local/bin/" INSTALLER_NO_MODIFY_PATH=1 sh

# Install OpenShift client (oc)
RUN curl -LsSf https://mirror.openshift.com/pub/openshift-v4/clients/ocp/stable/openshift-client-linux.tar.gz | tar xzf - -C /usr/local/bin/ oc \
    && chmod +x /usr/local/bin/oc

# Install common Python tools
RUN uv pip install --system --no-cache \
    pytest \
    requests \
    pyyaml \
    ruff \
    tox \
    tox-uv

# Create cursor user
RUN useradd -m -u 1000 -s /bin/bash cursor

# Copy ai-helpers repository to /opt/ai-helpers
COPY . /opt/ai-helpers
RUN chown -R cursor:cursor /opt/ai-helpers

# Switch to cursor user
USER cursor

# Install Cursor CLI
RUN curl -fsSL https://cursor.com/install | bash

# Install ai-helpers skills, commands, and agents for Cursor
RUN mkdir -p /home/cursor/.cursor/skills /home/cursor/.cursor/commands && \
    ln -s /opt/ai-helpers/helpers/skills/* /home/cursor/.cursor/skills/ && \
    ln -s /opt/ai-helpers/helpers/commands/* /home/cursor/.cursor/commands/ && \
    ln -s /opt/ai-helpers/helpers/agents/* /home/cursor/.cursor/skills/

# Set Cursor Agent CLI as the default command
# --trust: skip workspace trust prompt
# --print: output to stdout for non-interactive container use
ENTRYPOINT ["/home/cursor/.local/bin/agent", "--trust", "--print"]
