Skip to content

Commit

Permalink
refactor(docker): replace the multiple colcon commands with `build_…
Browse files Browse the repository at this point in the history
…and_clean.sh`. (#5425)

* run resolve_rosdep_keys.sh

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

* style(pre-commit): autofix

* update .dockerignore

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

* chmod +x

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

* fix location

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

* remove rosdep update

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

* run build_and_clean.sh

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

* style(pre-commit): autofix

---------

Signed-off-by: Yutaka Kondo <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
youtalk and pre-commit-ci[bot] authored Nov 12, 2024
1 parent e637867 commit 7aed5b5
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 72 deletions.
83 changes: 11 additions & 72 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,9 @@ SHELL ["/bin/bash", "-o", "pipefail", "-c"]
ARG ROS_DISTRO
ENV CCACHE_DIR="/root/.ccache"

COPY docker/scripts/build_and_clean.sh /autoware/build_and_clean.sh
RUN chmod +x /autoware/build_and_clean.sh

# Set up development environment and tools
RUN --mount=type=ssh \
--mount=type=cache,target=/var/cache/apt,sharing=locked \
Expand All @@ -177,15 +180,7 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
RUN --mount=type=cache,target=${CCACHE_DIR} \
--mount=type=bind,from=rosdep-depend,source=/autoware/src/core,target=/autoware/src/core \
source /opt/ros/"$ROS_DISTRO"/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 /autoware/log
&& /autoware/build_and_clean.sh ${CCACHE_DIR} /opt/autoware

ENTRYPOINT ["/ros_entrypoint.sh"]
CMD ["/bin/bash"]
Expand All @@ -209,15 +204,7 @@ RUN --mount=type=cache,target=${CCACHE_DIR} \
--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 /autoware/log
&& /autoware/build_and_clean.sh ${CCACHE_DIR} /opt/autoware

ENTRYPOINT ["/ros_entrypoint.sh"]
CMD ["/bin/bash"]
Expand Down Expand Up @@ -254,15 +241,7 @@ RUN --mount=type=cache,target=${CCACHE_DIR} \
--mount=type=bind,from=rosdep-universe-sensing-perception-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 /autoware/log
&& /autoware/build_and_clean.sh ${CCACHE_DIR} /opt/autoware

ENTRYPOINT ["/ros_entrypoint.sh"]
CMD ["/bin/bash"]
Expand Down Expand Up @@ -296,15 +275,7 @@ RUN --mount=type=cache,target=${CCACHE_DIR} \
--mount=type=bind,from=rosdep-universe-sensing-perception-depend,source=/autoware/src/universe/autoware.universe/sensing/autoware_cuda_utils,target=/autoware/src/universe/autoware.universe/sensing/autoware_cuda_utils \
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
&& /autoware/build_and_clean.sh ${CCACHE_DIR} /opt/autoware

COPY --from=universe-sensing-perception-devel /opt/autoware /opt/autoware

Expand All @@ -330,15 +301,7 @@ RUN --mount=type=cache,target=${CCACHE_DIR} \
--mount=type=bind,from=rosdep-universe-localization-mapping-depend,source=/autoware/src/universe/autoware.universe/map,target=/autoware/src/universe/autoware.universe/map \
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 /autoware/log
&& /autoware/build_and_clean.sh ${CCACHE_DIR} /opt/autoware

FROM universe-common-devel AS universe-planning-control-devel
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
Expand All @@ -364,15 +327,7 @@ RUN --mount=type=cache,target=${CCACHE_DIR} \
--mount=type=bind,from=rosdep-universe-planning-control-depend,source=/autoware/src/universe/autoware.universe/sensing/autoware_pointcloud_preprocessor,target=/autoware/src/universe/autoware.universe/sensing/autoware_pointcloud_preprocessor \
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 /autoware/log
&& /autoware/build_and_clean.sh ${CCACHE_DIR} /opt/autoware

ENTRYPOINT ["/ros_entrypoint.sh"]
CMD ["/bin/bash"]
Expand All @@ -398,15 +353,7 @@ RUN --mount=type=cache,target=${CCACHE_DIR} \
--mount=type=bind,from=rosdep-universe-vehicle-system-depend,source=/autoware/src/universe/autoware.universe/localization/autoware_pose2twist,target=/autoware/src/universe/autoware.universe/localization/autoware_pose2twist \
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 /autoware/log
&& /autoware/build_and_clean.sh ${CCACHE_DIR} /opt/autoware

ENTRYPOINT ["/ros_entrypoint.sh"]
CMD ["/bin/bash"]
Expand Down Expand Up @@ -441,15 +388,7 @@ RUN --mount=type=cache,target=${CCACHE_DIR} \
--mount=type=bind,from=rosdep-universe-depend,source=/autoware/src/vehicle,target=/autoware/src/vehicle \
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 /autoware/log
&& /autoware/build_and_clean.sh ${CCACHE_DIR} /opt/autoware

ENTRYPOINT ["/ros_entrypoint.sh"]
CMD ["/bin/bash"]
Expand Down
18 changes: 18 additions & 0 deletions docker/scripts/build_and_clean.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

function build_and_clean() {
local ccache_dir=$1
local install_base=$2

du -sh "$ccache_dir" && ccache -s &&
colcon build --cmake-args \
" -Wno-dev" \
" --no-warn-unused-cli" \
--merge-install \
--install-base "$install_base" \
--mixin release compile-commands ccache &&
du -sh "$ccache_dir" && ccache -s &&
rm -rf /autoware/build /autoware/log
}

build_and_clean "$@"

0 comments on commit 7aed5b5

Please sign in to comment.