# CmdForge - AI-powered CLI command builder
# Build: docker build -t cmdforge .
# Run:   docker run -it --rm -v ~/.cmdforge:/root/.cmdforge cmdforge

FROM python:3.12-slim

LABEL maintainer="rob"
LABEL description="CmdForge - Personal AI-powered CLI command builder"

# Install system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
    git \
    curl \
    # Node.js for Claude CLI
    nodejs \
    npm \
    # Browser for OAuth authentication
    firefox-esr \
    # xdg-open for opening URLs (used by Claude CLI)
    xdg-utils \
    # Qt/PySide6 dependencies (complete set)
    libgl1 \
    libegl1 \
    libglib2.0-0 \
    libfontconfig1 \
    libfreetype6 \
    libx11-6 \
    libx11-xcb1 \
    libxext6 \
    libxrender1 \
    libxcb1 \
    libxcb-cursor0 \
    libxcb-glx0 \
    libxcb-icccm4 \
    libxcb-image0 \
    libxcb-keysyms1 \
    libxcb-randr0 \
    libxcb-render0 \
    libxcb-render-util0 \
    libxcb-shape0 \
    libxcb-shm0 \
    libxcb-sync1 \
    libxcb-xfixes0 \
    libxcb-xinerama0 \
    libxcb-xkb1 \
    libxkbcommon0 \
    libxkbcommon-x11-0 \
    libxkbfile1 \
    libdbus-1-3 \
    libxcomposite1 \
    libxdamage1 \
    libxi6 \
    libxrandr2 \
    libxtst6 \
    libnss3 \
    libasound2 \
    libpulse0 \
    && rm -rf /var/lib/apt/lists/*

# Set working directory
WORKDIR /app

# Copy project files
COPY pyproject.toml README.md ./
COPY src/ ./src/
COPY examples/ ./examples/
COPY tests/ ./tests/

# Install CmdForge and all dependencies (CLI, TUI, registry)
RUN pip install --no-cache-dir -e ".[all,dev]"

# Create cmdforge directory
RUN mkdir -p /root/.cmdforge /root/.local/bin

# Install example tools
RUN python examples/install.py

# Generate CLI wrappers
RUN cmdforge refresh

# Add local bin to PATH
ENV PATH="/root/.local/bin:${PATH}"

# Default command - show help
CMD ["cmdforge", "--help"]

# For interactive use:
# docker run -it --rm cmdforge cmdforge ui
# docker run -it --rm cmdforge bash
