diff --git a/scripts/build_image_layers.sh b/scripts/build_image_layers.sh index d2b723d7..65b31293 100755 --- a/scripts/build_image_layers.sh +++ b/scripts/build_image_layers.sh @@ -40,6 +40,14 @@ if [[ -f ~/.isaac_ros_common-config ]]; then . ~/.isaac_ros_common-config fi +# Override with config from project directory if exists (and is defined) +if [[ ! -z "${PROJECT_ROOT}" ]]; then + print_info "Sourcing project config at: ${PROJECT_ROOT}" + if [[ -f "${PROJECT_ROOT}/.isaac_ros_common-config" ]]; then + . "${PROJECT_ROOT}/.isaac_ros_common-config" + fi +fi + # Prepend configured docker search dirs if [ ${#CONFIG_DOCKER_SEARCH_DIRS[@]} -gt 0 ]; then for (( i=${#CONFIG_DOCKER_SEARCH_DIRS[@]}-1 ; i>=0 ; i-- )); do diff --git a/scripts/run_dev.sh b/scripts/run_dev.sh index 86f08e54..2a03a627 100755 --- a/scripts/run_dev.sh +++ b/scripts/run_dev.sh @@ -33,6 +33,17 @@ if [[ -f ~/.isaac_ros_common-config ]]; then . ~/.isaac_ros_common-config fi +# Override with config from project directory if exists (and is defined) +if [[ ! -z "${PROJECT_ROOT}" ]]; then + print_info "Sourcing project config at: ${PROJECT_ROOT}" + if [[ -f "${PROJECT_ROOT}/.isaac_ros_common-config" ]]; then + . "${PROJECT_ROOT}/.isaac_ros_common-config" + fi + + # Make the project root available to nested scripts, eg. build_image_layers.sh + export PROJECT_ROOT="${PROJECT_ROOT}" +fi + # Parse command-line args IMAGE_KEY=ros2_humble @@ -44,7 +55,8 @@ fi ISAAC_ROS_DEV_DIR="${ISAAC_ROS_WS}" SKIP_IMAGE_BUILD=0 VERBOSE=0 -VALID_ARGS=$(getopt -o hvd:i:ba: --long help,verbose,isaac_ros_dev_dir:,image_key:,skip_image_build,docker_arg: -- "$@") +DOCKER_BASH_COMMAND="echo 'Docker-bash command is empty. Use it with -c.'" +VALID_ARGS=$(getopt -o hvd:i:ba:c: --long help,verbose,isaac_ros_dev_dir:,image_key:,skip_image_build,docker_arg:,bash_cmd: -- "$@") eval set -- "$VALID_ARGS" while [ : ]; do case "$1" in @@ -68,6 +80,10 @@ while [ : ]; do VERBOSE=1 shift ;; + -c | --bash_cmd) + DOCKER_BASH_COMMAND="$2" + shift 2 + ;; -h | --help) usage exit 0 @@ -202,7 +218,7 @@ print_info "Launching Isaac ROS Dev container with image key ${BASE_IMAGE_KEY}: # Build image to launch if [[ $SKIP_IMAGE_BUILD -ne 1 ]]; then print_info "Building $BASE_IMAGE_KEY base as image: $BASE_NAME" - $ROOT/build_image_layers.sh --image_key "$BASE_IMAGE_KEY" --image_name "$BASE_NAME" + $ROOT/build_image_layers.sh --image_key "$BASE_IMAGE_KEY" --image_name "$BASE_NAME" -d "--progress=plain" # -d "--no-cache" # Check result if [ $? -ne 0 ]; then @@ -277,6 +293,7 @@ fi # Run container from image print_info "Running $CONTAINER_NAME" +print_info "User-Bash command: $DOCKER_BASH_COMMAND" if [[ $VERBOSE -eq 1 ]]; then set -x fi @@ -292,4 +309,4 @@ docker run -it --rm \ --entrypoint /usr/local/bin/scripts/workspace-entrypoint.sh \ --workdir /workspaces/isaac_ros-dev \ $BASE_NAME \ - /bin/bash + /bin/bash -c "${DOCKER_BASH_COMMAND}; exec bash"