Skip to content

Commit

Permalink
fix(docker): revert args & use target
Browse files Browse the repository at this point in the history
Signed-off-by: amadeuszsz <[email protected]>
  • Loading branch information
amadeuszsz committed Dec 20, 2024
1 parent 49285a6 commit 4f8246d
Showing 1 changed file with 36 additions and 25 deletions.
61 changes: 36 additions & 25 deletions docker/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ print_help() {
echo "Options:"
echo " --help Display this help message"
echo " -h Display this help message"
echo " --no-cuda Disable CUDA support"
echo " --platform Specify the platform (default: current platform)"
echo " --devel-only Build devel image only"
echo ""
echo "Note: The --platform option should be one of 'linux/amd64' or 'linux/arm64'."
}
Expand All @@ -24,10 +26,16 @@ parse_arguments() {
print_help
exit 1
;;
--no-cuda)
option_no_cuda=true
;;
--platform)
option_platform="$2"
shift
;;
--devel-only)
option_devel_only=true
;;
*)
echo "Unknown option: $1"
print_help
Expand All @@ -38,6 +46,25 @@ parse_arguments() {
done
}

# Set CUDA options
set_cuda_options() {
if [ "$option_no_cuda" = "true" ]; then
setup_args="--no-nvidia"
image_name_suffix=""
else
image_name_suffix="-cuda"
fi
}

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

# Set platform
set_platform() {
if [ -n "$option_platform" ]; then
Expand Down Expand Up @@ -91,9 +118,10 @@ build_images() {
echo "Building images for platform: $platform"
echo "ROS distro: $rosdistro"
echo "Base image: $base_image"
echo "Base Autoware image: $autoware_base_image"
echo "Base Autoware CUDA image: $autoware_base_cuda_image"
echo "Setup args: $setup_args"
echo "Lib dir: $lib_dir"
echo "Image name suffix: $image_name_suffix"
echo "Target: $target"

set -x
docker buildx bake --load --progress=plain -f "$SCRIPT_DIR/docker-bake-base.hcl" \
Expand All @@ -102,12 +130,10 @@ build_images() {
--set "*.platform=$platform" \
--set "*.args.ROS_DISTRO=$rosdistro" \
--set "*.args.BASE_IMAGE=$base_image" \
--set "*.args.AUTOWARE_BASE_IMAGE=$autoware_base_image" \
--set "*.args.AUTOWARE_BASE_CUDA_IMAGE=$autoware_base_cuda_image" \
--set "*.args.SETUP_ARGS=$setup_args" \
--set "*.args.LIB_DIR=$lib_dir" \
--set "base.tags=ghcr.io/autowarefoundation/autoware-base:latest" \
--set "base-cuda.tags=ghcr.io/autowarefoundation/autoware-base:cuda-latest"

docker buildx bake --load --progress=plain -f "$SCRIPT_DIR/docker-bake.hcl" -f "$SCRIPT_DIR/docker-bake-cuda.hcl" \
--set "*.context=$WORKSPACE_ROOT" \
--set "*.ssh=default" \
Expand All @@ -116,30 +142,13 @@ build_images() {
--set "*.args.BASE_IMAGE=$base_image" \
--set "*.args.AUTOWARE_BASE_IMAGE=$autoware_base_image" \
--set "*.args.AUTOWARE_BASE_CUDA_IMAGE=$autoware_base_cuda_image" \
--set "*.args.SETUP_ARGS=$setup_args" \
--set "*.args.LIB_DIR=$lib_dir" \
--set "rosdep-depend.tags=ghcr.io/autowarefoundation/autoware:rosdep-depend" \
--set "rosdep-universe-sensing-perception-depend.tags=ghcr.io/autowarefoundation/autoware:rosdep-universe-sensing-perception-depend" \
--set "rosdep-universe-localization-mapping-depend.tags=ghcr.io/autowarefoundation/autoware:rosdep-universe-localization-mapping-depend" \
--set "rosdep-universe-planning-control-depend.tags=ghcr.io/autowarefoundation/autoware:rosdep-universe-planning-control-depend" \
--set "rosdep-universe-vehicle-system-depend.tags=ghcr.io/autowarefoundation/autoware:rosdep-universe-vehicle-system-depend" \
--set "rosdep-universe-depend.tags=ghcr.io/autowarefoundation/autoware:rosdep-universe-depend" \
--set "core-devel.tags=ghcr.io/autowarefoundation/autoware:core-devel" \
--set "universe-common-devel.tags=ghcr.io/autowarefoundation/autoware:universe-common-devel" \
--set "universe-common-devel-cuda.tags=ghcr.io/autowarefoundation/autoware:universe-common-devel-cuda" \
--set "universe-sensing-perception-devel.tags=ghcr.io/autowarefoundation/autoware:universe-sensing-perception-devel" \
--set "universe-sensing-perception-devel-cuda.tags=ghcr.io/autowarefoundation/autoware:universe-sensing-perception-devel-cuda" \
--set "universe-localization-mapping-devel.tags=ghcr.io/autowarefoundation/autoware:universe-localization-mapping-devel" \
--set "universe-planning-control-devel.tags=ghcr.io/autowarefoundation/autoware:universe-planning-control-devel" \
--set "universe-vehicle-system-devel.tags=ghcr.io/autowarefoundation/autoware:universe-vehicle-system-devel" \
--set "universe-devel.tags=ghcr.io/autowarefoundation/autoware:universe-devel" \
--set "universe-devel-cuda.tags=ghcr.io/autowarefoundation/autoware:universe-devel-cuda" \
--set "universe-sensing-perception.tags=ghcr.io/autowarefoundation/autoware:universe-sensing-perception" \
--set "universe-sensing-perception-cuda.tags=ghcr.io/autowarefoundation/autoware:universe-sensing-perception-cuda" \
--set "universe-localization-mapping.tags=ghcr.io/autowarefoundation/autoware:universe-localization-mapping" \
--set "universe-planning-control.tags=ghcr.io/autowarefoundation/autoware:universe-planning-control" \
--set "universe-vehicle-system.tags=ghcr.io/autowarefoundation/autoware:universe-vehicle-system" \
--set "universe.tags=ghcr.io/autowarefoundation/autoware:universe" \
--set "universe-cuda.tags=ghcr.io/autowarefoundation/autoware:universe-cuda"
--set "universe-cuda.tags=ghcr.io/autowarefoundation/autoware:universe-cuda" \
"$target$image_name_suffix"
set +x
}

Expand All @@ -150,6 +159,8 @@ remove_dangling_images() {

# Main script execution
parse_arguments "$@"
set_cuda_options
set_build_options
set_platform
set_arch_lib_dir
load_env
Expand Down

0 comments on commit 4f8246d

Please sign in to comment.