diff --git a/.github/actions/docker-build-and-push/action.yaml b/.github/actions/docker-build-and-push/action.yaml index 84a7c12a2b0..2625334f2cb 100644 --- a/.github/actions/docker-build-and-push/action.yaml +++ b/.github/actions/docker-build-and-push/action.yaml @@ -144,6 +144,12 @@ runs: overwrite: true if-no-files-found: error + - name: Remove tar file - prebuilt + if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.artifacts-destination == 'tarball' }} + run: | + rm /tmp/prebuilt.tar + shell: bash + - name: Upload Artifact - devel if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.artifacts-destination == 'tarball' }} id: artifact-upload-step-devel @@ -156,6 +162,12 @@ runs: overwrite: true if-no-files-found: error + - name: Remove tar file - devel + if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.artifacts-destination == 'tarball' }} + run: | + rm /tmp/devel.tar + shell: bash + - name: Upload Artifact - runtime if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.artifacts-destination == 'tarball' }} id: artifact-upload-step-runtime @@ -168,6 +180,12 @@ runs: overwrite: true if-no-files-found: error + - name: Remove tar file - runtime + if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.artifacts-destination == 'tarball' }} + run: | + rm /tmp/runtime.tar + shell: bash + - name: Output artifact URLs id: output-artifact-urls run: | diff --git a/.github/workflows/build-main-self-hosted.yaml b/.github/workflows/build-main-self-hosted.yaml index e4cc44884e3..c0bba91845b 100644 --- a/.github/workflows/build-main-self-hosted.yaml +++ b/.github/workflows/build-main-self-hosted.yaml @@ -13,7 +13,11 @@ on: default: tarball jobs: + load-env: + uses: ./.github/workflows/load-env.yaml + build-main-self-hosted: + needs: load-env runs-on: [self-hosted, linux, ARM64] strategy: fail-fast: false @@ -43,25 +47,18 @@ jobs: - name: Free disk space uses: ./.github/actions/free-disk-space - - name: Load env - run: | - cat amd64.env | sed -e "s/^\s*//" -e "/^#/d" >> $GITHUB_ENV - if [ "$(uname -m)" = "aarch64" ]; then - cat arm64.env | sed -e "s/^\s*//" -e "/^#/d" >> $GITHUB_ENV - fi - - name: Build 'autoware-universe' uses: ./.github/actions/docker-build-and-push with: bake-target: autoware-openadk build-args: | *.platform=linux/arm64 - *.args.ROS_DISTRO=${{ env.rosdistro }} - *.args.BASE_IMAGE=${{ env[format('{0}', matrix.base_image_env)] }} + *.args.ROS_DISTRO=${{ needs.load-env.outputs.rosdistro }} + *.args.BASE_IMAGE=${{ needs.load-env.outputs[format('{0}', matrix.base_image_env)] }} *.args.SETUP_ARGS=${{ matrix.setup-args }} *.args.LIB_DIR=${{ matrix.lib_dir }} tag-suffix: ${{ matrix.additional-tag-suffix }}-arm64 - tag-prefix: ${{ env.rosdistro }} + tag-prefix: ${{ needs.load-env.outputs.rosdistro }} allow-push: false - name: Show disk space diff --git a/.github/workflows/build-main.yaml b/.github/workflows/build-main.yaml index 7b21980574a..4b276a7ad32 100644 --- a/.github/workflows/build-main.yaml +++ b/.github/workflows/build-main.yaml @@ -13,7 +13,11 @@ on: default: tarball jobs: + load-env: + uses: ./.github/workflows/load-env.yaml + build-main: + needs: load-env runs-on: ubuntu-latest strategy: fail-fast: false @@ -38,25 +42,18 @@ jobs: - name: Free disk space uses: ./.github/actions/free-disk-space - - name: Load env - run: | - cat amd64.env | sed -e "s/^\s*//" -e "/^#/d" >> $GITHUB_ENV - if [ "$(uname -m)" = "aarch64" ]; then - cat arm64.env | sed -e "s/^\s*//" -e "/^#/d" >> $GITHUB_ENV - fi - - name: Build 'autoware-universe' uses: ./.github/actions/docker-build-and-push with: bake-target: autoware-openadk build-args: | *.platform=linux/amd64 - *.args.ROS_DISTRO=${{ env.rosdistro }} - *.args.BASE_IMAGE=${{ env[format('{0}', matrix.base_image_env)] }} + *.args.ROS_DISTRO=${{ needs.load-env.outputs.rosdistro }} + *.args.BASE_IMAGE=${{ needs.load-env.outputs[format('{0}', matrix.base_image_env)] }} *.args.SETUP_ARGS=${{ matrix.setup-args }} *.args.LIB_DIR=${{ matrix.lib_dir }} tag-suffix: ${{ matrix.additional-tag-suffix }}-amd64 - tag-prefix: ${{ env.rosdistro }} + tag-prefix: ${{ needs.load-env.outputs.rosdistro }} allow-push: false - name: Show disk space diff --git a/.github/workflows/docker-build-and-push-main-self-hosted.yaml b/.github/workflows/docker-build-and-push-main-self-hosted.yaml index 315e5b1ed07..98b194f5d76 100644 --- a/.github/workflows/docker-build-and-push-main-self-hosted.yaml +++ b/.github/workflows/docker-build-and-push-main-self-hosted.yaml @@ -25,7 +25,11 @@ on: default: tarball jobs: + load-env: + uses: ./.github/workflows/load-env.yaml + docker-build-and-push-main-self-hosted: + needs: load-env runs-on: [self-hosted, linux, ARM64] strategy: fail-fast: false @@ -52,15 +56,24 @@ jobs: - name: Check out repository uses: actions/checkout@v4 + - name: Install vcstool + run: | + sudo apt-get -y update + sudo apt-get -y install python3-pip + pip install --no-cache-dir vcstool + + - name: Set git config + uses: autowarefoundation/autoware-github-actions/set-git-config@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + - name: Free disk space uses: ./.github/actions/free-disk-space - - name: Load env + - name: Run vcs import run: | - cat amd64.env | sed -e "s/^\s*//" -e "/^#/d" >> $GITHUB_ENV - if [ "$(uname -m)" = "aarch64" ]; then - cat arm64.env | sed -e "s/^\s*//" -e "/^#/d" >> $GITHUB_ENV - fi + mkdir src + vcs import src < autoware.repos - name: Build 'autoware-openadk' uses: ./.github/actions/docker-build-and-push @@ -68,12 +81,12 @@ jobs: bake-target: autoware-openadk build-args: | *.platform=linux/arm64 - *.args.ROS_DISTRO=${{ env.rosdistro }} - *.args.BASE_IMAGE=${{ env[format('{0}', matrix.base_image_env)] }} + *.args.ROS_DISTRO=${{ needs.load-env.outputs.rosdistro }} + *.args.BASE_IMAGE=${{ needs.load-env.outputs[format('{0}', matrix.base_image_env)] }} *.args.SETUP_ARGS=${{ matrix.setup-args }} *.args.LIB_DIR=${{ matrix.lib_dir }} tag-suffix: ${{ matrix.additional-tag-suffix }}-arm64 - tag-prefix: ${{ env.rosdistro }} + tag-prefix: ${{ needs.load-env.outputs.rosdistro }} allow-push: true - name: Show disk space diff --git a/.github/workflows/docker-build-and-push-main.yaml b/.github/workflows/docker-build-and-push-main.yaml index 1ed3fbef819..37607874844 100644 --- a/.github/workflows/docker-build-and-push-main.yaml +++ b/.github/workflows/docker-build-and-push-main.yaml @@ -19,7 +19,11 @@ on: default: tarball jobs: + load-env: + uses: ./.github/workflows/load-env.yaml + docker-build-and-push-main: + needs: load-env runs-on: buildjet-16vcpu-ubuntu-2204 strategy: fail-fast: false @@ -54,12 +58,21 @@ jobs: - name: Check out repository uses: actions/checkout@v4 - - name: Load env + - name: Install vcstool run: | - cat amd64.env | sed -e "s/^\s*//" -e "/^#/d" >> $GITHUB_ENV - if [ "$(uname -m)" = "aarch64" ]; then - cat arm64.env | sed -e "s/^\s*//" -e "/^#/d" >> $GITHUB_ENV - fi + sudo apt-get -y update + sudo apt-get -y install python3-pip + pip install --no-cache-dir vcstool + + - name: Set git config + uses: autowarefoundation/autoware-github-actions/set-git-config@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Run vcs import + run: | + mkdir src + vcs import src < autoware.repos - name: Build 'autoware-openadk' if: steps.author-check.outputs.author-found == 'true' || ${{ github.event_name == 'workflow_dispatch' }} @@ -68,10 +81,14 @@ jobs: bake-target: autoware-openadk build-args: | *.platform=linux/amd64 - *.args.ROS_DISTRO=${{ env.rosdistro }} - *.args.BASE_IMAGE=${{ env[format('{0}', matrix.base_image_env)] }} + *.args.ROS_DISTRO=${{ needs.load-env.outputs.rosdistro }} + *.args.BASE_IMAGE=${{ needs.load-env.outputs[format('{0}', matrix.base_image_env)] }} *.args.SETUP_ARGS=${{ matrix.setup-args }} *.args.LIB_DIR=${{ matrix.lib_dir }} tag-suffix: ${{ matrix.additional-tag-suffix }}-amd64 - tag-prefix: ${{ env.rosdistro }} + tag-prefix: ${{ needs.load-env.outputs.rosdistro }} allow-push: true + + - name: Show disk space + run: | + df -h diff --git a/.github/workflows/load-env.yaml b/.github/workflows/load-env.yaml index 508a30bf74a..e65389426b1 100644 --- a/.github/workflows/load-env.yaml +++ b/.github/workflows/load-env.yaml @@ -3,8 +3,8 @@ name: load-env on: workflow_call: outputs: - base-image: - value: ${{ jobs.load-env.outputs.base-image }} + base_image: + value: ${{ jobs.load-env.outputs.base_image }} rosdistro: value: ${{ jobs.load-env.outputs.rosdistro }} @@ -12,7 +12,7 @@ jobs: load-env: runs-on: ubuntu-latest outputs: - base-image: ${{ steps.set-env.outputs.base-image }} + base_image: ${{ steps.set-env.outputs.base_image }} rosdistro: ${{ steps.set-env.outputs.rosdistro }} steps: - name: Check out repository @@ -28,5 +28,5 @@ jobs: - name: Set env id: set-env run: | - echo "base-image=${{ env.base_image }}" >> $GITHUB_OUTPUT + echo "base_image=${{ env.base_image }}" >> $GITHUB_OUTPUT echo "rosdistro=${{ env.rosdistro }}" >> $GITHUB_OUTPUT diff --git a/ansible/playbooks/docker.yaml b/ansible/playbooks/docker.yaml index 5cc84043e27..443d355709a 100644 --- a/ansible/playbooks/docker.yaml +++ b/ansible/playbooks/docker.yaml @@ -24,3 +24,7 @@ when: prompt_install_nvidia == 'y' - role: autoware.dev_env.docker_engine - role: autoware.dev_env.nvidia_container_toolkit + + # ONNX files and other artifacts + - role: autoware.dev_env.artifacts + when: prompt_download_artifacts == 'y' diff --git a/ansible/playbooks/rosdep.yaml b/ansible/playbooks/rosdep.yaml new file mode 100644 index 00000000000..c7c23a245ab --- /dev/null +++ b/ansible/playbooks/rosdep.yaml @@ -0,0 +1,10 @@ +- name: Register rosdep package repositories + hosts: localhost + connection: local + pre_tasks: + - name: Verify OS + ansible.builtin.fail: + msg: Only Ubuntu 22.04 is supported for this branch. Please refer to https://autowarefoundation.github.io/autoware-documentation/main/installation/autoware/source-installation/. + when: ansible_distribution != 'Ubuntu' or ansible_distribution_version != '22.04' + roles: + - role: autoware.dev_env.pacmod diff --git a/docker/autoware-openadk/Dockerfile b/docker/autoware-openadk/Dockerfile index 3602fe690cf..e07b79c0856 100644 --- a/docker/autoware-openadk/Dockerfile +++ b/docker/autoware-openadk/Dockerfile @@ -39,6 +39,39 @@ RUN --mount=type=ssh \ # Create entrypoint CMD ["/bin/bash"] +FROM $BASE_IMAGE as src-imported +SHELL ["/bin/bash", "-o", "pipefail", "-c"] +ARG ROS_DISTRO + +# Copy files +COPY setup-dev-env.sh ansible-galaxy-requirements.yaml amd64.env arm64.env /autoware/ +COPY ansible/ /autoware/ansible/ +WORKDIR /autoware + +RUN --mount=type=ssh \ + ./setup-dev-env.sh -y rosdep \ + && pip uninstall -y ansible ansible-core \ + && apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/* "$HOME"/.cache + +# Copy repository files +COPY src /autoware/src + +# Generate install package lists +RUN rosdep update && rosdep keys --ignore-src --from-paths src \ + | xargs rosdep resolve --rosdistro ${ROS_DISTRO} \ + | grep -v '^#' \ + | sed 's/ \+/\n/g'\ + | sort \ + > /rosdep-all-depend-packages.txt \ + && cat /rosdep-all-depend-packages.txt +RUN rosdep keys --dependency-types=exec --ignore-src --from-paths src \ + | xargs rosdep resolve --rosdistro ${ROS_DISTRO} \ + | grep -v '^#' \ + | sed 's/ \+/\n/g'\ + | sort \ + > /rosdep-exec-depend-packages.txt \ + && cat /rosdep-exec-depend-packages.txt + FROM base as prebuilt SHELL ["/bin/bash", "-o", "pipefail", "-c"] ARG ROS_DISTRO @@ -60,15 +93,15 @@ RUN --mount=type=ssh \ COPY autoware.repos /autoware/ # Install rosdep dependencies +COPY --from=src-imported /rosdep-all-depend-packages.txt /tmp/rosdep-all-depend-packages.txt +# hadolint ignore=SC2002 RUN --mount=type=ssh \ - mkdir src \ - && vcs import src < autoware.repos \ - && apt-get update \ - && rosdep update \ - && DEBIAN_FRONTEND=noninteractive rosdep install -y --ignore-src --from-paths src --rosdistro "$ROS_DISTRO" \ + apt-get update \ + && cat /tmp/rosdep-all-depend-packages.txt | xargs apt-get install -y --no-install-recommends \ && apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/* "$HOME"/.cache # Build Autoware +COPY --from=src-imported /autoware/src /autoware/src RUN source /opt/ros/"$ROS_DISTRO"/setup.bash \ && colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release --cmake-args \ " -Wno-dev" \ @@ -86,7 +119,7 @@ SHELL ["/bin/bash", "-o", "pipefail", "-c"] # Install development tools and artifacts RUN --mount=type=ssh \ - ./setup-dev-env.sh -y --module dev-tools --download-artifacts openadk \ + ./setup-dev-env.sh -y --module dev-tools openadk \ && pip uninstall -y ansible ansible-core \ && apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/* "$HOME"/.cache @@ -103,20 +136,19 @@ ARG LIB_DIR ARG SETUP_ARGS # Set up runtime environment and artifacts -COPY autoware.repos /autoware/ +COPY --from=src-imported /rosdep-exec-depend-packages.txt /tmp/rosdep-exec-depend-packages.txt +# hadolint ignore=SC2002 RUN --mount=type=ssh \ - ./setup-dev-env.sh -y --module all ${SETUP_ARGS} --download-artifacts --no-cuda-drivers --runtime openadk \ + ./setup-dev-env.sh -y --module all ${SETUP_ARGS} --no-cuda-drivers --runtime openadk \ && pip uninstall -y ansible ansible-core \ - && mkdir src \ - && vcs import src < autoware.repos \ - && rosdep update \ - && DEBIAN_FRONTEND=noninteractive rosdep install -y --dependency-types=exec --ignore-src --from-paths src --rosdistro "$ROS_DISTRO" \ + && apt-get update \ + && cat /tmp/rosdep-exec-depend-packages.txt | xargs apt-get install -y --no-install-recommends \ && apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/* "$HOME"/.cache \ && find /usr/lib/$LIB_DIR-linux-gnu -name "*.a" -type f -delete \ && find / -name "*.o" -type f -delete \ && find / -name "*.h" -type f -delete \ && find / -name "*.hpp" -type f -delete \ - && rm -rf /autoware/src /autoware/ansible /autoware/autoware.repos \ + && rm -rf /autoware/ansible \ /root/.local/pipx /opt/ros/"$ROS_DISTRO"/include /etc/apt/sources.list.d/cuda*.list \ /etc/apt/sources.list.d/docker.list /etc/apt/sources.list.d/nvidia-docker.list \ /usr/include /usr/share/doc /usr/lib/gcc /usr/lib/jvm /usr/lib/llvm* diff --git a/docker/run.sh b/docker/run.sh index 3ea92854b3c..2c6856b1e71 100755 --- a/docker/run.sh +++ b/docker/run.sh @@ -20,11 +20,12 @@ fi option_no_nvidia=false option_devel=false option_headless=false +DATA_PATH="${HOME}/autoware_data" MAP_PATH="" WORKSPACE_PATH="" USER_ID="" WORKSPACE="" -DEFAULT_LAUNCH_CMD="ros2 launch autoware_launch autoware.launch.xml map_path:=/autoware_map vehicle_model:=sample_vehicle sensor_model:=sample_sensor_kit" +DEFAULT_LAUNCH_CMD="ros2 launch autoware_launch autoware.launch.xml data_path:=/autoware_data map_path:=/autoware_map vehicle_model:=sample_vehicle sensor_model:=sample_sensor_kit" # Function to print help message print_help() { @@ -35,6 +36,7 @@ print_help() { echo -e "${RED}Usage:${NC} run.sh [OPTIONS] [LAUNCH_CMD](optional)" echo -e "Options:" echo -e " ${GREEN}--help/-h${NC} Display this help message" + echo -e " ${GREEN}--data-path${NC} Specify to mount data files into /autoware_data" echo -e " ${GREEN}--map-path${NC} Specify to mount map files into /autoware_map (mandatory if no custom launch command is provided)" echo -e " ${GREEN}--no-nvidia${NC} Disable NVIDIA GPU support" echo -e " ${GREEN}--devel${NC} Use the latest development version of Autoware" @@ -64,6 +66,10 @@ parse_arguments() { WORKSPACE_PATH="$2" shift ;; + --data-path) + DATA_PATH="$2" + shift + ;; --map-path) MAP_PATH="$2" shift @@ -95,6 +101,9 @@ set_variables() { exit 1 fi + # Mount data path if provided + DATA="-v ${DATA_PATH}:/autoware_data:ro" + # Mount map path if provided MAP="-v ${MAP_PATH}:/autoware_map:ro" @@ -150,6 +159,7 @@ main() { echo -e "${GREEN}\n-----------------------LAUNCHING CONTAINER-----------------------" echo -e "${GREEN}IMAGE:${NC} ${IMAGE}" + echo -e "${GREEN}DATA PATH(mounted):${NC} ${DATA_PATH}:/autoware_data" echo -e "${GREEN}MAP PATH(mounted):${NC} ${MAP_PATH}:/autoware_map" echo -e "${GREEN}WORKSPACE(mounted):${NC} ${WORKSPACE_PATH}:/workspace" echo -e "${GREEN}LAUNCH CMD:${NC} ${LAUNCH_CMD}" @@ -159,7 +169,7 @@ main() { set -x docker run -it --rm --net=host ${GPU_FLAG} ${USER_ID} ${MOUNT_X} \ -e XAUTHORITY=${XAUTHORITY} -e XDG_RUNTIME_DIR=$XDG_RUNTIME_DIR -e NVIDIA_DRIVER_CAPABILITIES=all -v /etc/localtime:/etc/localtime:ro \ - ${WORKSPACE} ${MAP} ${IMAGE} \ + ${WORKSPACE} ${DATA} ${MAP} ${IMAGE} \ ${LAUNCH_CMD} } diff --git a/setup-dev-env.sh b/setup-dev-env.sh index e5cb6953f61..48afecc4444 100755 --- a/setup-dev-env.sh +++ b/setup-dev-env.sh @@ -133,7 +133,7 @@ if [ "$option_yes" = "true" ] || [ "$option_download_artifacts" = "true" ]; then fi # Check downloading artifacts -if [ "$target_playbook" = "autoware.dev_env.openadk" ]; then +if [ "$target_playbook" = "autoware.dev_env.docker" ] || [ "$target_playbook" = "autoware.dev_env.openadk" ]; then if [ "$option_download_artifacts" = "true" ]; then echo -e "\e[36mArtifacts will be downloaded to $option_data_dir\e[m" ansible_args+=("--extra-vars" "prompt_download_artifacts=y")