Skip to content
Josh Cooper edited this page Mar 23, 2026 · 2 revisions

One Dockerfile, Development and Release

In your Dockerfile you can make use of multi-stage builds, allowing for one Dockerfile to cover both devleopment and release use cases.

ARG BASE_IMAGE=lcas.lincoln.ac.uk/ros:humble-staging
ARG ROS_DISTRO=humble

FROM ${BASE_IMAGE} AS devcontainer

RUN sudo apt-get install -y cowsay

# Do an initial build to speed up development
RUN /bin/bash -lc "source /opt/ros/${ROS_DISTRO}/setup.bash && source /home/ros/.bashrc && colcon build --continue-on-error"

# ----------------------------------------------------------------------------------------------------
FROM devcontainer AS final

RUN /bin/bash -lc "source /opt/ros/${ROS_DISTRO}/setup.bash && source /home/ros/.bashrc && colcon build"

CMD ["/bin/bash", "-lc", "source /home/ros/workspace/install/setup.bash && exec ros2 launch my_ros_pkg my_ros_pkg.launch.py"]

Then we can target the devcontainer stage for development, and use the final target for deployment. The last built stage will be what is used by default.

Clone this wiki locally