# PentestAgent Kali Linux Image
# Full penetration testing environment

FROM kalilinux/kali-rolling

LABEL maintainer="Masic"
LABEL description="PentestAgent with Kali Linux tools"

# Set environment variables
ENV DEBIAN_FRONTEND=noninteractive
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1

# Update and install Kali tools
RUN apt-get update && apt-get install -y --no-install-recommends \
    # Python (python3-full includes venv with ensurepip)
    python3-full \
    python3-pip \
    # Kali meta-packages (selective for size)
    kali-tools-web \
    kali-tools-information-gathering \
    kali-tools-vulnerability \
    kali-tools-exploitation \
    # Additional tools
    nmap \
    nikto \
    dirb \
    gobuster \
    sqlmap \
    wpscan \
    hydra \
    john \
    hashcat \
    metasploit-framework \
    burpsuite \
    zaproxy \
    nuclei \
    ffuf \
    # Network tools
    openvpn \
    wireguard \
    proxychains4 \
    tor \
    # Utilities
    curl \
    wget \
    git \
    vim \
    tmux \
    jq \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/*

# Create app directory
WORKDIR /app

# Install Python dependencies using virtual environment (PEP 668 compliance)
COPY requirements.txt .
RUN python3 -m venv /opt/venv && \
    /opt/venv/bin/pip install --no-cache-dir --upgrade pip wheel setuptools

# Install heavy dependencies first (helps with CI memory limits)
RUN /opt/venv/bin/pip install --no-cache-dir torch --index-url https://download.pytorch.org/whl/cpu
RUN /opt/venv/bin/pip install --no-cache-dir sentence-transformers faiss-cpu
RUN /opt/venv/bin/pip install --no-cache-dir -r requirements.txt

# Add venv to PATH
ENV PATH="/opt/venv/bin:$PATH"

# Copy application code
COPY . .

# Copy common wordlists
RUN mkdir -p /wordlists && \
    cp -r /usr/share/wordlists/* /wordlists/ 2>/dev/null || true

# Set permissions
RUN chmod +x /app/scripts/*.sh 2>/dev/null || true

# Entry point
COPY docker-entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh

ENTRYPOINT ["/entrypoint.sh"]
CMD ["python3", "-m", "pentestagent"]
