Announcing Official Docker Images for ROS2

Hi @ruffsl,

first of all thank you for this!

Minor comment on Creating a Dockerfile to build ROS packages:

This line fails:

RUN git -C src clone
-b $ROS_DISTRO
GitHub - ros2/demos

There is no crystal branch on ros2/demos (at least not yet).

Cloning into 'demos'...
fatal: Remote branch crystal not found in upstream origin
The command '/bin/sh -c git -C src clone       -b $ROS_DISTRO       https://github.com/ros2/demos.git' returned a non-zero code: 128

If you change to master branch works without problems. Like:

FROM ros:crystal-ros-base

# install ros build tools
RUN apt-get update && apt-get install -y \
      python3-colcon-common-extensions && \
    rm -rf /var/lib/apt/lists/*

# clone ros package repo
ENV ROS_WS /opt/ros_ws
RUN mkdir -p $ROS_WS/src
WORKDIR $ROS_WS
RUN git -C src clone \
      -b master \
      https://github.com/ros2/demos.git

# install ros package dependencies
RUN apt-get update && \
    rosdep update && \
    rosdep install -y \
      --from-paths \
        src/demos/demo_nodes_cpp \
      --ignore-src && \
    rm -rf /var/lib/apt/lists/*

# build ros package source
RUN . /opt/ros/$ROS_DISTRO/setup.sh && \
    colcon build \
      --packages-select \
        demo_nodes_cpp \
      --cmake-args \
        -DCMAKE_BUILD_TYPE=Release

# copy ros package install via multi-stage
FROM ros:crystal-ros-core
ENV ROS_WS /opt/ros_ws
COPY --from=0  $ROS_WS/install $ROS_WS/install

# source ros package from entrypoint
RUN sed --in-place --expression \
      '$isource "$ROS_WS/install/setup.bash"' \
      /ros_entrypoint.sh

CMD ["bash"]

Regards,

@LanderU

1 Like