diff --git a/docker/build.sh b/docker/build.sh index a5de2f4bff..d0d8b8976e 100755 --- a/docker/build.sh +++ b/docker/build.sh @@ -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'." } @@ -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 @@ -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 @@ -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" \ @@ -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" \ @@ -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 } @@ -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