ROS-Dynamic-Executor-Experi.../Dockerfile

99 lines
3.7 KiB
Text
Raw Normal View History

# Set the ROS distribution as an argument, defaulting to 'jazzy'
ARG ROS_DISTRO=foxy
2025-03-22 19:42:17 -04:00
# You can find available ROS images here: https://hub.docker.com/_/ros/tags
FROM osrf/ros:${ROS_DISTRO}-desktop
2025-03-22 19:42:17 -04:00
# Set the maintainer information for this Dockerfile
LABEL maintainer="Niklas Halle <niklas@niklashalle.net>"
# Set environment variables
ENV PIP_BREAK_SYSTEM_PACKAGES=1
ENV DEBIAN_FRONTEND=noninteractive
2025-04-29 09:31:19 +02:00
# User and group IDs
ARG USERNAME=dev
ARG USER_UID=1000
ARG USER_GID=$USER_UID
# Create the user
RUN groupadd --gid $USER_GID $USERNAME \
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME \
#
# [Optional] Add sudo support. Omit if you don't need to install software after connecting.
&& apt-get update \
&& apt-get install -y sudo \
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
&& chmod 0440 /etc/sudoers.d/$USERNAME
# Set the default shell to bash for RUN commands
# This ensures all RUN commands use bash instead of sh
SHELL ["/bin/bash", "-c"]
# Update the system and install essential tools
# This step upgrades all packages and installs utilities needed for development
RUN apt-get update -q && \
apt-get upgrade -yq && \
apt-get install -yq --no-install-recommends \
apt-utils wget curl git build-essential vim sudo \
lsb-release locales bash-completion tzdata gosu \
gedit htop nano libserial-dev ninja-build clang-18
# Update packages and install dependencies
RUN apt-get update && \
apt-get install -y software-properties-common curl build-essential && \
add-apt-repository ppa:deadsnakes/ppa && \
apt-get update && \
apt-get install -y \
2025-04-29 09:31:19 +02:00
python3.8 \
python3.8-venv \
python3.8-dev \
python3.8-distutils \
nlohmann-json3-dev \
curl && \
rm -rf /var/lib/apt/lists/*
# Install additional tools required for ROS 2 development
# These packages help with building and managing ROS 2 workspaces
RUN apt-get update -q && \
apt-get install -y gnupg2 iputils-ping usbutils \
python3-argcomplete python3-colcon-common-extensions python3-networkx python3-pip python3-rosdep python3-vcstool
# Set up the ROS 2 environment
# This ensures that ROS 2 commands are available in the shell
# rosdep is a tool for installing system dependencies for ROS packages
RUN rosdep update && \
2025-04-29 09:31:19 +02:00
grep -F "source /opt/ros/${ROS_DISTRO}/setup.bash" /home/dev/.bashrc || echo "source /opt/ros/${ROS_DISTRO}/setup.bash" >> /home/dev/.bashrc && \
grep -F "source /usr/share/colcon_argcomplete/hook/colcon-argcomplete.bash" /home/dev/.bashrc || echo "source /usr/share/colcon_argcomplete/hook/colcon-argcomplete.bash" >> /home/dev/.bashrc
# Bootstrap pip manually (recommended way)
2025-04-29 09:31:19 +02:00
RUN curl -sS https://bootstrap.pypa.io/pip/3.8/get-pip.py | python3.8
2025-04-29 09:31:19 +02:00
# Set Python 3.8 as default Python3
RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 1
# Install modern nodejs (optional but good practice for JupyterLab widgets)
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && \
apt-get install -y nodejs && \
npm install -g npm
# Install JupyterLab globally
RUN python3 -m pip install --upgrade jupyterlab
2025-04-29 09:31:19 +02:00
# Install dependencies for ros2_tracing
RUN apt-get update -q && \
apt-get install -y lttng-tools lttng-modules-dkms liblttng-ust-dev
2025-05-02 15:32:04 +02:00
RUN apt-get install -y python3-babeltrace python3-lttng python3-pytest python3-pytest-cov python3-pandas
2025-04-29 10:23:56 +02:00
# Python bokeh is not available in the default apt repository
# So we install it using pip
RUN python3 -m pip install --upgrade bokeh
2025-04-29 09:31:19 +02:00
2025-04-29 14:57:54 +02:00
# Install additional Python packages
RUN python3 -m pip install --upgrade numexpr
2025-04-29 09:31:19 +02:00
# Add user to the "tracing" group
RUN usermod -aG tracing $USERNAME
# [Optional] Set the default user. Omit if you want to keep the default as root.
USER $USERNAME