Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
Signed-off-by: Oguz Ozturk <[email protected]>
  • Loading branch information
oguzkaganozt committed Nov 25, 2024
1 parent fe6272a commit f6f5a50
Show file tree
Hide file tree
Showing 16 changed files with 818 additions and 270 deletions.
26 changes: 26 additions & 0 deletions .github/actions/docker-build-and-push/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,30 @@ runs:
flavor: |
latest=false
- name: Docker meta for planning-control-fail
id: meta-planning-control-fail
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository_owner }}/${{ inputs.target-image }}
tags: |
type=raw,value=planning-control-fail-${{ inputs.platform }}
type=raw,value=planning-control-fail-${{ steps.date.outputs.date }}-${{ inputs.platform }}
bake-target: docker-metadata-action-planning-control-fail
flavor: |
latest=false
- name: Docker meta for planning-control-pass
id: meta-planning-control-pass
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository_owner }}/${{ inputs.target-image }}
tags: |
type=raw,value=planning-control-pass-${{ inputs.platform }}
type=raw,value=planning-control-pass-${{ steps.date.outputs.date }}-${{ inputs.platform }}
bake-target: docker-metadata-action-planning-control-pass
flavor: |
latest=false
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
Expand All @@ -91,5 +115,7 @@ runs:
files: |
docker/docker-bake.hcl
${{ steps.meta-simulator-visualizer.outputs.bake-file }}
${{ steps.meta-planning-control-fail.outputs.bake-file }}
${{ steps.meta-planning-control-pass.outputs.bake-file }}
set: |
${{ inputs.build-args }}
2 changes: 1 addition & 1 deletion .github/workflows/docker-build-and-push-arm64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
uses: ./.github/actions/docker-build-and-push
with:
platform: arm64
target-image: autoware_snapshots
target-image: demo_packages
build-args: |
*.platform=linux/arm64
*.args.ROS_DISTRO=${{ needs.load-env.outputs.rosdistro }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docker-build-and-push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
uses: ./.github/actions/docker-build-and-push
with:
platform: amd64
target-image: autoware_snapshots
target-image: demo_packages
build-args: |
*.platform=linux/amd64
*.args.ROS_DISTRO=${{ needs.load-env.outputs.rosdistro }}
Expand Down
117 changes: 5 additions & 112 deletions docker/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,110 +2,18 @@

set -e

# Function to print help message
print_help() {
echo "Usage: build.sh [OPTIONS]"
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'."
}

SCRIPT_DIR=$(readlink -f "$(dirname "$0")")
WORKSPACE_ROOT="$SCRIPT_DIR/.."

# Parse arguments
parse_arguments() {
while [ "$1" != "" ]; do
case "$1" in
--help | -h)
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
exit 1
;;
esac
shift
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
targets=("universe-devel")
else
targets=()
fi
}

# Set platform
set_platform() {
if [ -n "$option_platform" ]; then
platform="$option_platform"
else
platform="linux/amd64"
if [ "$(uname -m)" = "aarch64" ]; then
platform="linux/arm64"
fi
fi
}

# Set arch lib dir
set_arch_lib_dir() {
if [ "$platform" = "linux/arm64" ]; then
lib_dir="aarch64"
elif [ "$platform" = "linux/amd64" ]; then
lib_dir="x86_64"
else
echo "Unsupported platform: $platform"
exit 1
fi
}

# Load env
load_env() {
source "$WORKSPACE_ROOT/amd64.env"
if [ "$platform" = "linux/arm64" ]; then
source "$WORKSPACE_ROOT/arm64.env"
fi
}

# Clone repositories
clone_repositories() {
cd "$WORKSPACE_ROOT"
if [ ! -d "src" ]; then
mkdir -p src
vcs import src <autoware.repos
vcs import src <simulator.repos
else
echo "Source directory already exists. Updating repositories..."
vcs import src <autoware.repos
vcs import src <simulator.repos
vcs pull src
fi
}
Expand All @@ -116,25 +24,16 @@ build_images() {
export BUILDKIT_STEP_LOG_MAX_SIZE=10000000

echo "Building images for platform: $platform"
echo "ROS distro: $rosdistro"
echo "Base image: $base_image"
echo "Setup args: $setup_args"
echo "Lib dir: $lib_dir"
echo "Image name suffix: $image_name_suffix"
echo "Targets: ${targets[*]}"

set -x
docker buildx bake --load --progress=plain -f "$SCRIPT_DIR/docker-bake.hcl" \
--set "*.context=$WORKSPACE_ROOT" \
--set "*.ssh=default" \
--set "*.platform=$platform" \
--set "*.args.ROS_DISTRO=$rosdistro" \
--set "*.args.BASE_IMAGE=$base_image" \
--set "*.args.SETUP_ARGS=$setup_args" \
--set "*.args.LIB_DIR=$lib_dir" \
--set "base.tags=ghcr.io/autowarefoundation/autoware:base" \
--set "universe-devel.tags=ghcr.io/autowarefoundation/autoware:universe-devel$image_name_suffix" \
--set "universe.tags=ghcr.io/autowarefoundation/autoware:universe$image_name_suffix" \
--set "simulator-visualizer.tags=ghcr.io/autowarefoundation/openadkit.autoware:simulator-visualizer" \
--set "planning-control-fail.tags=ghcr.io/autowarefoundation/openadkit.autoware:planning-control-fail" \
--set "planning-control-pass.tags=ghcr.io/autowarefoundation/openadkit.autoware:planning-control-pass" \
"${targets[@]}"
set +x
}
Expand All @@ -145,12 +44,6 @@ remove_dangling_images() {
}

# Main script execution
parse_arguments "$@"
set_cuda_options
set_build_options
set_platform
set_arch_lib_dir
load_env
clone_repositories
build_images
remove_dangling_images
18 changes: 17 additions & 1 deletion docker/docker-bake.hcl
Original file line number Diff line number Diff line change
@@ -1,14 +1,30 @@
group "default" {
targets = [
"simulator-visualizer"
"simulator-visualizer",
"planning-control-fail",
"planning-control-pass"
]
}

// For docker/metadata-action
target "docker-metadata-action-simulator-visualizer" {}
target "docker-metadata-action-planning-control-fail" {}
target "docker-metadata-action-planning-control-pass" {}

target "simulator-visualizer" {
inherits = ["docker-metadata-action-simulator-visualizer"]
dockerfile = "docker/simulator-visualizer/Dockerfile"
target = "simulator-visualizer"
}

target "planning-control-fail" {
inherits = ["docker-metadata-action-planning-control-fail"]
dockerfile = "docker/planning-control/fail/Dockerfile"
target = "planning-control-fail"
}

target "planning-control-pass" {
inherits = ["docker-metadata-action-planning-control-pass"]
dockerfile = "docker/planning-control/pass/Dockerfile"
target = "planning-control-pass"
}
3 changes: 0 additions & 3 deletions docker/etc/simulation/rviz/launch_rviz.sh

This file was deleted.

49 changes: 49 additions & 0 deletions docker/local-simulation.docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
services:
simulator:
image: ghcr.io/autowarefoundation/autoware_snapshots:simulator-visualizer-amd64
network_mode: "host"
volumes:
- /dev/shm:/dev/shm
- /etc/localtime:/etc/localtime:ro
- /tmp/.X11-unix:/tmp/.X11-unix:rw
- ./etc/map:/autoware/map
- ./etc/simulation:/autoware/simulation
environment:
- ROS_DOMAIN_ID=88
- DISPLAY=${DISPLAY}
- VNC_ENABLED=false
command: >-
ros2 launch
scenario_test_runner
scenario_test_runner.launch.py
architecture_type:=awf/universe/20240605
record:=false
sensor_model:=sample_sensor_kit
vehicle_model:=sample_vehicle
scenario:=/autoware/simulation/yield_maneuver_demo.yaml
map_path:=/autoware/map
global_timeout:=240
initialize_duration:=90
launch_autoware:=false
launch_rviz:=true
planning-control:
image: ghcr.io/autowarefoundation/autoware:universe
network_mode: "host"
volumes:
- /dev/shm:/dev/shm
- /etc/localtime:/etc/localtime:ro
- ./etc/map:/autoware/map
environment:
- ROS_DOMAIN_ID=88
command: >-
ros2 launch
autoware_launch
planning_simulator.launch.xml
scenario_simulation:=true
vehicle_model:=sample_vehicle
sensor_model:=sample_sensor_kit
map_path:=/autoware/map
use_foa:=false
perception/enable_traffic_light:=false
rviz:=false
6 changes: 6 additions & 0 deletions docker/planning-control/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash
# shellcheck disable=SC1090,SC1091

source "/opt/ros/$ROS_DISTRO/setup.bash"
source /opt/autoware/setup.bash
exec "$@"
9 changes: 9 additions & 0 deletions docker/planning-control/fail/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM ghcr.io/autowarefoundation/autoware:universe AS planning-control-fail

# Copy launch file
COPY docker/planning-control/fail/fail_scenario.launch.xml /opt/autoware/share/autoware_launch/config/planning/scenario_planning/lane_driving/behavior_planning/behavior_path_planner/autoware_behavior_path_static_obstacle_avoidance_module/static_obstacle_avoidance.param.yaml

# Copy entrypoint script
COPY docker/planning-control/entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
Loading

0 comments on commit f6f5a50

Please sign in to comment.