Skip to content

Commit

Permalink
feat(docker): separation from autoware-universe stage to `autoware-…
Browse files Browse the repository at this point in the history
…universe-sensing-perception` stage (#5164)

* split depend stage

Signed-off-by: Yutaka Kondo <[email protected]>

* add s/p stage

Signed-off-by: Yutaka Kondo <[email protected]>

* fix

Signed-off-by: Yutaka Kondo <[email protected]>

* rename

Signed-off-by: Yutaka Kondo <[email protected]>

* fix

Signed-off-by: Yutaka Kondo <[email protected]>

* revert rename

Signed-off-by: Yutaka Kondo <[email protected]>

* Revert "revert rename"

This reverts commit 789ee21.

* simplify rosdep-depend

Signed-off-by: Yutaka Kondo <[email protected]>

---------

Signed-off-by: Yutaka Kondo <[email protected]>
  • Loading branch information
youtalk authored Sep 4, 2024
1 parent d5568e0 commit 42cba8b
Showing 1 changed file with 45 additions and 2 deletions.
47 changes: 45 additions & 2 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ 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
Expand All @@ -71,6 +72,17 @@ RUN rosdep keys --ignore-src --from-paths src \
| sort \
> /rosdep-universe-common-depend-packages.txt \
&& cat /rosdep-universe-common-depend-packages.txt

COPY src/universe/autoware.universe/perception /autoware/src/universe/autoware.universe/perception
COPY src/universe/autoware.universe/sensing /autoware/src/universe/autoware.universe/sensing
RUN rosdep keys --ignore-src --from-paths src \
| xargs rosdep resolve --rosdistro ${ROS_DISTRO} \
| grep -v '^#' \
| sed 's/ \+/\n/g'\
| sort \
> /rosdep-universe-sensing-perception-depend-packages.txt \
&& cat /rosdep-universe-sensing-perception-depend-packages.txt

COPY src/launcher /autoware/src/launcher
COPY src/param /autoware/src/param
COPY src/sensor_component /autoware/src/sensor_component
Expand All @@ -84,6 +96,7 @@ RUN rosdep keys --ignore-src --from-paths src \
| sort \
> /rosdep-universe-depend-packages.txt \
&& cat /rosdep-universe-depend-packages.txt

RUN rosdep keys --dependency-types=exec --ignore-src --from-paths src \
| xargs rosdep resolve --rosdistro ${ROS_DISTRO} \
| grep -v '^#' \
Expand Down Expand Up @@ -157,6 +170,37 @@ RUN --mount=type=cache,target=${CCACHE_DIR} \
&& du -sh ${CCACHE_DIR} && ccache -s \
&& rm -rf /autoware/build

FROM autoware-universe-common AS autoware-universe-sensing-perception
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
ARG ROS_DISTRO
ENV CCACHE_DIR="/root/.ccache"

# Install rosdep dependencies
COPY --from=rosdep-depend /rosdep-universe-sensing-perception-depend-packages.txt /tmp/rosdep-universe-sensing-perception-depend-packages.txt
# hadolint ignore=SC2002
RUN --mount=type=ssh \
apt-get update \
&& cat /tmp/rosdep-universe-sensing-perception-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

# hadolint ignore=SC1091
RUN --mount=type=cache,target=${CCACHE_DIR} \
--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/sensing,target=/autoware/src/universe/autoware.universe/sensing \
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

CMD ["/bin/bash"]

FROM autoware-universe-common AS autoware-universe
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
ARG ROS_DISTRO
Expand All @@ -170,6 +214,7 @@ 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

COPY --from=autoware-universe-sensing-perception /opt/autoware /opt/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 \
Expand All @@ -181,9 +226,7 @@ RUN --mount=type=cache,target=${CCACHE_DIR} \
--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 \
Expand Down

0 comments on commit 42cba8b

Please sign in to comment.