FROM greeng340or/rust-dev-ubuntu

# Install required packages for librocksdb-sys, Python, Node.js, and search tools
RUN apt-get update && apt-get install -y \
    clang \
    libclang-dev \
    llvm-dev \
    python3 \
    python3-pip \
    python3-venv \
    curl \
    lsof \
    silversearcher-ag \
    ripgrep \
    && pip3 install build pdoc twine --break-system-packages \
    && curl -fsSL https://deb.nodesource.com/setup_lts.x | bash - \
    && apt-get install -y nodejs \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/*

# Install uv (fast Python package manager)
RUN curl -LsSf https://astral.sh/uv/install.sh | sh
ENV PATH="/root/.local/bin:$PATH"


# Note: Avoid installing a specific CPython via `uv python install ...` during image build.
# Those downloads are large and can fail transiently (e.g., GitHub 5xx), breaking devcontainer builds.
# We rely on the distro-provided python3 installed above.

# Install Rust tooling.
#
# Tools required by `make fmt` / `fmt-check` / `lint` / `pre-merge`:
#   - llvm-tools-preview + cargo-llvm-cov: coverage reporting
#   - cargo-machete:      audit-deps-unused (unused workspace deps)
#   - taplo-cli:          fmt-toml / fmt-check-toml / lint-toml
#   - cargo-edit:         upgrade-deps-rust (provides `cargo upgrade`)
#   - cargo-outdated:     audit-deps-outdated
#   - cargo-audit:        audit-deps-security (RustSec advisory DB)
RUN rustup component add llvm-tools-preview \
    && cargo install cargo-llvm-cov --locked \
    && cargo install cargo-machete --locked \
    && cargo install taplo-cli --locked \
    && cargo install cargo-edit --locked \
    && cargo install cargo-outdated --locked \
    && cargo install cargo-audit --locked

# Install YAML linter
RUN uv tool install yamllint

# Install Markdown linter
RUN npm install -g markdownlint-cli2

# Install Python dependencies for Qrusty integrations
COPY integrations/python/requirements.txt /tmp/requirements.txt
RUN pip3 install --break-system-packages -r /tmp/requirements.txt && rm /tmp/requirements.txt

# Install Node.js dependencies globally for Node-RED development
RUN npm install -g node-red
