Skip to content

Commit b2c7255

Browse files
authored
refactor: added Docker image for visualization plugins (#5460)
* refactor: added Docker image for visualization plugins Signed-off-by: Esteve Fernandez <esteve.fernandez@tier4.jp> * added visualization section Signed-off-by: Esteve Fernandez <esteve.fernandez@tier4.jp> * update README.md Signed-off-by: Esteve Fernandez <esteve.fernandez@tier4.jp> * update README.md Signed-off-by: Esteve Fernandez <esteve.fernandez@tier4.jp> * added stages for visualization image Signed-off-by: Esteve Fernandez <esteve.fernandez@tier4.jp> * fix dependency generation Signed-off-by: Esteve Fernandez <esteve.fernandez@tier4.jp> * added target option Signed-off-by: Esteve Fernandez <esteve.fernandez@tier4.jp> * remove suffix and explicit visualization build Signed-off-by: Esteve Fernandez <esteve.fernandez@tier4.jp> * added tags for all targets Signed-off-by: Esteve Fernandez <esteve.fernandez@tier4.jp> * added COPY statement for universe-visualization-devel Signed-off-by: Esteve Fernandez <esteve.fernandez@tier4.jp> --------- Signed-off-by: Esteve Fernandez <esteve.fernandez@tier4.jp>
1 parent 6049f52 commit b2c7255

File tree

4 files changed

+110
-4
lines changed

4 files changed

+110
-4
lines changed

docker/Dockerfile

+63
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,18 @@ RUN /autoware/resolve_rosdep_keys.sh /autoware/src ${ROS_DISTRO} \
3535
> /rosdep-universe-common-depend-packages.txt \
3636
&& cat /rosdep-universe-common-depend-packages.txt
3737

38+
FROM rosdep-depend AS rosdep-universe-visualization-depend
39+
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
40+
ARG ROS_DISTRO
41+
42+
COPY src/universe/autoware.universe/visualization /autoware/src/universe/autoware.universe/visualization
43+
RUN /autoware/resolve_rosdep_keys.sh /autoware/src ${ROS_DISTRO} \
44+
> /rosdep-universe-visualization-depend-packages.txt \
45+
&& cat /rosdep-universe-visualization-depend-packages.txt
46+
RUN /autoware/resolve_rosdep_keys.sh /autoware/src ${ROS_DISTRO} \
47+
> /rosdep-universe-visualization-exec-depend-packages.txt \
48+
&& cat /rosdep-universe-visualization-exec-depend-packages.txt
49+
3850
FROM rosdep-depend AS rosdep-universe-sensing-perception-depend
3951
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
4052
ARG ROS_DISTRO
@@ -314,6 +326,30 @@ RUN --mount=type=cache,target=${CCACHE_DIR} \
314326
ENTRYPOINT ["/ros_entrypoint.sh"]
315327
CMD ["/bin/bash"]
316328

329+
FROM universe-common-devel AS universe-visualization-devel
330+
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
331+
ARG ROS_DISTRO
332+
ENV CCACHE_DIR="/root/.ccache"
333+
334+
# Install rosdep dependencies
335+
COPY --from=rosdep-universe-visualization-depend /rosdep-universe-visualization-depend-packages.txt /tmp/rosdep-universe-visualization-depend-packages.txt
336+
# hadolint ignore=SC2002
337+
RUN --mount=type=ssh \
338+
--mount=type=cache,target=/var/cache/apt,sharing=locked \
339+
apt-get update \
340+
&& cat /tmp/rosdep-universe-visualization-depend-packages.txt | xargs apt-get install -y --no-install-recommends \
341+
&& /autoware/cleanup_apt.sh
342+
343+
# hadolint ignore=SC1091
344+
RUN --mount=type=cache,target=${CCACHE_DIR} \
345+
--mount=type=bind,from=rosdep-universe-visualization-depend,source=/autoware/src/universe/autoware.universe/visualization,target=/autoware/src/universe/autoware.universe/visualization \
346+
source /opt/ros/"$ROS_DISTRO"/setup.bash \
347+
&& source /opt/autoware/setup.bash \
348+
&& /autoware/build_and_clean.sh ${CCACHE_DIR} /opt/autoware
349+
350+
ENTRYPOINT ["/ros_entrypoint.sh"]
351+
CMD ["/bin/bash"]
352+
317353
FROM universe-common-devel AS universe-devel
318354
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
319355
ARG ROS_DISTRO
@@ -332,6 +368,7 @@ COPY --from=universe-sensing-perception-devel /opt/autoware /opt/autoware
332368
COPY --from=universe-localization-mapping-devel /opt/autoware /opt/autoware
333369
COPY --from=universe-planning-control-devel /opt/autoware /opt/autoware
334370
COPY --from=universe-vehicle-system-devel /opt/autoware /opt/autoware
371+
COPY --from=universe-visualization-devel /opt/autoware /opt/autoware
335372
# hadolint ignore=SC1091
336373
RUN --mount=type=cache,target=${CCACHE_DIR} \
337374
--mount=type=bind,from=rosdep-universe-depend,source=/autoware/src/launcher,target=/autoware/src/launcher \
@@ -494,6 +531,32 @@ RUN echo "source /opt/autoware/setup.bash" > /etc/bash.bashrc
494531
ENTRYPOINT ["/ros_entrypoint.sh"]
495532
CMD ["/bin/bash"]
496533

534+
# hadolint ignore=DL3006
535+
FROM $AUTOWARE_BASE_IMAGE AS universe-visualization
536+
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
537+
ARG ROS_DISTRO
538+
ARG LIB_DIR
539+
540+
# Set up runtime environment
541+
COPY --from=rosdep-universe-visualization-depend /rosdep-universe-visualization-exec-depend-packages.txt /tmp/rosdep-universe-visualization-exec-depend-packages.txt
542+
# hadolint ignore=SC2002
543+
RUN --mount=type=ssh \
544+
--mount=type=cache,target=/var/cache/apt,sharing=locked \
545+
./setup-dev-env.sh -y --module all --no-nvidia --no-cuda-drivers --runtime openadkit \
546+
&& pip uninstall -y ansible ansible-core \
547+
&& apt-get update \
548+
&& cat /tmp/rosdep-universe-visualization-exec-depend-packages.txt | xargs apt-get install -y --no-install-recommends \
549+
&& /autoware/cleanup_system.sh $LIB_DIR $ROS_DISTRO
550+
551+
COPY --from=universe-visualization-devel /opt/autoware /opt/autoware
552+
553+
# Copy bash aliases
554+
COPY docker/etc/.bash_aliases /root/.bash_aliases
555+
RUN echo "source /opt/autoware/setup.bash" > /etc/bash.bashrc
556+
557+
ENTRYPOINT ["/ros_entrypoint.sh"]
558+
CMD ["/bin/bash"]
559+
497560
# hadolint ignore=DL3006
498561
FROM $AUTOWARE_BASE_IMAGE AS universe
499562
SHELL ["/bin/bash", "-o", "pipefail", "-c"]

docker/README.md

+5
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,10 @@ This stage is an Autoware Universe Sensing/Perception runtime container. It only
135135

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

138+
### `universe-visualization`
139+
140+
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.
141+
138142
### `universe-localization-mapping-devel`
139143

140144
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`:
@@ -187,6 +191,7 @@ Then it builds the remaining packages of `autoware.repos`:
187191
- `universe/autoware.universe/launch`
188192
- `universe/autoware.universe/simulator`
189193
- `universe/autoware.universe/tools`
194+
- `universe/autoware.universe/visualization`
190195
- `vehicle`
191196

192197
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.

docker/build.sh

+26-4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ print_help() {
1111
echo " --no-cuda Disable CUDA support"
1212
echo " --platform Specify the platform (default: current platform)"
1313
echo " --devel-only Build devel image only"
14+
echo " --target Specify the target image (default: universe or universe-devel if --devel-only is set)"
1415
echo ""
1516
echo "Note: The --platform option should be one of 'linux/amd64' or 'linux/arm64'."
1617
}
@@ -36,6 +37,10 @@ parse_arguments() {
3637
--devel-only)
3738
option_devel_only=true
3839
;;
40+
--target)
41+
option_target="$2"
42+
shift
43+
;;
3944
*)
4045
echo "Unknown option: $1"
4146
print_help
@@ -58,10 +63,15 @@ set_cuda_options() {
5863

5964
# Set build options
6065
set_build_options() {
61-
if [ "$option_devel_only" = "true" ]; then
62-
target="universe-devel"
66+
if [ -n "$option_target" ]; then
67+
target="$option_target"
68+
image_name_suffix=""
6369
else
64-
target="universe"
70+
if [ "$option_devel_only" = "true" ]; then
71+
target="universe-devel"
72+
else
73+
target="universe"
74+
fi
6575
fi
6676
}
6777

@@ -144,9 +154,21 @@ build_images() {
144154
--set "*.args.AUTOWARE_BASE_CUDA_IMAGE=$autoware_base_cuda_image" \
145155
--set "*.args.SETUP_ARGS=$setup_args" \
146156
--set "*.args.LIB_DIR=$lib_dir" \
157+
--set "universe-sensing-perception-devel.tags=ghcr.io/autowarefoundation/autoware:universe-sensing-perception-devel" \
158+
--set "universe-sensing-perception.tags=ghcr.io/autowarefoundation/autoware:universe-sensing-perception" \
159+
--set "universe-localization-mapping-devel.tags=ghcr.io/autowarefoundation/autoware:universe-localization-mapping-devel" \
160+
--set "universe-localization-mapping.tags=ghcr.io/autowarefoundation/autoware:universe-localization-mapping" \
161+
--set "universe-planning-control-devel.tags=ghcr.io/autowarefoundation/autoware:universe-planning-control-devel" \
162+
--set "universe-planning-control.tags=ghcr.io/autowarefoundation/autoware:universe-planning-control" \
163+
--set "universe-vehicle-system-devel.tags=ghcr.io/autowarefoundation/autoware:universe-vehicle-system-devel" \
164+
--set "universe-vehicle-system.tags=ghcr.io/autowarefoundation/autoware:universe-vehicle-system" \
165+
--set "universe-visualization-devel.tags=ghcr.io/autowarefoundation/autoware:universe-visualization-devel" \
166+
--set "universe-visualization.tags=ghcr.io/autowarefoundation/autoware:universe-visualization" \
147167
--set "universe-devel.tags=ghcr.io/autowarefoundation/autoware:universe-devel" \
148-
--set "universe-devel-cuda.tags=ghcr.io/autowarefoundation/autoware:universe-devel-cuda" \
149168
--set "universe.tags=ghcr.io/autowarefoundation/autoware:universe" \
169+
--set "universe-sensing-perception-devel-cuda.tags=ghcr.io/autowarefoundation/autoware:universe-sensing-perception-devel-cuda" \
170+
--set "universe-sensing-perception-cuda.tags=ghcr.io/autowarefoundation/autoware:universe-sensing-perception-cuda" \
171+
--set "universe-devel-cuda.tags=ghcr.io/autowarefoundation/autoware:universe-devel-cuda" \
150172
--set "universe-cuda.tags=ghcr.io/autowarefoundation/autoware:universe-cuda" \
151173
"$target$image_name_suffix"
152174
set +x

docker/docker-bake.hcl

+16
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ group "default" {
99
"universe-planning-control",
1010
"universe-vehicle-system-devel",
1111
"universe-vehicle-system",
12+
"universe-visualization-devel",
13+
"universe-visualization",
1214
"universe-devel",
1315
"universe"
1416
]
@@ -24,6 +26,8 @@ target "docker-metadata-action-universe-planning-control-devel" {}
2426
target "docker-metadata-action-universe-planning-control" {}
2527
target "docker-metadata-action-universe-vehicle-system-devel" {}
2628
target "docker-metadata-action-universe-vehicle-system" {}
29+
target "docker-metadata-action-universe-visualization-devel" {}
30+
target "docker-metadata-action-universe-visualization" {}
2731
target "docker-metadata-action-universe-devel" {}
2832
target "docker-metadata-action-universe" {}
2933

@@ -81,6 +85,18 @@ target "universe-vehicle-system" {
8185
target = "universe-vehicle-system"
8286
}
8387

88+
target "universe-visualization-devel" {
89+
inherits = ["docker-metadata-action-universe-visualization-devel"]
90+
dockerfile = "docker/Dockerfile"
91+
target = "universe-visualization-devel"
92+
}
93+
94+
target "universe-visualization" {
95+
inherits = ["docker-metadata-action-universe-visualization"]
96+
dockerfile = "docker/Dockerfile"
97+
target = "universe-visualization"
98+
}
99+
84100
target "universe-devel" {
85101
inherits = ["docker-metadata-action-universe-devel"]
86102
dockerfile = "docker/Dockerfile"

0 commit comments

Comments
 (0)