From 7d4eca3c4611625c1e7eb9891a4b7981c19b5516 Mon Sep 17 00:00:00 2001 From: Akash Shingha Date: Thu, 12 Mar 2026 17:11:03 +0200 Subject: [PATCH] Refactor Dockerfile and update dependency management for improved clarity; enhance README with dependency details and installation instructions --- Dockerfile | 8 ++++---- README.md | 24 ++++++++++++++++++++++++ apt-requirements.txt | 2 +- apt-runtime.txt | 9 ++++++--- docker-compose.yml | 3 ++- requirements.txt | 3 ++- 6 files changed, 39 insertions(+), 10 deletions(-) diff --git a/Dockerfile b/Dockerfile index 80d744f..26903d6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,10 +3,10 @@ SHELL ["/bin/bash", "-lc"] WORKDIR /ws # Install build dependencies -COPY apt-requirements.txt /tmp/requirements.txt +COPY apt-requirements.txt /tmp/apt-build.txt RUN apt-get update \ - && xargs -a /tmp/requirements.txt apt-get install -y --no-install-recommends \ - && rm -rf /var/lib/apt/lists/* /tmp/requirements.txt + && grep -Ev '^[[:space:]]*($|#)' /tmp/apt-build.txt | xargs apt-get install -y --no-install-recommends \ + && rm -rf /var/lib/apt/lists/* /tmp/apt-build.txt # Copy package manifest and install rosdeps COPY package.xml ./package.xml @@ -29,7 +29,7 @@ WORKDIR /ws ## Install minimal runtime packages required by the built binaries COPY apt-runtime.txt /tmp/apt-runtime.txt RUN apt-get update \ - && xargs -a /tmp/apt-runtime.txt apt-get install -y --no-install-recommends \ + && grep -Ev '^[[:space:]]*($|#)' /tmp/apt-runtime.txt | xargs apt-get install -y --no-install-recommends \ && rm -rf /var/lib/apt/lists/* /tmp/apt-runtime.txt COPY --from=build /ws/install /ws/install diff --git a/README.md b/README.md index a921d63..23f0157 100644 --- a/README.md +++ b/README.md @@ -14,10 +14,34 @@ You are reading now the README for a **default** ROS2 package. If you want to us ## Dependencies - ROS2 Humble +- Dependency files in this repository: + - `apt-requirements.txt`: build-only system dependencies. + - `apt-runtime.txt`: runtime system dependencies (minimal default set). + - `requirements.txt`: pip dependencies (currently none required). +- OpenCV policy: use APT package `python3-opencv` (do not install `opencv-python` via pip by default). + +- Optional debug-only packages: + - `ros-humble-ros2cli` + - `net-tools` + - `iputils-ping` + - These are listed as commented entries in `apt-runtime.txt` and are not installed by default. + - gstreamer libs: ```bash sudo apt-get install libgstreamer-plugins-base1.0-dev libgstreamer-plugins-good1.0-dev libgstreamer-plugins-bad1.0-dev libgstrtspserver-1.0-dev gstreamer1.0-plugins-ugly gstreamer1.0-plugins-bad ``` + +For a minimal host setup using repository-managed lists: +```bash +sudo apt-get update +grep -Ev '^[[:space:]]*($|#)' apt-requirements.txt | xargs sudo apt-get install -y --no-install-recommends +grep -Ev '^[[:space:]]*($|#)' apt-runtime.txt | xargs sudo apt-get install -y --no-install-recommends +``` + +Install debug tools only when needed: +```bash +sudo apt-get install -y --no-install-recommends ros-humble-ros2cli net-tools iputils-ping +``` ## Install - Navigate to the root directory, create a new directory named `ros2_ws/src`, and then change the current working directory to `ros2_ws/src`: ```bashrc diff --git a/apt-requirements.txt b/apt-requirements.txt index 67fd704..86eb89a 100644 --- a/apt-requirements.txt +++ b/apt-requirements.txt @@ -3,12 +3,12 @@ build-essential cmake pkg-config libopencv-dev -python3-opencv python3-rosdep python3-rosdistro software-properties-common libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev +libgstreamer-plugins-bad1.0-dev libgstreamer-plugins-good1.0-dev libgstrtspserver-1.0-dev ninja-build diff --git a/apt-runtime.txt b/apt-runtime.txt index 982f1f8..e6ff5be 100644 --- a/apt-runtime.txt +++ b/apt-runtime.txt @@ -5,7 +5,10 @@ gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly libgstrtspserver-1.0-0 python3-opencv -ros-humble-ros2cli ros-humble-rclpy -net-tools -iputils-ping + +# Optional debug-only tools (not required for normal runtime) +# Uncomment/install manually only when troubleshooting: +# ros-humble-ros2cli +# net-tools +# iputils-ping diff --git a/docker-compose.yml b/docker-compose.yml index 149a92a..f0d3c10 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -16,7 +16,8 @@ services: # Ensure the node binds to non-localhost interface (disable local_only) # and subscribe to the actual image topic available on the host - command: ["image2rtsp.launch.py", "local_only:=false", "topic:=/camera/image", "log_level:=debug"] + #log_level:= info, debug, warning, error, fatal + command: ["image2rtsp.launch.py", "local_only:=false", "topic:=/camera/image", "log_level:=info"] restart: unless-stopped diff --git a/requirements.txt b/requirements.txt index 0dd006b..15662a4 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,2 @@ -opencv-python +# No required pip dependencies. +# OpenCV is provided via apt package: python3-opencv.