FROM mcr.microsoft.com/devcontainers/cpp:1-debian-12

ARG REINSTALL_CMAKE_VERSION_FROM_SOURCE="3.22.2"

ARG LICENSE_ALREADY_ACCEPTED=1

RUN apt-get update && apt-get upgrade -y

# Optionally install the cmake for vcpkg
COPY ./Resources/Scripts/reinstall-cmake.sh /tmp/

RUN if [ "${REINSTALL_CMAKE_VERSION_FROM_SOURCE}" != "none" ]; then \
        chmod +x /tmp/reinstall-cmake.sh && /tmp/reinstall-cmake.sh ${REINSTALL_CMAKE_VERSION_FROM_SOURCE}; \
    fi \
    && rm -f /tmp/reinstall-cmake.sh


# Optionally install the Cube CLT
RUN apt-get install --no-install-recommends -y unzip
RUN mkdir /home/temp 
WORKDIR /home/temp

RUN wget http://192.168.1.225:8081/repository/file/Stm32/en.st-stm32cubeclt_1.18.0_24403_20250225_1636_amd64.deb_bundle.sh.zip
RUN unzip en.st-stm32cubeclt_1.18.0_24403_20250225_1636_amd64.deb_bundle.sh.zip 
RUN chmod +x st-stm32cubeclt_1.18.0_24403_20250225_1636_amd64.deb_bundle.sh && ./st-stm32cubeclt_1.18.0_24403_20250225_1636_amd64.deb_bundle.sh
WORKDIR /
RUN rm -rf /home/temp

WORKDIR /home/vscode
RUN apt-get install --no-install-recommends -y python3-pip python3-venv
RUN python3 -m venv venv && ./venv/bin/pip install --no-cache-dir pyserial protobuf grpcio grpcio-tools


RUN usermod -aG sudo,dialout,plugdev vscode
RUN apt-get clean && \
    rm -rf /var/lib/apt/lists/*

USER vscode


