|
| 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:latest |
| 23 | + |
| 24 | +# Define arguments used in the metadata definition |
| 25 | +ARG VCS_REF |
| 26 | +ARG VERSION="preview" |
| 27 | + |
| 28 | +# Specify the docker image metadata |
| 29 | +LABEL org.label-schema.schema-version="1.0" |
| 30 | +LABEL org.label-schema.name="Lunar Pole Exploration Rover" |
| 31 | +LABEL org.label-schema.description="Lunar Pole Exploration Rover entry for the NASA Space ROS Sim Summer Sprint Challenge" |
| 32 | +LABEL org.label-schema.vendor="Open Robotics" |
| 33 | +LABEL org.label-schema.version=${VERSION} |
| 34 | +LABEL org.label-schema.url="https://github.com/space-ros" |
| 35 | +LABEL org.label-schema.vcs-url="https://github.com/space-ros/demos" |
| 36 | +LABEL org.label-schema.vcs-ref=${VCS_REF} |
| 37 | + |
| 38 | +# Disable prompting during package installation |
| 39 | +ARG DEBIAN_FRONTEND=noninteractive |
| 40 | + |
| 41 | +# Define a few key variables |
| 42 | +ENV DEMO_DIR=${HOME_DIR}/demos_ws |
| 43 | +ENV IGNITION_VERSION=fortress |
| 44 | +ENV GZ_VERSION=fortress |
| 45 | + |
| 46 | +# Clone all space-ros sources |
| 47 | +RUN mkdir ${SPACEROS_DIR}/src \ |
| 48 | + && vcs import ${SPACEROS_DIR}/src < ${SPACEROS_DIR}/exact.repos |
| 49 | + |
| 50 | +# Define key locations |
| 51 | +RUN mkdir -p ${DEMO_DIR}/src |
| 52 | +WORKDIR ${DEMO_DIR} |
| 53 | + |
| 54 | + |
| 55 | +# Make sure the latest versions of packages are installed |
| 56 | +# Using Docker BuildKit cache mounts for /var/cache/apt and /var/lib/apt ensures that |
| 57 | +# the cache won't make it into the built image but will be maintained between steps. |
| 58 | +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ |
| 59 | + --mount=type=cache,target=/var/lib/apt,sharing=locked \ |
| 60 | + sudo apt-get update |
| 61 | +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ |
| 62 | + --mount=type=cache,target=/var/lib/apt,sharing=locked \ |
| 63 | + sudo apt-get dist-upgrade -y |
| 64 | +RUN rosdep update |
| 65 | + |
| 66 | +# Install the various build and test tools |
| 67 | +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ |
| 68 | + --mount=type=cache,target=/var/lib/apt,sharing=locked \ |
| 69 | + sudo apt install -y \ |
| 70 | + build-essential \ |
| 71 | + clang-format \ |
| 72 | + cmake \ |
| 73 | + git \ |
| 74 | + libbullet-dev \ |
| 75 | + python3-colcon-common-extensions \ |
| 76 | + python3-flake8 \ |
| 77 | + python3-pip \ |
| 78 | + python3-pytest-cov \ |
| 79 | + python3-rosdep \ |
| 80 | + python3-setuptools \ |
| 81 | + python3-vcstool \ |
| 82 | + wget |
| 83 | + |
| 84 | +# Install some pip packages needed for testing |
| 85 | +RUN python3 -m pip install -U \ |
| 86 | + argcomplete \ |
| 87 | + flake8-blind-except \ |
| 88 | + flake8-builtins \ |
| 89 | + flake8-class-newline \ |
| 90 | + flake8-comprehensions \ |
| 91 | + flake8-deprecated \ |
| 92 | + flake8-docstrings \ |
| 93 | + flake8-import-order \ |
| 94 | + flake8-quotes \ |
| 95 | + pytest-repeat \ |
| 96 | + pytest-rerunfailures \ |
| 97 | + pytest |
| 98 | + |
| 99 | +# Get rosinstall_generator |
| 100 | +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ |
| 101 | + --mount=type=cache,target=/var/lib/apt,sharing=locked \ |
| 102 | + sudo apt-get update -y && sudo apt-get install -y python3-rosinstall-generator |
| 103 | + |
| 104 | + |
| 105 | +# Generate repos file for dependencies, excluding packages from Space ROS core. |
| 106 | +COPY --chown=${USERNAME}:${USERNAME} demo-pkgs.txt /tmp/ |
| 107 | +COPY --chown=${USERNAME}:${USERNAME} excluded-pkgs.txt /tmp/ |
| 108 | +RUN rosinstall_generator \ |
| 109 | + --upstream \ |
| 110 | + --rosdistro ${ROSDISTRO} \ |
| 111 | + --deps \ |
| 112 | + --exclude-path ${SPACEROS_DIR}/src \ |
| 113 | + --exclude $(cat /tmp/excluded-pkgs.txt) -- \ |
| 114 | + -- $(cat /tmp/demo-pkgs.txt) \ |
| 115 | + > /tmp/demo_generated_pkgs.repos |
| 116 | + |
| 117 | +RUN vcs import src < /tmp/demo_generated_pkgs.repos |
| 118 | + |
| 119 | +# Get the source for the dependencies |
| 120 | +COPY --chown=${USERNAME}:${USERNAME} demo_manual_pkgs.repos /tmp/ |
| 121 | +RUN vcs import src < /tmp/demo_manual_pkgs.repos && /bin/bash -c 'source "${SPACEROS_DIR}/install/setup.bash"' |
| 122 | + |
| 123 | +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ |
| 124 | + --mount=type=cache,target=/var/lib/apt,sharing=locked \ |
| 125 | + sudo apt-get update -y \ |
| 126 | +&& /bin/bash -c 'source "${SPACEROS_DIR}/install/setup.bash"' \ |
| 127 | +&& rosdep install --from-paths src --ignore-src -r -y --rosdistro ${ROSDISTRO} |
| 128 | + |
| 129 | +ENV MAKEFLAGS="-j1" |
| 130 | + |
| 131 | +# build demo |
| 132 | +RUN /bin/bash -c 'source ${SPACEROS_DIR}/install/setup.bash \ |
| 133 | + && colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXPORT_COMPILE_COMMANDS=ON --event-handlers desktop_notification- status-' |
| 134 | + |
| 135 | + |
| 136 | +# Add the user to the render group so that the user can access /dev/dri/renderD128 |
| 137 | +RUN sudo usermod -aG render $USERNAME |
| 138 | + |
| 139 | +# Add a couple sample GUI apps for testing |
| 140 | +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ |
| 141 | + --mount=type=cache,target=/var/lib/apt,sharing=locked \ |
| 142 | + sudo apt-get install -y \ |
| 143 | + firefox \ |
| 144 | + glmark2 \ |
| 145 | + libcanberra-gtk3-0 \ |
| 146 | + libpci-dev \ |
| 147 | + xauth \ |
| 148 | + xterm |
| 149 | + |
| 150 | +# Setup the entrypoint |
| 151 | +COPY ./entrypoint.sh / |
| 152 | +ENTRYPOINT ["/entrypoint.sh"] |
| 153 | +CMD ["bash"] |
0 commit comments