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): refine devel image [DO NO MERGE] #86

Closed
wants to merge 3 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
52 changes: 32 additions & 20 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ RUN --mount=type=ssh \
&& apt-get autoremove -y && rm -rf "$HOME"/.cache \
&& echo "source /opt/ros/${ROS_DISTRO}/setup.bash" > /etc/bash.bashrc

# Create entrypoint
CMD ["/bin/bash"]

FROM $BASE_IMAGE as rosdep-depend
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
ARG ROS_DISTRO
Expand Down Expand Up @@ -80,26 +77,29 @@ RUN rosdep keys --dependency-types=exec --ignore-src --from-paths src \

FROM base as autoware-core
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
ARG ROS_DISTRO
ARG SETUP_ARGS
ENV CCACHE_DIR="/root/.ccache"

# cspell: ignore libcu libnv
# Set up development environment
RUN --mount=type=ssh \
--mount=type=cache,target=/var/cache/apt,sharing=locked \
./setup-dev-env.sh -y --module all ${SETUP_ARGS} --no-cuda-drivers openadkit \
&& pip uninstall -y ansible ansible-core \
&& apt-get autoremove -y && rm -rf "$HOME"/.cache

# Install rosdep dependencies
# Install rosdep dependencies for core packages
COPY --from=rosdep-depend /rosdep-core-depend-packages.txt /tmp/rosdep-core-depend-packages.txt
# hadolint ignore=SC2002
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
apt-get update \
&& cat /tmp/rosdep-core-depend-packages.txt | xargs apt-get install -y --no-install-recommends \
&& apt-get autoremove -y && rm -rf "$HOME"/.cache

FROM autoware-core as autoware-core-prebuilt
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
ARG ROS_DISTRO
ENV CCACHE_DIR="/root/.ccache"

# Build Autoware core
RUN --mount=type=bind,from=rosdep-depend,source=/autoware/src/core,target=/autoware/src/core \
--mount=type=cache,target=${CCACHE_DIR} \
source /opt/ros/"$ROS_DISTRO"/setup.bash \
Expand All @@ -110,21 +110,20 @@ RUN --mount=type=bind,from=rosdep-depend,source=/autoware/src/core,target=/autow
--mixin release compile-commands ccache \
&& du -sh ${CCACHE_DIR} && ccache -s

FROM autoware-core as autoware-universe
FROM autoware-core-prebuilt as autoware-universe
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
ARG ROS_DISTRO
ARG SETUP_ARGS
ENV CCACHE_DIR="/root/.ccache"

# Install rosdep dependencies
# Install rosdep dependencies for universe packages
COPY --from=rosdep-depend /rosdep-universe-depend-packages.txt /tmp/rosdep-universe-depend-packages.txt
# hadolint ignore=SC2002
RUN --mount=type=ssh \
apt-get update \
&& cat /tmp/rosdep-universe-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

# Build Autoware
# Build Autoware universe
RUN --mount=type=bind,from=rosdep-depend,source=/autoware/src,target=/autoware/src \
--mount=type=cache,target=${CCACHE_DIR} \
source /opt/ros/"$ROS_DISTRO"/setup.bash \
Expand All @@ -135,19 +134,32 @@ RUN --mount=type=bind,from=rosdep-depend,source=/autoware/src,target=/autoware/s
--mixin release compile-commands ccache \
&& du -sh ${CCACHE_DIR} && ccache -s

CMD ["/bin/bash"]

FROM autoware-universe as devel
FROM autoware-core as devel
SHELL ["/bin/bash", "-o", "pipefail", "-c"]

# Install development tools and artifacts
# Install rosdep dependencies for universe packages
COPY --from=rosdep-depend /rosdep-universe-depend-packages.txt /tmp/rosdep-universe-depend-packages.txt
# hadolint ignore=SC2002
RUN --mount=type=ssh \
--mount=type=cache,target=/var/cache/apt,sharing=locked \
./setup-dev-env.sh -y --module dev-tools openadkit \
&& pip uninstall -y ansible ansible-core \
&& apt-get autoremove -y && rm -rf "$HOME"/.cache
apt-get update \
&& cat /tmp/rosdep-universe-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

# Set up runtime environment and artifacts
COPY --from=rosdep-depend /rosdep-exec-depend-packages.txt /tmp/rosdep-exec-depend-packages.txt
# hadolint ignore=SC2002
RUN --mount=type=ssh \
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

# Install development tools
RUN --mount=type=ssh \
--mount=type=cache,target=/var/cache/apt,sharing=locked \
./setup-dev-env.sh -y --module dev-tools openadkit \
&& 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
8 changes: 1 addition & 7 deletions setup-dev-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,7 @@ else
fi

# Check downloading artifacts
if [ "$option_yes" = "true" ] || [ "$option_download_artifacts" = "true" ]; then
echo -e "\e[36mArtifacts will be downloaded to $option_data_dir\e[m"
ansible_args+=("--extra-vars" "prompt_download_artifacts=y")
fi

# Check downloading artifacts
if [ "$target_playbook" = "autoware.dev_env.openadk" ]; then
if [ "$target_playbook" = "autoware.dev_env.openadkit" ]; then
if [ "$option_download_artifacts" = "true" ]; then
echo -e "\e[36mArtifacts will be downloaded to $option_data_dir\e[m"
ansible_args+=("--extra-vars" "prompt_download_artifacts=y")
Expand Down
Loading