Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(docker): introduce autoware-core stage #4710

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 58 additions & 17 deletions docker/autoware-openadk/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,20 @@ RUN --mount=type=ssh \
# Create entrypoint
CMD ["/bin/bash"]

FROM base as prebuilt
FROM $BASE_IMAGE as src-imported
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
WORKDIR /autoware
COPY autoware.repos /autoware/
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y install --no-install-recommends \
ros-dev-tools \
&& apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/* "$HOME"/.cache
RUN --mount=type=ssh \
mkdir src \
&& vcs import src < autoware.repos

FROM base as openadk-base
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
ARG ROS_DISTRO
ARG SETUP_ARGS
ENV CCACHE_DIR="/var/tmp/ccache"
ENV CC="/usr/lib/ccache/gcc"
ENV CXX="/usr/lib/ccache/g++"

# cspell: ignore libcu libnv
# Set up development environment
Expand All @@ -56,14 +63,17 @@ RUN --mount=type=ssh \
&& find / -name 'libcu*.a' -delete \
&& find / -name 'libnv*.a' -delete

# Copy repository files
COPY autoware.repos /autoware/
FROM openadk-base as autoware-core
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
ARG ROS_DISTRO
ENV CCACHE_DIR="/var/tmp/ccache"
ENV CC="/usr/lib/ccache/gcc"
ENV CXX="/usr/lib/ccache/g++"

# Install rosdep dependencies
# Install rosdep dependencies and build core packages
COPY --from=src-imported /autoware/src/core /autoware/src/core
RUN --mount=type=ssh \
mkdir src \
&& vcs import src < autoware.repos \
&& apt-get update \
apt-get update \
&& rosdep update \
&& DEBIAN_FRONTEND=noninteractive rosdep install -y --ignore-src --from-paths src --rosdistro "$ROS_DISTRO" \
&& source /opt/ros/"$ROS_DISTRO"/setup.bash \
Expand All @@ -79,6 +89,37 @@ RUN --mount=type=ssh \

CMD ["/bin/bash"]

FROM openadk-base as prebuilt
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
ARG ROS_DISTRO
ENV CCACHE_DIR="/var/tmp/ccache"
ENV CC="/usr/lib/ccache/gcc"
ENV CXX="/usr/lib/ccache/g++"

# Install rosdep dependencies and build the other packages
COPY --from=src-imported /autoware/src/launcher /autoware/src/launcher
COPY --from=src-imported /autoware/src/param /autoware/src/param
COPY --from=src-imported /autoware/src/sensor_component /autoware/src/sensor_component
COPY --from=src-imported /autoware/src/sensor_kit /autoware/src/sensor_kit
COPY --from=src-imported /autoware/src/universe /autoware/src/universe
COPY --from=autoware-core /autoware/install /opt/autoware/
# hadolint ignore=SC1091
RUN --mount=type=ssh \
apt-get update \
&& rosdep update \
&& DEBIAN_FRONTEND=noninteractive rosdep install -y --ignore-src --from-paths src --rosdistro "$ROS_DISTRO" \
&& source /opt/ros/"$ROS_DISTRO"/setup.bash \
&& source /opt/autoware/setup.bash \
&& colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release --cmake-args \
" -Wno-dev" \
" --no-warn-unused-cli" \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
&& find /autoware/install -type d -exec chmod 777 {} \; \
&& chmod -R 777 /var/tmp/ccache \
&& apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/* "$HOME"/.cache \
&& rm -rf /autoware/build /autoware/src

FROM prebuilt as devel
SHELL ["/bin/bash", "-o", "pipefail", "-c"]

Expand All @@ -101,30 +142,30 @@ ARG LIB_DIR
ARG SETUP_ARGS

# Set up runtime environment and artifacts
COPY autoware.repos /autoware/
COPY --from=src-imported /autoware/src /autoware/src
RUN --mount=type=ssh \
./setup-dev-env.sh -y --module all ${SETUP_ARGS} --download-artifacts --no-cuda-drivers --runtime openadk \
&& pip uninstall -y ansible ansible-core \
&& mkdir src \
&& vcs import src < autoware.repos \
&& apt-get update \
&& rosdep update \
&& DEBIAN_FRONTEND=noninteractive rosdep install -y --dependency-types=exec --ignore-src --from-paths src --rosdistro "$ROS_DISTRO" \
&& apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/* "$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/src /autoware/ansible /autoware/autoware.repos \
&& rm -rf /autoware/src /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 prebuilt binaries
COPY --from=prebuilt /autoware/install/ /autoware/install/
COPY --from=autoware-core /autoware/install /opt/autoware/
COPY --from=prebuilt /autoware/install /opt/autoware/

# Copy bash aliases
COPY docker/autoware-openadk/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/autoware-openadk/etc/ros_entrypoint.sh /ros_entrypoint.sh
Expand Down
4 changes: 3 additions & 1 deletion docker/autoware-openadk/etc/ros_entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +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 /opt/autoware/setup.bash
source /autoware/install/setup.bash
exec "$@"
else
Expand All @@ -22,9 +23,10 @@ else
# Add sudo privileges to the user
echo "$USER_NAME ALL=(ALL) NOPASSWD:ALL" >>/etc/sudoers

# Source ROS2
# Source ROS 2
# hadolint ignore=SC1090
source "/opt/ros/$ROS_DISTRO/setup.bash"
source /opt/autoware/setup.bash
source /autoware/install/setup.bash

# Execute the command as the user
Expand Down
Loading