FROM ros:noetic-ros-core

RUN apt-get update \
    && apt-get install -y build-essential file clang-format python3-rosdep \
    && rm -rf /var/lib/apt/lists/{apt,dpkg,cache,log} /tmp/* /var/tmp/*

# workaround for https://github.com/catkin/catkin_tools/issues/594:
# apt-get install python3-catkin-tools doesn't work because python3-trollius doesn't exist on Ubuntu Focal

ENV PATH="/root/.local/bin:${PATH}"

RUN apt-get update \
    && apt-get install -y git python3-pip \
    && rm -rf /var/lib/apt/lists/{apt,dpkg,cache,log} /tmp/* /var/tmp/*

RUN pip3 install --user git+https://github.com/catkin/catkin_tools.git

# end workaround

# Create ROS workspace
COPY . /ws/src/imu_tools
WORKDIR /ws

# Use rosdep to install all dependencies (including ROS itself)
RUN rosdep init && rosdep update && rosdep install --from-paths src -i -y --rosdistro noetic

RUN /bin/bash -c "source /opt/ros/noetic/setup.bash && \
    catkin init && \
    catkin config --install -j 1 -p 1 && \
    catkin build --limit-status-rate 0.1 --no-notify && \
    catkin build --limit-status-rate 0.1 --no-notify --make-args tests"