Skip to content

Commit

Permalink
generate install package lists
Browse files Browse the repository at this point in the history
  • Loading branch information
youtalk committed May 17, 2024
1 parent 3080ed8 commit 4881a01
Showing 1 changed file with 37 additions and 18 deletions.
55 changes: 37 additions & 18 deletions docker/autoware-openadk/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,33 @@ RUN --mount=type=ssh \
# Create entrypoint
CMD ["/bin/bash"]

FROM $BASE_IMAGE as src-imported
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
ARG ROS_DISTRO

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

# Generate install package lists
RUN rosdep keys --dependency-types=build --ignore-src --from-paths src \
| xargs rosdep resolve --rosdistro ${ROS_DISTRO} \
| grep -v '^#' \
| sed 's/ \+/\n/g'\
| sort \
> /rosdep-build-depend-packages.txt
RUN rosdep keys --dependency-types=exec --ignore-src --from-paths src \
| xargs rosdep resolve --rosdistro ${ROS_DISTRO} \
| grep -v '^#' \
| sed 's/ \+/\n/g'\
| sort \
> /rosdep-exec-depend-packages.txt

FROM base as prebuilt
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
ARG ROS_DISTRO
Expand All @@ -56,27 +83,21 @@ RUN --mount=type=ssh \
&& find / -name 'libcu*.a' -delete \
&& find / -name 'libnv*.a' -delete

# Copy repository files
COPY autoware.repos /autoware/

# Install rosdep dependencies
COPY --from=src-imported /autoware/src /autoware/src
COPY --from=src-imported /rosdep-build-depend-packages.txt /tmp/rosdep-build-depend-packages.txt
RUN --mount=type=ssh \
mkdir src \
&& vcs import src < autoware.repos \
&& apt-get update \
&& rosdep update \
&& DEBIAN_FRONTEND=noninteractive rosdep install -y --ignore-src --from-paths src --rosdistro "$ROS_DISTRO" \
&& apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/* "$HOME"/.cache

# Build Autoware
RUN source /opt/ros/"$ROS_DISTRO"/setup.bash \
apt-get update \
&& cat /tmp/rosdep-build-depend-packages.txt | xargs apt-get install -y --no-install-recommends \
&& source /opt/ros/"$ROS_DISTRO"/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

CMD ["/bin/bash"]
Expand All @@ -103,20 +124,18 @@ ARG LIB_DIR
ARG SETUP_ARGS

# Set up runtime environment and artifacts
COPY autoware.repos /autoware/
COPY --from=src-imported /rosdep-exec-depend-packages.txt /tmp/rosdep-exec-depend-packages.txt
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 \
&& rosdep update \
&& DEBIAN_FRONTEND=noninteractive rosdep install -y --dependency-types=exec --ignore-src --from-paths src --rosdistro "$ROS_DISTRO" \
&& apt-get update \
&& cat /tmp/rosdep-exec-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 \
&& 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/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*
Expand Down

0 comments on commit 4881a01

Please sign in to comment.