Skip to content

Commit acbe158

Browse files
Add docker-compose.yml and entrypoint.sh with CycloneDDS middleware
Co-authored-by: marc-hanheide <1153084+marc-hanheide@users.noreply.github.com>
1 parent 2b0d65a commit acbe158

3 files changed

Lines changed: 68 additions & 4 deletions

File tree

.devcontainer/Dockerfile

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,29 @@ ARG GIT_REPO_VERSION_DATE="unknown"
4040
ENV GIT_REPO_VERSION=${GIT_REPO_VERSION}
4141
ENV GIT_REPO_VERSION_DATE=${GIT_REPO_VERSION_DATE}
4242

43-
RUN mkdir -p /root/workspace/src
44-
COPY . /root/workspace/src/repository
45-
WORKDIR /root/workspace/
43+
# Install CycloneDDS ROS middleware implementation
44+
RUN apt-get update \
45+
&& apt-get install -qq -y --no-install-recommends \
46+
ros-${ROS_DISTRO}-rmw-cyclonedds-cpp \
47+
&& rm -rf /var/lib/apt/lists/*
48+
49+
# Use CycloneDDS as the default ROS Middleware
50+
ENV RMW_IMPLEMENTATION=rmw_cyclonedds_cpp
51+
52+
# Path to the colcon workspace inside the container
53+
ENV WORKSPACE_DIR=/root/workspace
54+
55+
RUN mkdir -p ${WORKSPACE_DIR}/src
56+
COPY . ${WORKSPACE_DIR}/src/repository
57+
WORKDIR ${WORKSPACE_DIR}
4658
RUN rosdep update --rosdistro ${ROS_DISTRO} && apt-get update \
4759
&& rosdep install --from-paths ./src --ignore-src -r -y \
48-
&& bash -c "source /opt/ros/${ROS_DISTRO}/setup.sh; colcon build"
60+
&& bash -c "source /opt/ros/${ROS_DISTRO}/setup.sh; colcon build" \
61+
&& rm -rf /var/lib/apt/lists/*
62+
63+
COPY entrypoint.sh /entrypoint.sh
64+
RUN chmod +x /entrypoint.sh
65+
66+
ENTRYPOINT ["/entrypoint.sh"]
67+
CMD ["ros2", "launch", "rosbag_blackbox", "rosbag_blackbox.launch.py"]
4968

docker-compose.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
services:
2+
# Service name matches the ROS package; image name mirrors the GitHub repository name
3+
rosbag_blackbox:
4+
image: ghcr.io/jabasai/rosbag_ringbuffer:latest
5+
build:
6+
context: .
7+
dockerfile: .devcontainer/Dockerfile
8+
target: final
9+
args:
10+
BASE_IMAGE: ros:humble
11+
environment:
12+
# Use CycloneDDS as the ROS Middleware
13+
- RMW_IMPLEMENTATION=rmw_cyclonedds_cpp
14+
# Host networking is required so that DDS multicast-based node discovery
15+
# works transparently between the container and other ROS 2 nodes on the
16+
# same machine or LAN. Be aware that this removes Docker's network
17+
# isolation: all host ports are accessible from inside the container.
18+
network_mode: host
19+
volumes:
20+
# Mount a local config file (override the bundled example_config.yaml)
21+
- ./src/rosbag_blackbox/config/example_config.yaml:/config/config.yaml:ro
22+
# Persist snapshots to the host
23+
- ./bags:/bags
24+
command:
25+
- ros2
26+
- launch
27+
- rosbag_blackbox
28+
- rosbag_blackbox.launch.py
29+
- snapshot_dir:=/bags
30+
- config_file:=/config/config.yaml

entrypoint.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# Source ROS 2 base environment
5+
# shellcheck disable=SC1091
6+
source /opt/ros/${ROS_DISTRO}/setup.bash
7+
8+
# Source the built colcon workspace if it exists
9+
WORKSPACE_DIR=${WORKSPACE_DIR:-/root/workspace}
10+
if [ -f "${WORKSPACE_DIR}/install/setup.bash" ]; then
11+
# shellcheck disable=SC1091
12+
source "${WORKSPACE_DIR}/install/setup.bash"
13+
fi
14+
15+
exec "$@"

0 commit comments

Comments
 (0)