Skip to content

Commit

Permalink
feat(docker): install colcon build artifacts to /opt/autoware ins…
Browse files Browse the repository at this point in the history
…tead of `/autoware/install` (#5117)
  • Loading branch information
youtalk authored Aug 22, 2024
1 parent b35b75c commit 91e8829
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 11 deletions.
30 changes: 21 additions & 9 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand All @@ -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"]

Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions docker/etc/ros_entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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" "$@"
Expand Down

0 comments on commit 91e8829

Please sign in to comment.