Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
11 changes: 5 additions & 6 deletions .devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,17 @@
"build": {
"dockerfile": "Containerfile",
"target": "dev",
"context": ".",
"args": {
"ROS_DISTRO": "kilted",
}
"context": "."
},
"workspaceFolder": "/workspace",
"workspaceMount": "source=${localWorkspaceFolder},target=/workspace,type=bind",
"mounts": [],
"runArgs": [
"--net=host"
"--net=host",
"--env-file",
"${localWorkspaceFolder}/.env" // Adjust path as needed
],
"containerEnv": {
"SHELL": "/bin/bash"
}
}
}
41 changes: 41 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Name of this project:
REPO_NAME = ros2-container-template

#ROS Configuration
ROS_DOMAIN_ID=11
ROS_DISTRO=jazzy
CYCLONEDDS_URI=/cyclonedds.xml
RMW_IMPLEMENTATION=rmw_zenoh_cpp
ZENOH_ROUTER_CONFIG_URI=/CUSTOM_RMW_ZENOH_ROUTER_CONFIG.json5
ZENOH_SESSION_CONFIG_URI=/CUSTOM_RMW_ZENOH_SESSION_CONFIG.json5

# Registry Configuration
CACHE = ${REG}/${REPO_NAME}
CACHE_AMD64 = ${CACHE}:cache-amd64
CACHE_ARM64 = ${CACHE}:cache-arm64
REG=example.registry.com

# Docker configuration
CONTAINERFILE = Containerfile
CONTAINER_ENGINE = docker
COMPOSEFILE = docker-compose.yml

# Tag names
# These are dependent on the distro, meaning changing distro will cause a rebuild
BASE_TAG = ${ROS_DISTRO}-base
DEV_TAG = ${ROS_DISTRO}-dev
FINAL_TAG = ${ROS_DISTRO}-final
TAG=${FINAL_TAG}

# Image names
BASE_IMAGE = ${REPO_NAME}:${BASE_TAG}
DEV_IMAGE = ${REPO_NAME}:${DEV_TAG}
FINAL_IMAGE = ${REPO_NAME}:${FINAL_TAG}

# Marker files
# These are used by `build`, `test`, `dev`, and `final` commands
# to ensure rebuilds only happen when necessary
MARKER_DIR = .make-markers
BASE_BUILT = ${MARKER_DIR}/base.built
DEV_BUILT = ${MARKER_DIR}/dev.built
FINAL_BUILT = ${MARKER_DIR}/final.built
26 changes: 0 additions & 26 deletions .github/workflows/makefile.yml

This file was deleted.

5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
!Containerfile
!.devcontainer.json
!README.md

!docker-compose.yaml
!.env
!/root
!/root/**
!/container/
!/container/**
!/linux/
Expand Down
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[submodule "src/examples"]
path = src/examples
[submodule "src/example"]
path = src/example
url = https://github.com/ros2/examples.git
branch = kilted
branch = jazzy
111 changes: 84 additions & 27 deletions Containerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
ARG ROS_DISTRO
# Set up ROS2 container for diesl, and configure Zenoh for the RMW
ARG ROS_DISTRO=jazzy TAG=latest REG=registry.gitlab.sitcore.net/haiisw/diesl



###########################################################################
### BASE IMAGE ###
###########################################################################

# The base layer only installs dependencies, and does not build any code
# It installs a full ros environment
FROM docker.io/osrf/ros:${ROS_DISTRO}-desktop-full AS base

ENV DEBIAN_FRONTEND=noninteractive
# You can either user the diesl base image or the official ROS base image
# FROM ${REG}:diesl-base:${TAG} AS base
FROM ros:${ROS_DISTRO}-ros-base AS base

ENV DEBIAN_FRONTEND=noninteractive LANG=C.UTF-8 LC_ALL=C.UTF-8 OPAL_PREFIX= ROS_DISTRO=${ROS_DISTRO}

# Install packages
RUN apt-get update \
Expand All @@ -15,32 +25,44 @@ RUN apt-get update \
git \
python3-pip \
pip \
python3-rosdep \
python3-rosdep \
wget \
unzip \
ros-${ROS_DISTRO}-ros-gz \
ros-${ROS_DISTRO}-launch \
ros-${ROS_DISTRO}-launch-ros \
ros-${ROS_DISTRO}-ament-cmake \
ros-${ROS_DISTRO}-ament-cmake-core \
ros-${ROS_DISTRO}-ament-cmake-python
# TODO add your dependencies here!
ros-${ROS_DISTRO}-ament-cmake-python \
# alternative RMW packages:
ros-${ROS_DISTRO}-rmw-cyclonedds-cpp \
ros-${ROS_DISTRO}-rmw-zenoh-cpp \
# Add additional depencies here as needed, these are for the example
ros-jazzy-example-interfaces \
ros-jazzy-demo-nodes-cpp \
python3-pytest \
python3-numpy

ENV RMW_IMPLEMENTATION=rmw_zenoh_cpp ZENOH_ROUTER_CONFIG_URI=/CUSTOM_RMW_ZENOH_ROUTER_CONFIG.json5 ZENOH_SESSION_CONFIG_URI=/CUSTOM_RMW_ZENOH_SESSION_CONFIG.json5
# expose ports used for Zenoh
EXPOSE 7447/tcp
EXPOSE 8000/tcp
EXPOSE 7447/udp
EXPOSE 7446/udp

COPY root/ /

# Set up the entrypoint
RUN cat <<EOF > /entrypoint.bash
#!/usr/bin/env bash
source /opt/ros/${ROS_DISTRO}/setup.bash
RUN chmod +x /entrypoint.bash
ENTRYPOINT [ "/entrypoint.bash" ]

if [ -f /workspace/install/setup.bash ]; then
source /workspace/install/setup.bash
fi
STOPSIGNAL SIGINT

exec "\$@"
exec bash
EOF

RUN chmod +x /entrypoint.bash
ENTRYPOINT [ "/entrypoint.bash" ]
###########################################################################
### BUILD IMAGE ###
###########################################################################

# The build layer (which should probably be renamed), actually builds everything.
# Full image with all the functionality, built on top of the base image
FROM base AS build

# Copy in workspace
Expand All @@ -50,19 +72,54 @@ WORKDIR /workspace
# Actually build package
RUN . /opt/ros/${ROS_DISTRO}/setup.sh && colcon build

# Start from mininal image for final
FROM docker.io/library/ros:${ROS_DISTRO}-ros-core AS final
STOPSIGNAL SIGINT

###########################################################################
### FINAL IMAGE ###
###########################################################################

# TODO uncomment this and add runtime dependencies
# RUN apt-get update \
# && apt-get install -y --no-install-recommends \
# my-package
# && rm -rf /var/lib/apt/lists/*
# Stripped down image with only what is needed to run the code
FROM ros:${ROS_DISTRO}-ros-core AS final

RUN apt-get update \
&& apt-get install -y --no-install-recommends \
ros-${ROS_DISTRO}-rmw-cyclonedds-cpp \
ros-${ROS_DISTRO}-rmw-zenoh-cpp \
# Add additional depencies here as needed, these are examples
ros-jazzy-example-interfaces \
ros-jazzy-demo-nodes-cpp \
python3-pytest \
python3-numpy \
# and clean up apt cache
&& apt-get autoclean \
&& rm -rf /var/lib/apt/lists/*

COPY --from=build /workspace/build /workspace/build
COPY --from=build /workspace/install /workspace/install

CMD [ "bash" ] # TODO your command here!!
ENV DEBIAN_FRONTEND=noninteractive LANG=C.UTF-8 LC_ALL=C.UTF-8 OPAL_PREFIX=
ENV RMW_IMPLEMENTATION=rmw_zenoh_cpp ZENOH_ROUTER_CONFIG_URI=/DEFAULT_RMW_ZENOH_ROUTER_CONFIG.json5 ZENOH_SESSION_CONFIG_URI=/DEFAULT_RMW_ZENOH_SESSION_CONFIG.json5
# expose ports used for Zenoh
EXPOSE 7447/tcp
EXPOSE 8000/tcp
EXPOSE 7447/udp
EXPOSE 7446/udp

COPY root/ /

RUN chmod +x /entrypoint.bash
ENTRYPOINT [ "/entrypoint.bash" ]

# Example of run command, in this case startng a zenoh router node
# CMD ["ros2", "run", "rmw_zenoh_cpp", "rmw_zenohd"]

STOPSIGNAL SIGINT



###########################################################################
### DEV IMAGE ###
###########################################################################

# Dev environment with useful tools
FROM base AS dev
Expand Down
Loading