diff --git a/docker/Dockerfile b/docker/Dockerfile index ff2c2a55657..f6c7153e2a0 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -100,15 +100,18 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ && cat /tmp/rosdep-core-depend-packages.txt | xargs apt-get install -y --no-install-recommends \ && apt-get autoremove -y && rm -rf "$HOME"/.cache -RUN --mount=type=bind,from=rosdep-depend,source=/autoware/src/core,target=/autoware/src/core \ - --mount=type=cache,target=${CCACHE_DIR} \ +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 + && du -sh ${CCACHE_DIR} && ccache -s \ + && rm -rf /autoware/build FROM autoware-core AS autoware-universe SHELL ["/bin/bash", "-o", "pipefail", "-c"] @@ -125,15 +128,25 @@ RUN --mount=type=ssh \ && apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/* "$HOME"/.cache # Build Autoware -RUN --mount=type=bind,from=rosdep-depend,source=/autoware/src,target=/autoware/src \ - --mount=type=cache,target=${CCACHE_DIR} \ +# 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/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 + && du -sh ${CCACHE_DIR} && ccache -s \ + && rm -rf /autoware/build CMD ["/bin/bash"] @@ -147,7 +160,6 @@ RUN --mount=type=ssh \ && pip uninstall -y ansible ansible-core \ && apt-get autoremove -y && rm -rf "$HOME"/.cache -COPY src /autoware/src # Create entrypoint COPY docker/etc/ros_entrypoint.sh /ros_entrypoint.sh RUN chmod +x /ros_entrypoint.sh @@ -179,11 +191,11 @@ RUN --mount=type=ssh \ /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=autoware-universe /autoware/install/ /autoware/install/ +COPY --from=autoware-universe /opt/autoware /opt/autoware # Copy bash aliases COPY docker/etc/.bash_aliases /root/.bash_aliases -RUN echo "source /autoware/install/setup.bash" > /etc/bash.bashrc +RUN echo "source /opt/autoware/setup.bash" > /etc/bash.bashrc # Create entrypoint COPY docker/etc/ros_entrypoint.sh /ros_entrypoint.sh diff --git a/docker/etc/ros_entrypoint.sh b/docker/etc/ros_entrypoint.sh index cbe45ef3bdb..25484312db6 100644 --- a/docker/etc/ros_entrypoint.sh +++ b/docker/etc/ros_entrypoint.sh @@ -10,7 +10,7 @@ GROUP_NAME=${LOCAL_GROUP} # Check if any of the variables are empty if [[ -z $USER_ID || -z $USER_NAME || -z $GROUP_ID || -z $GROUP_NAME ]]; then source "/opt/ros/$ROS_DISTRO/setup.bash" - source /autoware/install/setup.bash + source /opt/autoware/setup.bash exec "$@" else echo "Starting with user: $USER_NAME >> UID $USER_ID, GID: $GROUP_ID" @@ -25,7 +25,7 @@ else # Source ROS2 # hadolint ignore=SC1090 source "/opt/ros/$ROS_DISTRO/setup.bash" - source /autoware/install/setup.bash + source /opt/autoware/setup.bash # Execute the command as the user exec /usr/sbin/gosu "$USER_NAME" "$@"