# Use the Rust devcontainer image as base
FROM mcr.microsoft.com/devcontainers/rust:2-1-bookworm

# Install dependencies
RUN apt-get update && \
    apt-get install -y --no-install-recommends \
    usbutils \
    curl \
    ca-certificates \
    build-essential \
    git \
    pkg-config \
    libssl-dev \
    python3.11-venv \
    # For arm-none-eabi toolchain
    gcc-arm-none-eabi && \
    rm -rf /var/lib/apt/lists/*

# Install Rust target for embedded development
RUN rustup target add thumbv7em-none-eabihf

# Install probe-rs (latest release) via curl
RUN curl -LsSf https://github.com/probe-rs/probe-rs/releases/latest/download/probe-rs-tools-installer.sh | sh

# Add vscode user to plugdev group for USB access
RUN groupadd -f plugdev \
    && usermod -aG plugdev vscode
