# 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 \
    # X11 libraries for display
    libx11-6 \
    libxext6 \
    libxrender1 \
    && 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
