FROM ros:jazzy-ros-base

ENV DEBIAN_FRONTEND=noninteractive

# ---------- System dependencies ----------
RUN apt-get update && apt-get install -y \
    python3-colcon-common-extensions \
    python3-rosdep \
    build-essential \
    udev \
    git

# ---------- Initialize rosdep ----------
RUN rosdep init || true
RUN rosdep update

# ---------- Workspace ----------
WORKDIR /ros_ws

# ---------- Copy package.xml files ----------
COPY toid_bot_description/package.xml    toid_bot_description/package.xml
COPY toid_control/package.xml            toid_control/package.xml
COPY toid_msgs/package.xml               toid_msgs/package.xml
COPY toid_odometry/package.xml           toid_odometry/package.xml
COPY toid_spinner_controller/package.xml toid_spinner_controller/package.xml
COPY toid_behaviors/package.xml          toid_behaviors/package.xml
COPY toid_navigation/package.xml         toid_navigation/package.xml

# ---------- Install dependencies ----------
RUN . /opt/ros/jazzy/setup.sh && \
    rosdep install --from-paths ./ --ignore-src -r -y \
    && rm -rf /var/lib/apt/lists/*

RUN rm -rf ./*

RUN cat <<EOF >> /root/.bashrc
source /opt/ros/jazzy/setup.bash
if [[ -f ./install/setup.bash ]]; then
    source ./install/setup.bash
fi
EOF


CMD ["sleep", "infinity"]
