|
| 1 | +# Copyright 2021 Open Source Robotics Foundation, Inc. |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | +# |
| 15 | +# A Docker configuration script to build the Space ROS image. |
| 16 | +# |
| 17 | +# The script provides the following build arguments: |
| 18 | +# |
| 19 | +# VCS_REF - The git revision of the Space ROS source code (no default value). |
| 20 | +# VERSION - The version of Space ROS (default: "preview") |
| 21 | + |
| 22 | +FROM osrf/space-ros-moveit2:main |
| 23 | + |
| 24 | +# Define arguments used in the metadata definition |
| 25 | +ARG VCS_REF |
| 26 | +ARG VERSION="preview" |
| 27 | +ARG USERNAME="spaceros-user" |
| 28 | + |
| 29 | +# Specify the docker image metadata |
| 30 | +LABEL org.label-schema.schema-version="1.0" |
| 31 | +LABEL org.label-schema.name="Curiosity Rover" |
| 32 | +LABEL org.label-schema.description="Curiosity rover demo on the Space ROS platform" |
| 33 | +LABEL org.label-schema.vendor="Open Robotics" |
| 34 | +LABEL org.label-schema.version=${VERSION} |
| 35 | +LABEL org.label-schema.url="https://github.com/space-ros" |
| 36 | +LABEL org.label-schema.vcs-url="https://github.com/space-ros/docker" |
| 37 | +LABEL org.label-schema.vcs-ref=${VCS_REF} |
| 38 | + |
| 39 | +# Define a few key variables |
| 40 | +ENV DEMO_DIR=${HOME}/demos_ws |
| 41 | +WORKDIR ${DEMO_DIR} |
| 42 | + |
| 43 | +# Disable prompting during package installation |
| 44 | +ARG DEBIAN_FRONTEND=noninteractive |
| 45 | + |
| 46 | +# Update the ROS package keys |
| 47 | +ADD --chmod=644 https://raw.githubusercontent.com/ros/rosdistro/master/ros.key /usr/share/keyrings/ros-archive-keyring.gpg |
| 48 | + |
| 49 | +# Install base image dependencies |
| 50 | +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ |
| 51 | + --mount=type=cache,target=/var/lib/apt,sharing=locked \ |
| 52 | + sudo apt-get update -y && \ |
| 53 | + sudo -E apt-get install -y \ |
| 54 | + git-lfs \ |
| 55 | + python3-rosinstall-generator |
| 56 | + |
| 57 | +RUN git clone https://github.com/space-ros/demos.git ${DEMO_DIR}/src/demos |
| 58 | +RUN git clone https://github.com/space-ros/simulation.git ${DEMO_DIR}/src/simulation |
| 59 | + |
| 60 | +# Get a list of all installed ros2 packges |
| 61 | +RUN source "${SPACEROS_DIR}/setup.bash" && \ |
| 62 | + source "${MOVEIT2_DIR}/install/setup.bash" && \ |
| 63 | + ros2 pkg list > /tmp/installed-pkgs.txt |
| 64 | + |
| 65 | +# Generate repos file for demo dependencies, excluding previously installed packages |
| 66 | +COPY --chown=${USERNAME}:${USERNAME} demo-pkgs.txt /tmp/ |
| 67 | +COPY --chown=${USERNAME}:${USERNAME} excluded-pkgs.txt /tmp/ |
| 68 | +RUN rosinstall_generator \ |
| 69 | + --rosdistro ${ROS_DISTRO} \ |
| 70 | + --deps \ |
| 71 | + --exclude $(cat /tmp/excluded-pkgs.txt /tmp/installed-pkgs.txt) -- \ |
| 72 | + $(cat /tmp/demo-pkgs.txt) \ |
| 73 | + > demo_generated_pkgs.repos |
| 74 | + |
| 75 | +RUN vcs import --shallow src < demo_generated_pkgs.repos |
| 76 | + |
| 77 | +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ |
| 78 | + --mount=type=cache,target=/var/lib/apt,sharing=locked \ |
| 79 | + sudo apt-get update -y && \ |
| 80 | + source "${SPACEROS_DIR}/setup.bash" && \ |
| 81 | + source "${MOVEIT2_DIR}/install/setup.bash" && \ |
| 82 | + rosdep install --from-paths src --ignore-src -r -y --rosdistro ${ROS_DISTRO} |
| 83 | + |
| 84 | +# Build the demo |
| 85 | +RUN source ${SPACEROS_DIR}/setup.bash && \ |
| 86 | + source ${MOVEIT2_DIR}/install/setup.bash && \ |
| 87 | + colcon build \ |
| 88 | + --cmake-args \ |
| 89 | + -DCMAKE_BUILD_TYPE=Release |
| 90 | + |
| 91 | +# Setup the entrypoint |
| 92 | +COPY ./entrypoint.sh / |
| 93 | +ENTRYPOINT ["/entrypoint.sh"] |
| 94 | +CMD ["bash"] |
0 commit comments