96 lines
No EOL
3.6 KiB
Docker
96 lines
No EOL
3.6 KiB
Docker
# Set the ROS distribution as an argument, defaulting to 'jazzy'
|
|
ARG ROS_DISTRO=foxy
|
|
|
|
# You can find available ROS images here: https://hub.docker.com/_/ros/tags
|
|
FROM osrf/ros:${ROS_DISTRO}-desktop
|
|
|
|
# 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
|
|
|
|
# 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 \
|
|
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 && \
|
|
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)
|
|
RUN curl -sS https://bootstrap.pypa.io/pip/3.8/get-pip.py | python3.8
|
|
|
|
# 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
|
|
|
|
# Install dependencies for ros2_tracing
|
|
RUN apt-get update -q && \
|
|
apt-get install -y lttng-tools lttng-modules-dkms liblttng-ust-dev
|
|
RUN apt-get install -y python3-babeltrace python3-lttng python3-pytest python3-pandas
|
|
|
|
# Python bokeh is not available in the default apt repository
|
|
# So we install it using pip
|
|
RUN python3 -m pip install --upgrade bokeh
|
|
|
|
# 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 |