From 2904e9f84b40d00ddd6daa3c913efb18f294fb44 Mon Sep 17 00:00:00 2001 From: Yutaka Kondo Date: Mon, 9 Sep 2024 18:10:46 +0900 Subject: [PATCH] feat(docker): add `universe-localization-mapping` runtime image (#5189) --- .../actions/docker-build-and-push/action.yaml | 24 +++++++++++ docker/Dockerfile | 41 +++++++++++++++++++ docker/README.md | 4 ++ docker/docker-bake.hcl | 16 ++++++++ 4 files changed, 85 insertions(+) diff --git a/.github/actions/docker-build-and-push/action.yaml b/.github/actions/docker-build-and-push/action.yaml index a4e158fbff9..4c9ab208345 100644 --- a/.github/actions/docker-build-and-push/action.yaml +++ b/.github/actions/docker-build-and-push/action.yaml @@ -133,6 +133,28 @@ runs: latest=false suffix=-universe-sensing-perception${{ inputs.tag-suffix }} + - name: Docker meta for autoware:universe-localization-mapping-devel + id: meta-universe-localization-mapping-devel + uses: docker/metadata-action@v5 + with: + images: ghcr.io/${{ github.repository_owner }}/${{ inputs.bake-target }} + tags: ${{ steps.set-docker-tags.outputs.tags }} + bake-target: docker-metadata-action-universe-localization-mapping-devel + flavor: | + latest=false + suffix=-universe-localization-mapping-devel${{ inputs.tag-suffix }} + + - name: Docker meta for autoware:universe-localization-mapping + id: meta-universe-localization-mapping + uses: docker/metadata-action@v5 + with: + images: ghcr.io/${{ github.repository_owner }}/${{ inputs.bake-target }} + tags: ${{ steps.set-docker-tags.outputs.tags }} + bake-target: docker-metadata-action-universe-localization-mapping + flavor: | + latest=false + suffix=-universe-localization-mapping${{ inputs.tag-suffix }} + - name: Docker meta for autoware:universe-devel id: meta-universe-devel uses: docker/metadata-action@v5 @@ -172,6 +194,8 @@ runs: ${{ steps.meta-core-devel.outputs.bake-file }} ${{ steps.meta-universe-sensing-perception-devel.outputs.bake-file }} ${{ steps.meta-universe-sensing-perception.outputs.bake-file }} + ${{ steps.meta-universe-localization-mapping-devel.outputs.bake-file }} + ${{ steps.meta-universe-localization-mapping.outputs.bake-file }} ${{ steps.meta-universe-devel.outputs.bake-file }} ${{ steps.meta-universe.outputs.bake-file }} provenance: false diff --git a/docker/Dockerfile b/docker/Dockerfile index edb8d78ba7c..be8fd88541d 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -110,6 +110,13 @@ RUN rosdep keys --ignore-src --from-paths src \ | sort \ > /rosdep-universe-localization-mapping-depend-packages.txt \ && cat /rosdep-universe-localization-mapping-depend-packages.txt +RUN rosdep keys --dependency-types=exec --ignore-src --from-paths src \ + | xargs rosdep resolve --rosdistro ${ROS_DISTRO} \ + | grep -v '^#' \ + | sed 's/ \+/\n/g'\ + | sort \ + > /rosdep-universe-localization-mapping-exec-depend-packages.txt \ + && cat /rosdep-universe-localization-mapping-exec-depend-packages.txt FROM rosdep-depend AS rosdep-universe-depend SHELL ["/bin/bash", "-o", "pipefail", "-c"] @@ -352,6 +359,40 @@ RUN echo "source /opt/autoware/setup.bash" > /etc/bash.bashrc ENTRYPOINT ["/ros_entrypoint.sh"] CMD ["/bin/bash"] +FROM base AS universe-localization-mapping +SHELL ["/bin/bash", "-o", "pipefail", "-c"] +ARG ROS_DISTRO +ARG LIB_DIR +ARG SETUP_ARGS + +# Set up runtime environment and artifacts +COPY --from=rosdep-universe-localization-mapping-depend /rosdep-universe-localization-mapping-exec-depend-packages.txt /tmp/rosdep-universe-localization-mapping-exec-depend-packages.txt +# hadolint ignore=SC2002 +RUN --mount=type=ssh \ + --mount=type=cache,target=/var/cache/apt,sharing=locked \ + ./setup-dev-env.sh -y --module all ${SETUP_ARGS} --no-cuda-drivers --runtime openadkit \ + && pip uninstall -y ansible ansible-core \ + && apt-get update \ + && cat /tmp/rosdep-universe-localization-mapping-exec-depend-packages.txt | xargs apt-get install -y --no-install-recommends \ + && apt-get autoremove -y && rm -rf "$HOME"/.cache \ + && find /usr/lib/$LIB_DIR-linux-gnu -name "*.a" -type f -delete \ + && find / -name "*.o" -type f -delete \ + && find / -name "*.h" -type f -delete \ + && find / -name "*.hpp" -type f -delete \ + && rm -rf /autoware/ansible \ + /root/.local/pipx /opt/ros/"$ROS_DISTRO"/include /etc/apt/sources.list.d/cuda*.list \ + /etc/apt/sources.list.d/docker.list /etc/apt/sources.list.d/nvidia-docker.list \ + /usr/include /usr/share/doc /usr/lib/gcc /usr/lib/jvm /usr/lib/llvm* + +COPY --from=universe-localization-mapping-devel /opt/autoware /opt/autoware + +# Copy bash aliases +COPY docker/etc/.bash_aliases /root/.bash_aliases +RUN echo "source /opt/autoware/setup.bash" > /etc/bash.bashrc + +ENTRYPOINT ["/ros_entrypoint.sh"] +CMD ["/bin/bash"] + FROM base AS universe SHELL ["/bin/bash", "-o", "pipefail", "-c"] ARG ROS_DISTRO diff --git a/docker/README.md b/docker/README.md index 91f959b6197..f9e58ca22ee 100644 --- a/docker/README.md +++ b/docker/README.md @@ -61,6 +61,10 @@ This stage installs the dependency packages based on `/rosdep-universe-localizat - `universe/autoware.universe/localization` - `universe/autoware.universe/map` +### `universe-localization-mapping` + +This stage is a Autoware Universe Localization/Mapping runtime container. It only includes the dependencies given by `/rosdep-universe-localization-mapping-exec-depend-packages.txt` and the binaries built in the `universe-localization-mapping-devel` stage. + ### `universe-devel` This stage installs the dependency packages based on `/rosdep-universe-depend-packages.txt` and build the remaining packages of `autoware.repos`: diff --git a/docker/docker-bake.hcl b/docker/docker-bake.hcl index 4360c907329..274f5725a41 100644 --- a/docker/docker-bake.hcl +++ b/docker/docker-bake.hcl @@ -4,6 +4,8 @@ group "default" { "core-devel", "universe-sensing-perception-devel", "universe-sensing-perception", + "universe-localization-mapping-devel", + "universe-localization-mapping", "universe-devel", "universe" ] @@ -14,6 +16,8 @@ target "docker-metadata-action-base" {} target "docker-metadata-action-core-devel" {} target "docker-metadata-action-universe-sensing-perception-devel" {} target "docker-metadata-action-universe-sensing-perception" {} +target "docker-metadata-action-universe-localization-mapping-devel" {} +target "docker-metadata-action-universe-localization-mapping" {} target "docker-metadata-action-universe-devel" {} target "docker-metadata-action-universe" {} @@ -41,6 +45,18 @@ target "universe-sensing-perception" { target = "universe-sensing-perception" } +target "universe-localization-mapping-devel" { + inherits = ["docker-metadata-action-universe-localization-mapping-devel"] + dockerfile = "docker/Dockerfile" + target = "universe-localization-mapping-devel" +} + +target "universe-localization-mapping" { + inherits = ["docker-metadata-action-universe-localization-mapping"] + dockerfile = "docker/Dockerfile" + target = "universe-localization-mapping" +} + target "universe-devel" { inherits = ["docker-metadata-action-universe-devel"] dockerfile = "docker/Dockerfile"