1
+ # Set the ROS distribution as an argument, defaulting to 'jazzy'
2
+ ARG ROS_DISTRO=humble
3
+
4
+ # The base image comes from the official ROS repository hosted on Docker Hub
5
+ # You can find available ROS images here: https://hub.docker.com/_/ros/tags
6
+ # We're using the ros-base image which includes core ROS 2 packages
7
+ FROM ros:${ROS_DISTRO}-ros-base
8
+
9
+ # Set the maintainer information for this Dockerfile
10
+ LABEL maintainer="AutomaticAddison<
[email protected] >"
11
+
12
+ # Set environment variables
13
+ ENV PIP_BREAK_SYSTEM_PACKAGES=1
14
+ ENV DEBIAN_FRONTEND=noninteractive
15
+
16
+ # Set the default shell to bash for RUN commands
17
+ # This ensures all RUN commands use bash instead of sh
18
+ SHELL ["/bin/bash", "-c"]
19
+
20
+ # Update the system and install essential tools
21
+ # This step upgrades all packages and installs utilities needed for development
22
+ RUN apt-get update -q && \
23
+ apt-get upgrade -yq && \
24
+ apt-get install -yq --no-install-recommends apt-utils wget curl git build-essential \
25
+ vim sudo lsb-release locales bash-completion tzdata gosu gedit htop nano libserial-dev
26
+
27
+ # Install additional tools required for ROS 2 development
28
+ # These packages help with building and managing ROS 2 workspaces
29
+ RUN apt-get update -q && \
30
+ apt-get install -y gnupg2 iputils-ping usbutils \
31
+ python3-argcomplete python3-colcon-common-extensions python3-networkx python3-pip python3-rosdep python3-vcstool
32
+
33
+ # Set up the ROS 2 environment
34
+ # This ensures that ROS 2 commands are available in the shell
35
+ # rosdep is a tool for installing system dependencies for ROS packages
36
+ RUN rosdep update && \
37
+ grep -F "source /opt/ros/${ROS_DISTRO}/setup.bash" /root/.bashrc || echo "source /opt/ros/${ROS_DISTRO}/setup.bash" >> /root/.bashrc && \
38
+ grep -F "source /usr/share/colcon_argcomplete/hook/colcon-argcomplete.bash" /root/.bashrc || echo "source /usr/share/colcon_argcomplete/hook/colcon-argcomplete.bash" >> /root/.bashrc
39
+
40
+ # Install additional ROS 2 packages
41
+ RUN apt-get update && \
42
+ apt-get install -y \
43
+ ros-${ROS_DISTRO}-joint-state-publisher-gui \
44
+ ros-${ROS_DISTRO}-xacro \
45
+ ros-${ROS_DISTRO}-demo-nodes-cpp \
46
+ ros-${ROS_DISTRO}-demo-nodes-py \
47
+ ros-${ROS_DISTRO}-rviz2 \
48
+ ros-${ROS_DISTRO}-rqt-reconfigure
49
+
50
+ # Install Mesa graphics drivers
51
+ # Mesa is an open-source implementation of OpenGL and other graphics APIs
52
+ # It's crucial for 3D rendering in many applications, including RViz in ROS
53
+ RUN apt-get update && \
54
+ apt-get install -y software-properties-common && \
55
+ DEBIAN_FRONTEND=noninteractive add-apt-repository ppa:kisak/kisak-mesa
56
+
57
+ # Create necessary directories
58
+ RUN mkdir -p /etc/udev/rules.d && \
59
+ mkdir -p /root/ros2_ws/src/demo_nova_sanctum
60
+
61
+ # Copy the entire project into the container
62
+ # Since we're using the parent directory as context, we can copy everything
63
+ COPY . /root/ros2_ws/src/demo_nova_sanctum
64
+
65
+ # Copy configuration files from docker directory
66
+ # Note the docker/ prefix since we're in the parent context
67
+ COPY docker/workspace.sh /root/
68
+ COPY docker/entrypoint.sh /root/
69
+ COPY docker/bash_aliases.txt /root/.bashrc_aliases
70
+
71
+ # Make scripts executable
72
+ RUN chmod +x /root/workspace.sh /root/entrypoint.sh
73
+
74
+ # Add custom bash aliases
75
+ RUN cat /root/.bashrc_aliases >> /root/.bashrc
76
+
77
+ # Run the workspace setup script
78
+ # This typically installs workspace dependencies and builds the ROS 2 packages
79
+ WORKDIR /root
80
+ RUN ./workspace.sh
81
+
82
+ # Ensure the ROS 2 workspace is sourced in every new shell
83
+ RUN echo "source /root/ros2_ws/install/setup.bash" >> /root/.bashrc
84
+
85
+ # Set the entrypoint for the container
86
+ # This script will be run every time the container starts
87
+ ENTRYPOINT ["/root/entrypoint.sh"]
88
+
89
+ # Set the default command
90
+ # This keeps the container running indefinitely, allowing you to exec into it
91
+ RUN echo "source /opt/ros/humble/setup.bash" >> ~/.bashrc
92
+ RUN echo "source /root/ros2_ws/install/setup.bash" >> ~/.bashrc
93
+ CMD ["/bin/bash", "-c", "tail -f /dev/null"]
0 commit comments