From 201d2a635eabd223ecde17de214b6c5ae4edaa88 Mon Sep 17 00:00:00 2001 From: stevedan Date: Fri, 6 Sep 2024 22:19:06 +0200 Subject: [PATCH] update dockerfile #36 Signed-off-by: stevedan --- .../docker/Dockerfile | 68 ++++++++++--------- .../docker/demo-pkgs.txt | 9 +++ .../docker/excluded-pkgs.txt | 10 +++ 3 files changed, 55 insertions(+), 32 deletions(-) create mode 100644 lunar_pole_exploration_rover/docker/demo-pkgs.txt create mode 100644 lunar_pole_exploration_rover/docker/excluded-pkgs.txt diff --git a/lunar_pole_exploration_rover/docker/Dockerfile b/lunar_pole_exploration_rover/docker/Dockerfile index efd7633b..c1e8d89c 100644 --- a/lunar_pole_exploration_rover/docker/Dockerfile +++ b/lunar_pole_exploration_rover/docker/Dockerfile @@ -1,4 +1,5 @@ -# Copyright 2021 Open Source Robotics Foundation, Inc. +# Copyright 2024 Stevedan Ogochukwu Omodolor Omodolor +# Copyright 2024 Robin Baran # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -12,7 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. # -# A Docker configuration script to build the Space ROS image. +# A Docker configuration script to build the MoveIt2/Space ROS image. # # The script provides the following build arguments: # @@ -27,36 +28,30 @@ ARG VERSION="preview" # Specify the docker image metadata LABEL org.label-schema.schema-version="1.0" -LABEL org.label-schema.name="Lunar Pole Exploration Rover" -LABEL org.label-schema.description="Lunar Pole Exploration Rover entry for the NASA Space ROS Sim Summer Sprint Challenge" +LABEL org.label-schema.name="MoveIt2" +LABEL org.label-schema.description="Preview version of the MoveIt2/Space ROS platform" LABEL org.label-schema.vendor="Open Robotics" LABEL org.label-schema.version=${VERSION} LABEL org.label-schema.url="https://github.com/space-ros" -LABEL org.label-schema.vcs-url="https://github.com/space-ros/demos" +LABEL org.label-schema.vcs-url="https://github.com/space-ros/docker-images" LABEL org.label-schema.vcs-ref=${VCS_REF} +# Disable prompting during package installation +ARG DEBIAN_FRONTEND=noninteractive + # Define a few key variables ENV DEMO_DIR=${HOME_DIR}/demos_ws ENV IGNITION_VERSION=fortress ENV GZ_VERSION=fortress -# Disable prompting during package installation -ARG DEBIAN_FRONTEND=noninteractive - - -# Get rosinstall_generator -# Using Docker BuildKit cache mounts for /var/cache/apt and /var/lib/apt ensures that -# the cache won't make it into the built image but will be maintained between steps. -RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ - --mount=type=cache,target=/var/lib/apt,sharing=locked \ - sudo apt-get update -y && sudo apt-get install -y python3-rosinstall-generator +# Clone all space-ros sources +RUN mkdir ${SPACEROS_DIR}/src \ + && vcs import ${SPACEROS_DIR}/src < ${SPACEROS_DIR}/exact.repos -# Disable prompting during package installation -ARG DEBIAN_FRONTEND=noninteractive +# Define key locations +RUN mkdir -p ${DEMO_DIR}/src +WORKDIR ${DEMO_DIR} -# # Clone all space-ros sources -# RUN mkdir ${SPACEROS_DIR}/src \ -# && vcs import ${SPACEROS_DIR}/src < ${SPACEROS_DIR}/exact.repos # Make sure the latest versions of packages are installed # Using Docker BuildKit cache mounts for /var/cache/apt and /var/lib/apt ensures that @@ -102,13 +97,6 @@ RUN python3 -m pip install -U \ pytest-rerunfailures \ pytest -RUN mkdir -p ${DEMO_DIR}/src -WORKDIR ${DEMO_DIR} - -# Update the ownership of the source files (had to use sudo above to work around -# a possible inherited 'insteadof' from the host that forces use of ssh -RUN sudo chown -R ${USERNAME}:${USERNAME} ${DEMO_DIR} - # Get rosinstall_generator RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ --mount=type=cache,target=/var/lib/apt,sharing=locked \ @@ -119,6 +107,7 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ --mount=type=cache,target=/var/lib/apt,sharing=locked \ sudo apt-get install libmongoc-dev -y + # Compile mongo cxx driver https://mongocxx.org/mongocxx-v3/installation/linux/ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ --mount=type=cache,target=/var/lib/apt,sharing=locked \ @@ -127,9 +116,23 @@ RUN wget https://github.com/mongodb/mongo-cxx-driver/releases/download/r3.6.7/mo RUN tar -xzf mongo-cxx-driver-r3.6.7.tar.gz RUN cd mongo-cxx-driver-r3.6.7/build && cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local && sudo cmake --build . --target EP_mnmlstc_core && cmake --build . && sudo cmake --build . --target install + + +# Generate repos file for dependencies, excluding packages from Space ROS core. +COPY --chown=${USERNAME}:${USERNAME} demo-pkgs.txt /tmp/ +COPY --chown=${USERNAME}:${USERNAME} excluded-pkgs.txt /tmp/ +RUN rosinstall_generator \ + --rosdistro ${ROSDISTRO} \ + --deps \ + --exclude-path ${SPACEROS_DIR}/src \ + --exclude $(cat /tmp/excluded-pkgs.txt) -- \ + -- $(cat /tmp/demo-pkgs.txt) \ + > /tmp/demo_generated_pkgs.repos + +RUN vcs import src < /tmp/demo_generated_pkgs.repos + # Get the source for the dependencies -# RUN vcs import src < /tmp/demo_generated_pkgs.repos -COPY --chown=${USERNAME}:${USERNAME} ./demo_manual_pkgs.repos /tmp/ +COPY --chown=${USERNAME}:${USERNAME} demo_manual_pkgs.repos /tmp/ RUN vcs import src < /tmp/demo_manual_pkgs.repos && /bin/bash -c 'source "${SPACEROS_DIR}/install/setup.bash"' RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ @@ -138,9 +141,10 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ && /bin/bash -c 'source "${SPACEROS_DIR}/install/setup.bash"' \ && rosdep install --from-paths src --ignore-src -r -y --rosdistro ${ROSDISTRO} -# Build the demo +# build demo RUN /bin/bash -c 'source ${SPACEROS_DIR}/install/setup.bash \ - && colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release' + && colcon build --executo sequential --cmake-args -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXPORT_COMPILE_COMMANDS=ON --event-handlers desktop_notification- status-' + # Add the user to the render group so that the user can access /dev/dri/renderD128 RUN sudo usermod -aG render $USERNAME @@ -159,4 +163,4 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ # Setup the entrypoint COPY ./entrypoint.sh / ENTRYPOINT ["/entrypoint.sh"] -CMD ["bash"] +CMD ["bash"] \ No newline at end of file diff --git a/lunar_pole_exploration_rover/docker/demo-pkgs.txt b/lunar_pole_exploration_rover/docker/demo-pkgs.txt new file mode 100644 index 00000000..5cc28748 --- /dev/null +++ b/lunar_pole_exploration_rover/docker/demo-pkgs.txt @@ -0,0 +1,9 @@ +angles +backward_ros +control_msgs +rviz2 +ros2_control +warehouse_ros +xacro +yaml_cpp_vendor +python_qt_binding diff --git a/lunar_pole_exploration_rover/docker/excluded-pkgs.txt b/lunar_pole_exploration_rover/docker/excluded-pkgs.txt new file mode 100644 index 00000000..7ad42a8a --- /dev/null +++ b/lunar_pole_exploration_rover/docker/excluded-pkgs.txt @@ -0,0 +1,10 @@ +fastrtps +fastcdr +generate_parameter_library +rmw_fastrtps_cpp +rmw_fastrtps_dynamic_cpp +rmw_fastrtps_shared_cpp +rmw_connextdds +rosidl_typesupport_fastrtps_c +rosidl_typesupport_fastrtps_cpp +fastrtps_cmake_module \ No newline at end of file