From 28deda860b351a6d27f78e7413362a455bc951a1 Mon Sep 17 00:00:00 2001 From: Yutaka Kondo Date: Tue, 3 Sep 2024 19:08:24 +0900 Subject: [PATCH] feat(docker): introduce `autoware-universe-common` stage (#5157) * add universe-common stage Signed-off-by: Yutaka Kondo * create -common list Signed-off-by: Yutaka Kondo * install dummy Signed-off-by: Yutaka Kondo * Revert "create -common list" This reverts commit 0b478c19bacb9e66f2d202ba08ec53bf5dff1d12. * Revert "Revert "create -common list"" This reverts commit a682ee3347fe0bc2b8b5c783800f0d9596d5a2c5. * move launcher to universe Signed-off-by: Yutaka Kondo * reorder Signed-off-by: Yutaka Kondo * reorder Signed-off-by: Yutaka Kondo * copy 2 packages Signed-off-by: Yutaka Kondo * mount 2 packages Signed-off-by: Yutaka Kondo * add todo Signed-off-by: Yutaka Kondo * remove linefeed Signed-off-by: Yutaka Kondo --------- Signed-off-by: Yutaka Kondo --- docker/Dockerfile | 61 +++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 57 insertions(+), 4 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index f6c7153e2a0..440a3192bfa 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -58,6 +58,18 @@ RUN rosdep update && rosdep keys --ignore-src --from-paths src \ | sort \ > /rosdep-core-depend-packages.txt \ && cat /rosdep-core-depend-packages.txt +COPY src/universe/external /autoware/src/universe/external +COPY src/universe/autoware.universe/common /autoware/src/universe/autoware.universe/common +# TODO(youtalk): Remove COPYs when https://github.com/autowarefoundation/autoware.universe/issues/8695 is resolved +COPY src/universe/autoware.universe/simulator/dummy_perception_publisher /autoware/src/universe/autoware.universe/simulator/dummy_perception_publisher +COPY src/universe/autoware.universe/vehicle/autoware_vehicle_info_utils /autoware/src/universe/autoware.universe/vehicle/autoware_vehicle_info_utils +RUN rosdep keys --ignore-src --from-paths src \ + | xargs rosdep resolve --rosdistro ${ROS_DISTRO} \ + | grep -v '^#' \ + | sed 's/ \+/\n/g'\ + | sort \ + > /rosdep-universe-common-depend-packages.txt \ + && cat /rosdep-universe-common-depend-packages.txt COPY src/launcher /autoware/src/launcher COPY src/param /autoware/src/param COPY src/sensor_component /autoware/src/sensor_component @@ -113,10 +125,41 @@ RUN --mount=type=cache,target=${CCACHE_DIR} \ && du -sh ${CCACHE_DIR} && ccache -s \ && rm -rf /autoware/build -FROM autoware-core AS autoware-universe +FROM autoware-core AS autoware-universe-common +SHELL ["/bin/bash", "-o", "pipefail", "-c"] +ARG ROS_DISTRO +ENV CCACHE_DIR="/root/.ccache" + +# Install rosdep dependencies +COPY --from=rosdep-depend /rosdep-universe-common-depend-packages.txt /tmp/rosdep-universe-common-depend-packages.txt +# hadolint ignore=SC2002 +RUN --mount=type=ssh \ + apt-get update \ + && cat /tmp/rosdep-universe-common-depend-packages.txt | xargs apt-get install -y --no-install-recommends \ + && apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/* "$HOME"/.cache + +# TODO(youtalk): Remove COPYs when https://github.com/autowarefoundation/autoware.universe/issues/8695 is resolved +# hadolint ignore=SC1091 +RUN --mount=type=cache,target=${CCACHE_DIR} \ + --mount=type=bind,from=rosdep-depend,source=/autoware/src/universe/autoware.universe/common,target=/autoware/src/universe/autoware.universe/common \ + --mount=type=bind,from=rosdep-depend,source=/autoware/src/universe/autoware.universe/simulator/dummy_perception_publisher,target=/autoware/src/universe/autoware.universe/simulator/dummy_perception_publisher \ + --mount=type=bind,from=rosdep-depend,source=/autoware/src/universe/autoware.universe/vehicle/autoware_vehicle_info_utils,target=/autoware/src/universe/autoware.universe/vehicle/autoware_vehicle_info_utils \ + --mount=type=bind,from=rosdep-depend,source=/autoware/src/universe/external,target=/autoware/src/universe/external \ + source /opt/ros/"$ROS_DISTRO"/setup.bash \ + && source /opt/autoware/setup.bash \ + && du -sh ${CCACHE_DIR} && ccache -s \ + && colcon build --cmake-args \ + " -Wno-dev" \ + " --no-warn-unused-cli" \ + --merge-install \ + --install-base /opt/autoware \ + --mixin release compile-commands ccache \ + && du -sh ${CCACHE_DIR} && ccache -s \ + && rm -rf /autoware/build + +FROM autoware-universe-common AS autoware-universe SHELL ["/bin/bash", "-o", "pipefail", "-c"] ARG ROS_DISTRO -ARG SETUP_ARGS ENV CCACHE_DIR="/root/.ccache" # Install rosdep dependencies @@ -127,14 +170,24 @@ RUN --mount=type=ssh \ && cat /tmp/rosdep-universe-depend-packages.txt | xargs apt-get install -y --no-install-recommends \ && apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/* "$HOME"/.cache -# Build Autoware # hadolint ignore=SC1091 RUN --mount=type=cache,target=${CCACHE_DIR} \ --mount=type=bind,from=rosdep-depend,source=/autoware/src/launcher,target=/autoware/src/launcher \ --mount=type=bind,from=rosdep-depend,source=/autoware/src/param,target=/autoware/src/param \ --mount=type=bind,from=rosdep-depend,source=/autoware/src/sensor_component,target=/autoware/src/sensor_component \ --mount=type=bind,from=rosdep-depend,source=/autoware/src/sensor_kit,target=/autoware/src/sensor_kit \ - --mount=type=bind,from=rosdep-depend,source=/autoware/src/universe,target=/autoware/src/universe \ + --mount=type=bind,from=rosdep-depend,source=/autoware/src/universe/autoware.universe/control,target=/autoware/src/universe/autoware.universe/control \ + --mount=type=bind,from=rosdep-depend,source=/autoware/src/universe/autoware.universe/evaluator,target=/autoware/src/universe/autoware.universe/evaluator \ + --mount=type=bind,from=rosdep-depend,source=/autoware/src/universe/autoware.universe/launch,target=/autoware/src/universe/autoware.universe/launch \ + --mount=type=bind,from=rosdep-depend,source=/autoware/src/universe/autoware.universe/localization,target=/autoware/src/universe/autoware.universe/localization \ + --mount=type=bind,from=rosdep-depend,source=/autoware/src/universe/autoware.universe/map,target=/autoware/src/universe/autoware.universe/map \ + --mount=type=bind,from=rosdep-depend,source=/autoware/src/universe/autoware.universe/perception,target=/autoware/src/universe/autoware.universe/perception \ + --mount=type=bind,from=rosdep-depend,source=/autoware/src/universe/autoware.universe/planning,target=/autoware/src/universe/autoware.universe/planning \ + --mount=type=bind,from=rosdep-depend,source=/autoware/src/universe/autoware.universe/sensing,target=/autoware/src/universe/autoware.universe/sensing \ + --mount=type=bind,from=rosdep-depend,source=/autoware/src/universe/autoware.universe/simulator,target=/autoware/src/universe/autoware.universe/simulator \ + --mount=type=bind,from=rosdep-depend,source=/autoware/src/universe/autoware.universe/system,target=/autoware/src/universe/autoware.universe/system \ + --mount=type=bind,from=rosdep-depend,source=/autoware/src/universe/autoware.universe/tools,target=/autoware/src/universe/autoware.universe/tools \ + --mount=type=bind,from=rosdep-depend,source=/autoware/src/universe/autoware.universe/vehicle,target=/autoware/src/universe/autoware.universe/vehicle \ --mount=type=bind,from=rosdep-depend,source=/autoware/src/vehicle,target=/autoware/src/vehicle \ source /opt/ros/"$ROS_DISTRO"/setup.bash \ && source /opt/autoware/setup.bash \