diff --git a/.circleci/config.yml b/.circleci/config.yml index a54fe5d281d..ec6a46b682e 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -74,6 +74,10 @@ references: rosdep install -q -y \ --from-paths src \ --ignore-src \ + --skip-keys " \ + gazebo11 \ + libgazebo11-dev \ + " \ --verbose | \ awk '$1 ~ /^resolution\:/' | \ awk -F'[][]' '{print $2}' | \ @@ -276,10 +280,6 @@ references: file: lcov/project_coverage.info flags: project when: always - install_deployment_key: &install_deployment_key - add_ssh_keys: - fingerprints: - - "0e:8e:90:bf:3d:a9:04:d9:04:b4:62:38:a5:3b:90:7d" commands: <<: *common_commands @@ -393,14 +393,14 @@ workflows: - release_build nightly: jobs: - - debug_build - - debug_test: - requires: - - debug_build + # - debug_build + # - debug_test: + # requires: + # - debug_build - release_build - - test_rmw_connext_cpp: - requires: - - release_build + # - test_rmw_connext_cpp: + # requires: + # - release_build - test_rmw_cyclonedds_cpp: requires: - release_build diff --git a/Dockerfile b/Dockerfile index 9ac07102cac..41864885202 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,32 +7,34 @@ # --build-arg UNDERLAY_MIXINS \ # --build-arg OVERLAY_MIXINS ./ ARG FROM_IMAGE=osrf/ros2:nightly +ARG UNDERLAY_WS=/opt/underlay_ws +ARG OVERLAY_WS=/opt/overlay_ws # multi-stage for caching -FROM $FROM_IMAGE AS cache +FROM $FROM_IMAGE AS cacher # clone underlay source -ENV UNDERLAY_WS /opt/underlay_ws -RUN mkdir -p $UNDERLAY_WS/src -WORKDIR $UNDERLAY_WS -COPY ./tools/ros2_dependencies.repos ./ -RUN vcs import src < ros2_dependencies.repos +ARG UNDERLAY_WS +WORKDIR $UNDERLAY_WS/src +COPY ./tools/ros2_dependencies.repos ../ +RUN vcs import ./ < ../ros2_dependencies.repos && \ + find ./ -name ".git" | xargs rm -rf # copy overlay source -ENV OVERLAY_WS /opt/overlay_ws -RUN mkdir -p $OVERLAY_WS/src -WORKDIR $OVERLAY_WS -COPY ./ src/navigation2 +ARG OVERLAY_WS +WORKDIR $OVERLAY_WS/src +COPY ./ ./navigation2 # copy manifests for caching WORKDIR /opt -RUN find ./ -name "package.xml" | \ - xargs cp --parents -t /tmp && \ +RUN mkdir -p /tmp/opt && \ + find ./ -name "package.xml" | \ + xargs cp --parents -t /tmp/opt && \ find ./ -name "COLCON_IGNORE" | \ - xargs cp --parents -t /tmp + xargs cp --parents -t /tmp/opt || true # multi-stage for building -FROM $FROM_IMAGE AS build +FROM $FROM_IMAGE AS builder # install CI dependencies RUN apt-get update && apt-get install -q -y \ @@ -40,63 +42,77 @@ RUN apt-get update && apt-get install -q -y \ lcov \ && rm -rf /var/lib/apt/lists/* -# copy underlay manifests -ENV UNDERLAY_WS /opt/underlay_ws -COPY --from=cache /tmp/underlay_ws $UNDERLAY_WS -WORKDIR $UNDERLAY_WS +# TODO: clean up once libgazebo11-dev released into ros2 repo +# https://github.com/ros-infrastructure/reprepro-updater/pull/75 +# https://github.com/ros/rosdistro/pull/24646 +# setup keys +RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys D2486D2DD83DB69272AFE98867170598AF249743 +# setup sources.list +RUN . /etc/os-release \ + && echo "deb http://packages.osrfoundation.org/gazebo/$ID-stable `lsb_release -sc` main" > /etc/apt/sources.list.d/gazebo-latest.list +# install gazebo packages +RUN apt-get update && apt-get install -q -y --no-install-recommends \ + libgazebo11-dev \ + && rm -rf /var/lib/apt/lists/* # install underlay dependencies +ARG UNDERLAY_WS +WORKDIR $UNDERLAY_WS +COPY --from=cacher /tmp/$UNDERLAY_WS ./ RUN . /opt/ros/$ROS_DISTRO/setup.sh && \ apt-get update && rosdep install -q -y \ --from-paths src \ --ignore-src \ + --skip-keys " \ + gazebo11 \ + libgazebo11-dev \ + " \ && rm -rf /var/lib/apt/lists/* -# copy underlay source -COPY --from=cache $UNDERLAY_WS ./ - # build underlay source +COPY --from=cacher $UNDERLAY_WS ./ ARG UNDERLAY_MIXINS="release ccache" ARG FAIL_ON_BUILD_FAILURE=True RUN . /opt/ros/$ROS_DISTRO/setup.sh && \ colcon build \ --symlink-install \ - --mixin \ - $UNDERLAY_MIXINS \ + --mixin $UNDERLAY_MIXINS \ --event-handlers console_direct+ \ || touch build_failed && \ if [ -f build_failed ] && [ -n "$FAIL_ON_BUILD_FAILURE" ]; then \ exit 1; \ fi -# copy overlay manifests -ENV OVERLAY_WS /opt/overlay_ws -COPY --from=cache /tmp/overlay_ws $OVERLAY_WS -WORKDIR $OVERLAY_WS - # install overlay dependencies +ARG OVERLAY_WS +WORKDIR $OVERLAY_WS +COPY --from=cacher /tmp/$OVERLAY_WS ./ RUN . $UNDERLAY_WS/install/setup.sh && \ apt-get update && rosdep install -q -y \ --from-paths src \ + $UNDERLAY_WS/src \ --ignore-src \ + --skip-keys " \ + gazebo11 \ + libgazebo11-dev \ + " \ && rm -rf /var/lib/apt/lists/* -# copy overlay source -COPY --from=cache $OVERLAY_WS ./ - # build overlay source +COPY --from=cacher $OVERLAY_WS ./ ARG OVERLAY_MIXINS="release ccache" RUN . $UNDERLAY_WS/install/setup.sh && \ colcon build \ --symlink-install \ - --mixin \ - $OVERLAY_MIXINS \ + --mixin $OVERLAY_MIXINS \ || touch build_failed && \ if [ -f build_failed ] && [ -n "$FAIL_ON_BUILD_FAILURE" ]; then \ exit 1; \ fi # source overlay from entrypoint +ENV UNDERLAY_WS $UNDERLAY_WS +ENV OVERLAY_WS $OVERLAY_WS RUN sed --in-place \ 's|^source .*|source "$OVERLAY_WS/install/setup.bash"|' \ /ros_entrypoint.sh diff --git a/release_branch.Dockerfile b/release_branch.Dockerfile deleted file mode 100644 index 3a03113420b..00000000000 --- a/release_branch.Dockerfile +++ /dev/null @@ -1,43 +0,0 @@ -# This dockerfile expects proxies to be set via --build-arg if needed -# It also expects to be contained in the /navigation2 root folder for file copy -# -# Example build command: -# export CMAKE_BUILD_TYPE=Debug -# docker build -t nav2:release_branch \ -# --build-arg FROM_IMAGE=dashing \ -# --build-arg CMAKE_BUILD_TYPE \ -# -f Dockerfile.release_branch ./ - -ARG FROM_IMAGE=dashing -FROM ros:$FROM_IMAGE - -RUN rosdep update - -# copy ros package repo -ENV NAV2_WS /opt/nav2_ws -RUN mkdir -p $NAV2_WS/src -WORKDIR $NAV2_WS/src -COPY ./ navigation2/ - -# install navigation2 package dependencies -WORKDIR $NAV2_WS -RUN . /opt/ros/$ROS_DISTRO/setup.sh && \ - apt-get update && \ - rosdep install -q -y \ - --from-paths \ - src \ - --ignore-src \ - && rm -rf /var/lib/apt/lists/* - -# build navigation2 package source -ARG CMAKE_BUILD_TYPE=Release -RUN . /opt/ros/$ROS_DISTRO/setup.sh && \ - colcon build \ - --symlink-install \ - --cmake-args \ - -DCMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE - -# source navigation2 workspace from entrypoint -RUN sed --in-place --expression \ - '$isource "$NAV2_WS/install/setup.bash"' \ - /ros_entrypoint.sh diff --git a/tools/release.Dockerfile b/tools/release.Dockerfile new file mode 100644 index 00000000000..2b89b534008 --- /dev/null +++ b/tools/release.Dockerfile @@ -0,0 +1,102 @@ +# syntax=docker/dockerfile:experimental + +# Use experimental buildkit for faster builds +# https://github.com/moby/buildkit/blob/master/frontend/dockerfile/docs/experimental.md +# Use `--progress=plain` to use plane stdout for docker build +# +# Example build command: +# export DOCKER_BUILDKIT=1 +# export FROM_IMAGE="ros:eloquent" +# export OVERLAY_MIXINS="release ccache" +# docker build -t nav2:release_branch \ +# --build-arg FROM_IMAGE \ +# --build-arg OVERLAY_MIXINS \ +# -f release_branch.Dockerfile ./ + +ARG FROM_IMAGE=ros:eloquent +ARG OVERLAY_WS=/opt/overlay_ws + +# multi-stage for caching +FROM $FROM_IMAGE AS cacher + +# copy overlay source +ARG OVERLAY_WS +WORKDIR $OVERLAY_WS/src +RUN echo "\ +repositories: \n\ + ros-planning/navigation2: \n\ + type: git \n\ + url: https://github.com/ros-planning/navigation2.git \n\ + version: ${ROS_DISTRO}-devel \n\ +" > ../overlay.repos +RUN vcs import ./ < ../overlay.repos && \ + find ./ -name ".git" | xargs rm -rf +# COPY ./ ./ros-planning/navigation2 + +# copy manifests for caching +WORKDIR /opt +RUN mkdir -p /tmp/opt && \ + find ./ -name "package.xml" | \ + xargs cp --parents -t /tmp/opt && \ + find ./ -name "COLCON_IGNORE" | \ + xargs cp --parents -t /tmp/opt || true + +# multi-stage for building +FROM $FROM_IMAGE AS builder + +# edit apt for caching +RUN cp /etc/apt/apt.conf.d/docker-clean /etc/apt/ && \ + echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' \ + > /etc/apt/apt.conf.d/docker-clean + +# install CI dependencies +RUN --mount=type=cache,target=/var/cache/apt \ + --mount=type=cache,target=/var/lib/apt \ + apt-get update && apt-get install -q -y \ + ccache \ + lcov \ + && rosdep update + +# install overlay dependencies +ARG OVERLAY_WS +WORKDIR $OVERLAY_WS +COPY --from=cacher /tmp/$OVERLAY_WS/src ./src +RUN --mount=type=cache,target=/var/cache/apt \ + --mount=type=cache,target=/var/lib/apt \ + . /opt/ros/$ROS_DISTRO/setup.sh && \ + apt-get update && rosdep install -q -y \ + --from-paths src \ + --ignore-src \ + && rm -rf /var/lib/apt/lists/* + +# build overlay source +COPY --from=cacher $OVERLAY_WS/src ./src +ARG OVERLAY_MIXINS="release ccache" +RUN --mount=type=cache,target=/root/.ccache \ + . /opt/ros/$ROS_DISTRO/setup.sh && \ + colcon build \ + --symlink-install \ + --mixin $OVERLAY_MIXINS + +# restore apt for docker +RUN mv /etc/apt/docker-clean /etc/apt/apt.conf.d/ && \ + rm -rf /var/lib/apt/lists/ + +# source overlay from entrypoint +ENV OVERLAY_WS $OVERLAY_WS +RUN sed --in-place \ + 's|^source .*|source "$OVERLAY_WS/install/setup.bash"|' \ + /ros_entrypoint.sh + +# ARG RUN_TESTS +# ARG FAIL_ON_TEST_FAILURE +# RUN if [ -z "$RUN_TESTS" ]; then \ +# colcon test \ +# --mixin $OVERLAY_MIXINS \ +# --ctest-args --test-regex "test_.*"; \ +# if [ -z "$FAIL_ON_TEST_FAILURE" ]; then \ +# colcon test-result; \ +# else \ +# colcon test-result || true; \ +# fi \ +# fi diff --git a/tools/ros2_dependencies.repos b/tools/ros2_dependencies.repos index b10c8af63ae..df9e1a177aa 100644 --- a/tools/ros2_dependencies.repos +++ b/tools/ros2_dependencies.repos @@ -1,21 +1,24 @@ repositories: - BehaviorTree.CPP: + BehaviorTree/BehaviorTree.CPP: type: git url: https://github.com/BehaviorTree/BehaviorTree.CPP.git version: master - angles: + ros/angles: type: git url: https://github.com/ros/angles.git version: ros2 - gazebo_ros_pkgs: + ros-simulation/gazebo_ros_pkgs: type: git url: https://github.com/ros-simulation/gazebo_ros_pkgs.git - version: ros2 - image_common: + # TODO: Revert after support for Gazebo v11 is merged + # https://github.com/ros-simulation/gazebo_ros_pkgs/pull/1093 + # version: ros2 + version: gazebo11_foxy + ros-perception/image_common: type: git url: https://github.com/ros-perception/image_common.git version: ros2 - vision_opencv: + ros-perception/vision_opencv: type: git url: https://github.com/ros-perception/vision_opencv.git version: ros2 diff --git a/full_ros_build.Dockerfile b/tools/source.Dockerfile similarity index 100% rename from full_ros_build.Dockerfile rename to tools/source.Dockerfile