From 7a3def539d7e6721c9c82b3ef2c999e87370e0b3 Mon Sep 17 00:00:00 2001 From: Yutaka Kondo Date: Fri, 6 Sep 2024 13:57:38 +0900 Subject: [PATCH] feat(docker): add `universe-sensing-perception` runtime stage (#5172) * rename stages Signed-off-by: Yutaka Kondo * update docker-bake Signed-off-by: Yutaka Kondo * update actions Signed-off-by: Yutaka Kondo * fix target Signed-off-by: Yutaka Kondo * fix inherits Signed-off-by: Yutaka Kondo * feat(docker): separation from `autoware-universe` stage to `autoware-universe-sensing-perception` stage (#5164) * split depend stage Signed-off-by: Yutaka Kondo * add s/p stage Signed-off-by: Yutaka Kondo * fix Signed-off-by: Yutaka Kondo * rename Signed-off-by: Yutaka Kondo * fix Signed-off-by: Yutaka Kondo * revert rename Signed-off-by: Yutaka Kondo * Revert "revert rename" This reverts commit 789ee21e00f65cc3f09b29614e266c54d9ec9b05. * simplify rosdep-depend Signed-off-by: Yutaka Kondo --------- Signed-off-by: Yutaka Kondo * fix rebase Signed-off-by: Yutaka Kondo * rename stages Signed-off-by: Yutaka Kondo * fix bake Signed-off-by: Yutaka Kondo * fix dockerfile Signed-off-by: Yutaka Kondo * fix merge Signed-off-by: Yutaka Kondo * add universe-sensing-perception stage Signed-off-by: Yutaka Kondo * update config Signed-off-by: Yutaka Kondo --------- Signed-off-by: Yutaka Kondo --- .../actions/docker-build-and-push/action.yaml | 24 +++++++++++ docker/Dockerfile | 41 +++++++++++++++++++ docker/docker-bake.hcl | 23 ++++++++++- 3 files changed, 87 insertions(+), 1 deletion(-) diff --git a/.github/actions/docker-build-and-push/action.yaml b/.github/actions/docker-build-and-push/action.yaml index 1dda6a4439f..a4e158fbff9 100644 --- a/.github/actions/docker-build-and-push/action.yaml +++ b/.github/actions/docker-build-and-push/action.yaml @@ -111,6 +111,28 @@ runs: latest=false suffix=-core-devel${{ inputs.tag-suffix }} + - name: Docker meta for autoware:universe-sensing-perception-devel + id: meta-universe-sensing-perception-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-sensing-perception-devel + flavor: | + latest=false + suffix=-universe-sensing-perception-devel${{ inputs.tag-suffix }} + + - name: Docker meta for autoware:universe-sensing-perception + id: meta-universe-sensing-perception + 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-sensing-perception + flavor: | + latest=false + suffix=-universe-sensing-perception${{ inputs.tag-suffix }} + - name: Docker meta for autoware:universe-devel id: meta-universe-devel uses: docker/metadata-action@v5 @@ -148,6 +170,8 @@ runs: docker/docker-bake.hcl ${{ steps.meta-base.outputs.bake-file }} ${{ 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-devel.outputs.bake-file }} ${{ steps.meta-universe.outputs.bake-file }} provenance: false diff --git a/docker/Dockerfile b/docker/Dockerfile index 8f62a41003b..9e62ce5a02e 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -85,6 +85,13 @@ RUN rosdep keys --ignore-src --from-paths src \ | sort \ > /rosdep-universe-sensing-perception-depend-packages.txt \ && cat /rosdep-universe-sensing-perception-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-sensing-perception-exec-depend-packages.txt \ + && cat /rosdep-universe-sensing-perception-exec-depend-packages.txt COPY src/launcher /autoware/src/launcher COPY src/param /autoware/src/param @@ -258,6 +265,40 @@ RUN --mount=type=cache,target=${CCACHE_DIR} \ ENTRYPOINT ["/ros_entrypoint.sh"] CMD ["/bin/bash"] +FROM base AS universe-sensing-perception +SHELL ["/bin/bash", "-o", "pipefail", "-c"] +ARG ROS_DISTRO +ARG LIB_DIR +ARG SETUP_ARGS + +# Set up runtime environment and artifacts +COPY --from=rosdep-depend /rosdep-universe-sensing-perception-exec-depend-packages.txt /tmp/rosdep-universe-sensing-perception-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} --download-artifacts --no-cuda-drivers --runtime openadkit \ + && pip uninstall -y ansible ansible-core \ + && apt-get update \ + && cat /tmp/rosdep-universe-sensing-perception-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-sensing-perception-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/docker-bake.hcl b/docker/docker-bake.hcl index 7e48cbf8b1d..4360c907329 100644 --- a/docker/docker-bake.hcl +++ b/docker/docker-bake.hcl @@ -1,10 +1,19 @@ group "default" { - targets = ["base", "core-devel", "universe-devel", "universe"] + targets = [ + "base", + "core-devel", + "universe-sensing-perception-devel", + "universe-sensing-perception", + "universe-devel", + "universe" + ] } // For docker/metadata-action 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-devel" {} target "docker-metadata-action-universe" {} @@ -20,6 +29,18 @@ target "core-devel" { target = "core-devel" } +target "universe-sensing-perception-devel" { + inherits = ["docker-metadata-action-universe-sensing-perception-devel"] + dockerfile = "docker/Dockerfile" + target = "universe-sensing-perception-devel" +} + +target "universe-sensing-perception" { + inherits = ["docker-metadata-action-universe-sensing-perception"] + dockerfile = "docker/Dockerfile" + target = "universe-sensing-perception" +} + target "universe-devel" { inherits = ["docker-metadata-action-universe-devel"] dockerfile = "docker/Dockerfile"