FROM ubuntu:22.04

ENV DEBIAN_FRONTEND=noninteractive

# ── System packages ────────────────────────────────────────────────────────────
RUN apt-get update -qq && apt-get install -y -qq \
    # Basics
    curl wget git ca-certificates gnupg lsb-release unzip zip tar gzip \
    # Python & Build headers (needed for PyInstaller shared libraries)
    python3 python3-pip python3-venv python3-dev libpython3-dev libffi-dev libssl-dev \
    # Java (for SpotBugs)
    default-jdk \
    # C/C++ analysis & Build tools
    clang clang-tidy cppcheck bear make cmake build-essential gcc binutils \
    # NSIS (for Windows setup installer cross-compilation)
    nsis nsis-common nsis-pluginapi \
    # Misc
    jq \
    && rm -rf /var/lib/apt/lists/*

# ── PowerShell ─────────────────────────────────────────────────────────────────
RUN curl -sSL https://packages.microsoft.com/config/ubuntu/22.04/packages-microsoft-prod.deb -o /tmp/packages-microsoft-prod.deb \
    && dpkg -i /tmp/packages-microsoft-prod.deb \
    && rm /tmp/packages-microsoft-prod.deb \
    && apt-get update -qq \
    && apt-get install -y -qq powershell \
    && rm -rf /var/lib/apt/lists/*

# ── PSScriptAnalyzer ───────────────────────────────────────────────────────────
RUN pwsh -Command "Install-Module -Name PSScriptAnalyzer -Force -Scope AllUsers"

# ── SpotBugs ───────────────────────────────────────────────────────────────────
RUN wget -q https://github.com/spotbugs/spotbugs/releases/download/4.8.6/spotbugs-4.8.6.tgz \
    -O /tmp/spotbugs.tgz \
    && tar -xf /tmp/spotbugs.tgz -C /opt/ \
    && rm /tmp/spotbugs.tgz \
    && ln -s /opt/spotbugs-4.8.6/bin/spotbugs /usr/local/bin/spotbugs

# ── Node (needed by act_runner internals) ─────────────────────────────────────
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
    && apt-get install -y -qq nodejs \
    && rm -rf /var/lib/apt/lists/*

# ── Python packages ────────────────────────────────────────────────────────────
RUN pip3 install --quiet --no-cache-dir \
    codechecker \
    pylint \
    pyflakes \
    vunit-hdl \
    # LOGAR Packaging & Dependencies
    pyinstaller \
    distlib \
    cryptography \
    pefile \
    cffi \
    pgpy \
    fastapi \
    uvicorn \
    pydantic \
    requests

# Runner runs as root inside the container
WORKDIR /workspace

CMD ["/bin/bash"]
