ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

You dockerfile is a bit erratic, so I'll just provide a complete minimal example of building a ROS 1 package from source. Just swap melodic for kinetic if that is the distro you still require; the following includes:
Cloning source code into workspace
Installing package dependencies
Building package using catkin tools
Sourcing workspace into entrypoint
And launching package nodes

FROM ros:melodic

# install build tools
RUN apt-get update && apt-get install -y \
      python-catkin-tools \
    && 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 melodic-devel \
      https://github.com/ros/ros_tutorials.git

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

# build ros package source
WORKDIR $ROS_WS
RUN catkin config \
      --extend /opt/ros/$ROS_DISTRO && \
    catkin build \
      roscpp_tutorials

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

# run ros package launch file
CMD ["roslaunch", "roscpp_tutorials", "talker_listener.launch"]

You dockerfile is a bit erratic, so I'll just provide a complete minimal example of building a ROS 1 package from source. Just swap melodic for kinetic if that is the distro you still require; the following includes:
Cloning source code into workspace
Installing package dependencies
Building package using catkin tools
Sourcing workspace into entrypoint
And launching package nodes

FROM ros:melodic

# install build tools
RUN apt-get update && apt-get install -y \
      python-catkin-tools \
    && 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 melodic-devel \
      https://github.com/ros/ros_tutorials.git

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

# build ros package source
WORKDIR $ROS_WS
RUN catkin config \
      --extend /opt/ros/$ROS_DISTRO && \
    catkin build \
      roscpp_tutorials

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

# run ros package launch file
CMD ["roslaunch", "roscpp_tutorials", "talker_listener.launch"]

You dockerfile is a bit erratic, so I'll just provide a complete minimal example of building a ROS 1 package from source. Just swap melodic for kinetic if that is the distro you still require; the following includes:
Cloning source code into workspace
Installing package dependencies
Building package using catkin tools
Sourcing workspace into entrypoint
And launching package nodes

FROM ros:melodic

# install build tools
RUN apt-get update && apt-get install -y \
      python-catkin-tools \
    && 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 melodic-devel $ROS_DISTRO-devel \
      https://github.com/ros/ros_tutorials.git

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

# build ros package source
RUN catkin config \
      --extend /opt/ros/$ROS_DISTRO && \
    catkin build \
      roscpp_tutorials

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

# run ros package launch file
CMD ["roslaunch", "roscpp_tutorials", "talker_listener.launch"]