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

refactor: added Docker image for visualization plugins #5460

Merged
merged 10 commits into from
Jan 15, 2025
Merged
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
63 changes: 63 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,18 @@ RUN /autoware/resolve_rosdep_keys.sh /autoware/src ${ROS_DISTRO} \
> /rosdep-universe-common-depend-packages.txt \
&& cat /rosdep-universe-common-depend-packages.txt

FROM rosdep-depend AS rosdep-universe-visualization-depend
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
ARG ROS_DISTRO

COPY src/universe/autoware.universe/visualization /autoware/src/universe/autoware.universe/visualization
RUN /autoware/resolve_rosdep_keys.sh /autoware/src ${ROS_DISTRO} \
> /rosdep-universe-visualization-depend-packages.txt \
&& cat /rosdep-universe-visualization-depend-packages.txt
RUN /autoware/resolve_rosdep_keys.sh /autoware/src ${ROS_DISTRO} \
> /rosdep-universe-visualization-exec-depend-packages.txt \
&& cat /rosdep-universe-visualization-exec-depend-packages.txt

FROM rosdep-depend AS rosdep-universe-sensing-perception-depend
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
ARG ROS_DISTRO
Expand Down Expand Up @@ -314,6 +326,30 @@ RUN --mount=type=cache,target=${CCACHE_DIR} \
ENTRYPOINT ["/ros_entrypoint.sh"]
CMD ["/bin/bash"]

FROM universe-common-devel AS universe-visualization-devel
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
ARG ROS_DISTRO
ENV CCACHE_DIR="/root/.ccache"

# Install rosdep dependencies
COPY --from=rosdep-universe-visualization-depend /rosdep-universe-visualization-depend-packages.txt /tmp/rosdep-universe-visualization-depend-packages.txt
# hadolint ignore=SC2002
RUN --mount=type=ssh \
--mount=type=cache,target=/var/cache/apt,sharing=locked \
apt-get update \
&& cat /tmp/rosdep-universe-visualization-depend-packages.txt | xargs apt-get install -y --no-install-recommends \
&& /autoware/cleanup_apt.sh

# hadolint ignore=SC1091
RUN --mount=type=cache,target=${CCACHE_DIR} \
--mount=type=bind,from=rosdep-universe-visualization-depend,source=/autoware/src/universe/autoware.universe/visualization,target=/autoware/src/universe/autoware.universe/visualization \
source /opt/ros/"$ROS_DISTRO"/setup.bash \
&& source /opt/autoware/setup.bash \
&& /autoware/build_and_clean.sh ${CCACHE_DIR} /opt/autoware

ENTRYPOINT ["/ros_entrypoint.sh"]
CMD ["/bin/bash"]

FROM universe-common-devel AS universe-devel
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
ARG ROS_DISTRO
Expand All @@ -332,6 +368,7 @@ COPY --from=universe-sensing-perception-devel /opt/autoware /opt/autoware
COPY --from=universe-localization-mapping-devel /opt/autoware /opt/autoware
COPY --from=universe-planning-control-devel /opt/autoware /opt/autoware
COPY --from=universe-vehicle-system-devel /opt/autoware /opt/autoware
COPY --from=universe-visualization-devel /opt/autoware /opt/autoware
# hadolint ignore=SC1091
RUN --mount=type=cache,target=${CCACHE_DIR} \
--mount=type=bind,from=rosdep-universe-depend,source=/autoware/src/launcher,target=/autoware/src/launcher \
Expand Down Expand Up @@ -494,6 +531,32 @@ RUN echo "source /opt/autoware/setup.bash" > /etc/bash.bashrc
ENTRYPOINT ["/ros_entrypoint.sh"]
CMD ["/bin/bash"]

# hadolint ignore=DL3006
FROM $AUTOWARE_BASE_IMAGE AS universe-visualization
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
ARG ROS_DISTRO
ARG LIB_DIR

# Set up runtime environment
COPY --from=rosdep-universe-visualization-depend /rosdep-universe-visualization-exec-depend-packages.txt /tmp/rosdep-universe-visualization-exec-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 all --no-nvidia --no-cuda-drivers --runtime openadkit \
&& pip uninstall -y ansible ansible-core \
&& apt-get update \
&& cat /tmp/rosdep-universe-visualization-exec-depend-packages.txt | xargs apt-get install -y --no-install-recommends \
&& /autoware/cleanup_system.sh $LIB_DIR $ROS_DISTRO

COPY --from=universe-visualization-devel /opt/autoware /opt/autoware

# Copy bash aliases
COPY docker/etc/.bash_aliases /root/.bash_aliases
RUN echo "source /opt/autoware/setup.bash" > /etc/bash.bashrc

ENTRYPOINT ["/ros_entrypoint.sh"]
CMD ["/bin/bash"]

# hadolint ignore=DL3006
FROM $AUTOWARE_BASE_IMAGE AS universe
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
Expand Down
5 changes: 5 additions & 0 deletions docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,10 @@ This stage is an Autoware Universe Sensing/Perception runtime container. It only

This stage installs the CUDA runtime environment and copies the binaries built in the `universe-sensing-perception-devel-cuda` stage.

### `universe-visualization`

This stage is a Autoware Universe Visualization runtime container. It only includes the dependencies given by `/rosdep-universe-visualization-exec-depend-packages.txt` and the binaries built in the `universe-visualization-devel` stage.

### `universe-localization-mapping-devel`

This stage installs the dependency packages based on `/rosdep-universe-localization-mapping-depend-packages.txt` and builds the packages under the following directories of `autoware.repos`:
Expand Down Expand Up @@ -187,6 +191,7 @@ Then it builds the remaining packages of `autoware.repos`:
- `universe/autoware.universe/launch`
- `universe/autoware.universe/simulator`
- `universe/autoware.universe/tools`
- `universe/autoware.universe/visualization`
- `vehicle`

This stage provides an all-in-one development container to Autoware developers. By running the host's source code with volume mounting, it allows for easy building and debugging of Autoware.
Expand Down
30 changes: 26 additions & 4 deletions docker/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ print_help() {
echo " --no-cuda Disable CUDA support"
echo " --platform Specify the platform (default: current platform)"
echo " --devel-only Build devel image only"
echo " --target Specify the target image (default: universe or universe-devel if --devel-only is set)"
echo ""
echo "Note: The --platform option should be one of 'linux/amd64' or 'linux/arm64'."
}
Expand All @@ -36,6 +37,10 @@ parse_arguments() {
--devel-only)
option_devel_only=true
;;
--target)
option_target="$2"
shift
;;
*)
echo "Unknown option: $1"
print_help
Expand All @@ -58,10 +63,15 @@ set_cuda_options() {

# Set build options
set_build_options() {
if [ "$option_devel_only" = "true" ]; then
target="universe-devel"
if [ -n "$option_target" ]; then
target="$option_target"
image_name_suffix=""
else
target="universe"
if [ "$option_devel_only" = "true" ]; then
target="universe-devel"
else
target="universe"
fi
fi
}

Expand Down Expand Up @@ -144,9 +154,21 @@ build_images() {
--set "*.args.AUTOWARE_BASE_CUDA_IMAGE=$autoware_base_cuda_image" \
--set "*.args.SETUP_ARGS=$setup_args" \
--set "*.args.LIB_DIR=$lib_dir" \
--set "universe-sensing-perception-devel.tags=ghcr.io/autowarefoundation/autoware:universe-sensing-perception-devel" \
--set "universe-sensing-perception.tags=ghcr.io/autowarefoundation/autoware:universe-sensing-perception" \
--set "universe-localization-mapping-devel.tags=ghcr.io/autowarefoundation/autoware:universe-localization-mapping-devel" \
--set "universe-localization-mapping.tags=ghcr.io/autowarefoundation/autoware:universe-localization-mapping" \
--set "universe-planning-control-devel.tags=ghcr.io/autowarefoundation/autoware:universe-planning-control-devel" \
--set "universe-planning-control.tags=ghcr.io/autowarefoundation/autoware:universe-planning-control" \
--set "universe-vehicle-system-devel.tags=ghcr.io/autowarefoundation/autoware:universe-vehicle-system-devel" \
--set "universe-vehicle-system.tags=ghcr.io/autowarefoundation/autoware:universe-vehicle-system" \
--set "universe-visualization-devel.tags=ghcr.io/autowarefoundation/autoware:universe-visualization-devel" \
--set "universe-visualization.tags=ghcr.io/autowarefoundation/autoware:universe-visualization" \
--set "universe-devel.tags=ghcr.io/autowarefoundation/autoware:universe-devel" \
--set "universe-devel-cuda.tags=ghcr.io/autowarefoundation/autoware:universe-devel-cuda" \
--set "universe.tags=ghcr.io/autowarefoundation/autoware:universe" \
--set "universe-sensing-perception-devel-cuda.tags=ghcr.io/autowarefoundation/autoware:universe-sensing-perception-devel-cuda" \
--set "universe-sensing-perception-cuda.tags=ghcr.io/autowarefoundation/autoware:universe-sensing-perception-cuda" \
--set "universe-devel-cuda.tags=ghcr.io/autowarefoundation/autoware:universe-devel-cuda" \
--set "universe-cuda.tags=ghcr.io/autowarefoundation/autoware:universe-cuda" \
"$target$image_name_suffix"
set +x
Expand Down
16 changes: 16 additions & 0 deletions docker/docker-bake.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ group "default" {
"universe-planning-control",
"universe-vehicle-system-devel",
"universe-vehicle-system",
"universe-visualization-devel",
"universe-visualization",
"universe-devel",
"universe"
]
Expand All @@ -24,6 +26,8 @@ target "docker-metadata-action-universe-planning-control-devel" {}
target "docker-metadata-action-universe-planning-control" {}
target "docker-metadata-action-universe-vehicle-system-devel" {}
target "docker-metadata-action-universe-vehicle-system" {}
target "docker-metadata-action-universe-visualization-devel" {}
target "docker-metadata-action-universe-visualization" {}
target "docker-metadata-action-universe-devel" {}
target "docker-metadata-action-universe" {}

Expand Down Expand Up @@ -81,6 +85,18 @@ target "universe-vehicle-system" {
target = "universe-vehicle-system"
}

target "universe-visualization-devel" {
inherits = ["docker-metadata-action-universe-visualization-devel"]
dockerfile = "docker/Dockerfile"
target = "universe-visualization-devel"
}

target "universe-visualization" {
inherits = ["docker-metadata-action-universe-visualization"]
dockerfile = "docker/Dockerfile"
target = "universe-visualization"
}

target "universe-devel" {
inherits = ["docker-metadata-action-universe-devel"]
dockerfile = "docker/Dockerfile"
Expand Down
Loading