Skip to content

Development container support using docker-compose #817

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
May 28, 2025
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 0 additions & 63 deletions dev/Dockerfile

This file was deleted.

6 changes: 6 additions & 0 deletions docker/10_nvidia.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"file_format_version" : "1.0.0",
"ICD" : {
"library_path" : "libEGL_nvidia.so.0"
}
}
24 changes: 24 additions & 0 deletions docker/Dockerfile.base
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Ubuntu 24.04
FROM osrf/ros:jazzy-desktop-full AS vrx-base

ENV DEBIAN_FRONTEND=noninteractive

# Setup timezone
ENV TZ=Etc/UTC
RUN echo $TZ > /etc/timezone && \
ln -fs /usr/share/zoneinfo/$TZ /etc/localtime && \
apt update && \
apt install -y locales && \
locale-gen en_US en_US.UTF-8 && \
update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8

# Set up repo to install Gazebo
RUN curl -s https://packages.osrfoundation.org/gazebo.gpg -o /usr/share/keyrings/pkgs-osrf-archive-keyring.gpg && \
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/pkgs-osrf-archive-keyring.gpg] http://packages.osrfoundation.org/gazebo/ubuntu-stable $(lsb_release -cs) main" | tee /etc/apt/sources.list.d/gazebo-stable.list > /dev/null

# Install some 'standard' ROS packages and utilities.
RUN apt update \
&& apt install -y --no-install-recommends \
gz-harmonic \
&& rm -rf /var/lib/apt/lists/* \
&& apt clean -qq
15 changes: 15 additions & 0 deletions docker/Dockerfile.builder
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM vrx-base AS vrx-builder

COPY . /ws/src/

RUN . /opt/ros/${ROS_DISTRO}/setup.sh \
&& apt update \
&& rosdep install -r \
--from-paths /ws/src/ \
--ignore-src \
--rosdistro ${ROS_DISTRO} -y

# Build the project
RUN . /opt/ros/${ROS_DISTRO}/setup.sh \
&& cd /ws \
&& colcon build --symlink-install --merge-install
80 changes: 80 additions & 0 deletions docker/Dockerfile.devel
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
FROM vrx-base AS vrx-devel

# Install some 'standard' ROS packages and utilities.
RUN apt update \
&& apt install -y --no-install-recommends \
ros-${ROS_DISTRO}-ackermann-msgs \
ros-${ROS_DISTRO}-actuator-msgs \
ros-${ROS_DISTRO}-ament-cmake-pycodestyle \
ros-${ROS_DISTRO}-image-transport \
ros-${ROS_DISTRO}-image-transport-plugins \
ros-${ROS_DISTRO}-joy-teleop \
ros-${ROS_DISTRO}-joy-linux \
ros-${ROS_DISTRO}-mavros-msgs \
ros-${ROS_DISTRO}-navigation2 \
ros-${ROS_DISTRO}-nav2-bringup \
ros-${ROS_DISTRO}-nav2-minimal-tb3-sim \
ros-${ROS_DISTRO}-nav2-minimal-tb4-description\
ros-${ROS_DISTRO}-nav2-minimal-tb4-sim \
ros-${ROS_DISTRO}-radar-msgs \
ros-${ROS_DISTRO}-ros-gz-sim\
ros-${ROS_DISTRO}-vision-msgs \
ros-${ROS_DISTRO}-xacro \
&& rm -rf /var/lib/apt/lists/* \
&& apt clean -qq

# Tools necessary and useful during development
RUN apt update && \
apt install --no-install-recommends -y \
atop \
expect \
gdb \
iputils-ping \
gnutls-bin \
libbluetooth-dev \
libcwiid-dev \
net-tools \
python3-dbg \
python3-pip \
python3-venv \
vim \
wget \
xvfb \
&& rm -rf /var/lib/apt/lists/* \
&& apt clean -qq

# Nvidia setup
RUN dpkg --add-architecture i386 && \
apt-get update && apt-get install -y --no-install-recommends \
libxau6 libxau6:i386 \
libxdmcp6 libxdmcp6:i386 \
libxcb1 libxcb1:i386 \
libxext6 libxext6:i386 \
libx11-6 libx11-6:i386 \
libglvnd0 libglvnd0:i386 \
libgl1 libgl1:i386 \
libglx0 libglx0:i386 \
libegl1 libegl1:i386 \
libgles2 libgles2:i386 \
&& rm -rf /var/lib/apt/lists/* \
&& apt clean -qq
# COPY 10_nvidia.json /usr/share/glvnd/egl_vendor.d/10_nvidia.json
# # nvidia-container-runtime
# ENV NVIDIA_VISIBLE_DEVICES=${NVIDIA_VISIBLE_DEVICES:-all}
# ENV NVIDIA_DRIVER_CAPABILITIES=${NVIDIA_DRIVER_CAPABILITIES:+$NVIDIA_DRIVER_CAPABILITIES,}graphics,compat32,utility
# RUN echo "/usr/local/nvidia/lib" >> /etc/ld.so.conf.d/nvidia.conf && \
# echo "/usr/local/nvidia/lib64" >> /etc/ld.so.conf.d/nvidia.conf
# # Required for non-glvnd setups.
# ENV LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu:/usr/lib/i386-linux-gnu${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}:/usr/local/nvidia/lib:/usr/local/nvidia/lib64

# Add passworless for sudo for the ubuntu user
# RUN echo "ubuntu ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers

WORKDIR /ws

COPY entrypoint-ros.sh /entrypoint-ros.sh
RUN chmod +x /entrypoint-ros.sh

# USER ubuntu

ENTRYPOINT ["/entrypoint-ros.sh"]
22 changes: 22 additions & 0 deletions docker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# VRX Docker support
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does this file play with the Docker installation instructions from the wiki?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prerequisites are the same. No need to clone dockwater repository anymore, just run the docker compose command.


For running VRX using the docker support please refer to the instructions
in https://github.com/osrf/vrx/wiki/docker_install_tutorial.

## Dockerfiles in this directory

The directory contains a series of Dockerfiles designed to serve different setups
for VRX. The usage is mainly controlled by `docker-compose` although docker files
can be used independently if desired:

* `Dockerfile.base`: built on top of osrf desktop-full. Install
gz-harmonic from packages.osrfoundation.org repository and
the VRX dependencies using rosdep. Generates the `vrx-base` image.

* `Dockerfile.builder`: built on top of `vrx-base`. Compiles the vrx packages
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should explain what is vrx-base.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Include the image names in ad84a95

using colcon. Generates the `vrx-builder` image.

* `Dockerfile.devel`: built on top of `vrx-base`. development image with
extra ROS 2 development packages and other dev utilities. It configures
the GPU support and a development user. Runs a shell into the container
with local sources mapped in /ws. Generates the `vrx-devel` image.
49 changes: 49 additions & 0 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
services:
base:
build:
context: .
dockerfile: Dockerfile.base
image: vrx-base

builder:
build:
context: ../
dockerfile: docker/Dockerfile.builder
depends_on:
- base
image: vrx-builder:latest

devel:
build:
context: .
dockerfile: Dockerfile.devel
depends_on:
- base
image: vrx-devel:latest
network_mode: host
stdin_open: true
tty: true
user: ubuntu
group_add:
- video
- sudo
# TODO: support for intel by enabling /dev/dri
# devices: # for intel dri
# - /dev/dri
environment:
- DISPLAY=unix${DISPLAY}
- TERM=xterm-256color
volumes:
- ..:/ws/src
- /sys:/sys:ro
- /tmp/.X11-unix:/tmp/.X11-unix:rw
- /dev/log:/dev/log:ro
- /run/log:/run/log:ro
deploy:
resources:
reservations:
devices:
- driver: nvidia
count: 1
capabilities: [gpu]
command: bash
7 changes: 7 additions & 0 deletions docker/entrypoint-ros.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
set -e

# Setup ROS environment
source /opt/ros/${ROS_DISTRO}/setup.bash

exec "$@"