Building micro_ros_agent inside docker container

Ok, I’ve managed to make it work.
I left the files here for future references:

Dockerfile:

FROM dustynv/ros:humble-ros-base-l4t-r32.7.1

RUN mkdir -p /home/microros_ws
WORKDIR /home/microros_ws

RUN mkdir src \
    && git -C src clone -b $ROS_DISTRO https://github.com/micro-ROS/micro-ROS-Agent.git \
    && git -C src clone -b $ROS_DISTRO https://github.com/micro-ROS/micro_ros_msgs.git  \
    && . /opt/ros/$ROS_DISTRO/install/setup.sh \
    &&  apt update \
    &&  apt install -y python3-pip \
    libspdlog-dev \
    libfmt-dev \
    &&  apt autoremove -y \
    &&  sudo rosdep fix-permissions \
    &&  rosdep update \
    &&  rosdep install --from-paths src --ignore-src -y \
    &&  colcon build --cmake-args -DUAGENT_BUILD_EXECUTABLE=OFF -DUAGENT_P2P_PROFILE=OFF -DUAGENT_USE_SYSTEM_LOGGER=ON --no-warn-unused-cli \
    &&  rm -rf log/ build/ src/* \
    &&  rm -rf /var/lib/apt/lists/*

ENV RMW_IMPLEMENTATION=rmw_fastrtps_cpp

COPY ros_entrypoint.sh /

ENTRYPOINT ["/ros_entrypoint.sh"]
CMD ["bash"]

docker-compose.yaml

version: '3.4'
services:
  robot:
    network_mode: "host"
    privileged: true
    build:
      context: .
      dockerfile: Dockerfile
    volumes:
      - /etc/timezone:/etc/timezone:ro
      - /etc/localtime:/etc/localtime:ro
    command: ros2 run micro_ros_agent micro_ros_agent serial -v --dev /dev/ttyACM0

ros_entrypoint.sh

#!/bin/bash
set -e
source /opt/ros/humble/install/setup.bash
source /home/microros_ws/install/setup.bash
exec "$@"

Then run this command on jetson nano:

docker-compose up --build

and after building the image it will start micro-ros-agent.
The use of docker-compose will allow us to run other packages.

Thank and best regards