diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 00000000000..ca5c9172ae0 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,14 @@ +FROM ghcr.io/autowarefoundation/openadk:devel-latest-cuda + +ENV SHELL /bin/bash + +ARG USERNAME=autoware +ARG USER_UID=1000 +ARG USER_GID=$USER_UID + +RUN groupadd --gid $USER_GID $USERNAME \ + && useradd --uid $USER_UID --gid $USER_GID -m $USERNAME \ + && apt-get update \ + && apt-get install -y sudo \ + && echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \ + && chmod 0440 /etc/sudoers.d/$USERNAME \ No newline at end of file diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 29450aa3cca..edb6deeb0e3 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,6 +1,25 @@ { - "name": "Autoware", - "image": "ghcr.io/autowarefoundation/autoware-openadk:devel-latest" - - // "remoteUser": "autoware", + "name": "Autoware", + "build": { + "dockerfile": "Dockerfile" + }, + "remoteUser": "autoware", + "hostRequirements": { + "gpu": true + }, + "runArgs": [ + "--cap-add=SYS_PTRACE", + "--security-opt", + "seccomp=unconfined", + "--net=host", + "--volume=/etc/localtime:/etc/localtime:ro", + "--gpus", "all" + ], + "customizations": { + "vscode": { + "settings.json": { + "terminal.integrated.profiles.linux": {"bash": {"path": "/bin/bash"}} + } + } + } } diff --git a/.github/actions/docker-build-and-push/action.yaml b/.github/actions/docker-build-and-push/action.yaml index 703be5eb9c9..726eaa79e1e 100644 --- a/.github/actions/docker-build-and-push/action.yaml +++ b/.github/actions/docker-build-and-push/action.yaml @@ -51,29 +51,29 @@ runs: echo "$EOF" >> $GITHUB_OUTPUT shell: bash - - name: Docker meta for devel - id: meta-devel + - name: Docker meta for prebuilt + id: meta-prebuilt uses: docker/metadata-action@v4 with: images: ghcr.io/${{ github.repository_owner }}/${{ inputs.bake-target }} tags: ${{ steps.set-docker-tags.outputs.tags }} - bake-target: docker-metadata-action-devel + bake-target: docker-metadata-action-prebuilt flavor: | latest=false prefix=${{ inputs.tag-prefix }} - suffix=devel${{ inputs.tag-suffix }} + suffix=prebuilt${{ inputs.tag-suffix }} - - name: Docker meta for prebuilt - id: meta-prebuilt + - name: Docker meta for devel + id: meta-devel uses: docker/metadata-action@v4 with: images: ghcr.io/${{ github.repository_owner }}/${{ inputs.bake-target }} tags: ${{ steps.set-docker-tags.outputs.tags }} - bake-target: docker-metadata-action-prebuilt + bake-target: docker-metadata-action-devel flavor: | latest=false prefix=${{ inputs.tag-prefix }} - suffix=prebuilt${{ inputs.tag-suffix }} + suffix=devel${{ inputs.tag-suffix }} - name: Docker meta for runtime id: meta-runtime diff --git a/.github/workflows/update-docker-manifest.yaml b/.github/workflows/update-docker-manifest.yaml index d5963ca38e6..0e2ac4a8ab0 100644 --- a/.github/workflows/update-docker-manifest.yaml +++ b/.github/workflows/update-docker-manifest.yaml @@ -21,12 +21,12 @@ jobs: with: package-name: autoware-openadk - - name: Create alias from 'autoware-openadk:{rosdistro}-latest' to 'autoware-openadk:latest' + - name: Create alias from 'autoware-openadk:{rosdistro}-latest-devel' to 'autoware-openadk:latest-devel' uses: ./.github/actions/create-main-distro-alias with: package-name: autoware-openadk rosdistro: ${{ needs.load-env.outputs.rosdistro }} - tag-name: latest + tag-name: latest-devel - name: Create alias from 'autoware-openadk:{rosdistro}-latest-runtime' to 'autoware-openadk:latest-runtime' uses: ./.github/actions/create-main-distro-alias @@ -35,12 +35,12 @@ jobs: rosdistro: ${{ needs.load-env.outputs.rosdistro }} tag-name: latest-runtime - - name: Create alias from 'autoware-openadk:{rosdistro}-latest-cuda' to 'autoware-openadk:latest-cuda' + - name: Create alias from 'autoware-openadk:{rosdistro}-latest-devel-cuda' to 'autoware-openadk:latest-devel-cuda' uses: ./.github/actions/create-main-distro-alias with: package-name: autoware-openadk rosdistro: ${{ needs.load-env.outputs.rosdistro }} - tag-name: latest-cuda + tag-name: latest-devel-cuda - name: Create alias from 'autoware-openadk:{rosdistro}-latest-runtime-cuda' to 'autoware-openadk:latest-runtime-cuda' uses: ./.github/actions/create-main-distro-alias diff --git a/docker/README.md b/docker/README.md index ccae2487f26..54bda0f0782 100644 --- a/docker/README.md +++ b/docker/README.md @@ -54,7 +54,19 @@ For more launch options you can edit the launch command `--launch-cmd`: #### Using VS Code Remote Containers for Development Get the Visual Studio Code's [Remote - Containers](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) extension. -Refer to [this document](https://code.visualstudio.com/remote/advancedcontainers/add-nonroot-user) for more details. +And reopen the workspace in the container by selecting `Remote-Containers: Reopen in Container` from the Command Palette (`F1`). + +By default devcontainer assumes NIVIDA GPU support, you can change this by deleting these lines within `.devcontainer/devcontainer.json`: + +```json + "hostRequirements": { + "gpu": true + }, +``` +```json + "--gpus", "all" +``` + ## Building Docker images from scratch diff --git a/docker/autoware-openadk/docker-bake.hcl b/docker/autoware-openadk/docker-bake.hcl index 54fef6ef6d4..d472a0df008 100644 --- a/docker/autoware-openadk/docker-bake.hcl +++ b/docker/autoware-openadk/docker-bake.hcl @@ -3,22 +3,22 @@ group "default" { } // For docker/metadata-action -target "docker-metadata-action-devel" {} target "docker-metadata-action-prebuilt" {} +target "docker-metadata-action-devel" {} target "docker-metadata-action-runtime" {} -target "devel" { - inherits = ["docker-metadata-action-devel"] - dockerfile = "docker/autoware-openadk/Dockerfile" - target = "devel" -} - target "prebuilt" { inherits = ["docker-metadata-action-prebuilt"] dockerfile = "docker/autoware-openadk/Dockerfile" target = "prebuilt" } +target "devel" { + inherits = ["docker-metadata-action-devel"] + dockerfile = "docker/autoware-openadk/Dockerfile" + target = "devel" +} + target "runtime" { inherits = ["docker-metadata-action-runtime"] dockerfile = "docker/autoware-openadk/Dockerfile" diff --git a/docker/run.sh b/docker/run.sh index cb8d4dc9a28..8fddd96377f 100755 --- a/docker/run.sh +++ b/docker/run.sh @@ -15,12 +15,12 @@ print_help() { echo "Options:" echo " --help Display this help message" echo " -h Display this help message" + echo " --map-path Specify the path to the map files (mandatory)" echo " --no-nvidia Disable NVIDIA GPU support" echo " --devel Use the latest development version of Autoware" - echo " --headless Run Autoware in headless mode" + echo " --headless Run Autoware in headless mode (default: false)" echo " --workspace Specify the workspace path (default: current directory)" - echo " --map-path Specify the path to the map files (mandatory)" - echo " --launch-cmd Specify the launch command (default: autoware.launch.xml)" + echo " --launch-cmd Specify the launch command for the container" echo "" echo "Note: The --map-path option is mandatory. Please provide the path to the map files." } @@ -29,8 +29,8 @@ print_help() { option_no_nvidia=false option_devel=false option_headless=false -MAP_PATH="/path/to/map" -LAUNCH_CMD="ros2 launch autoware_launch autoware.launch.xml map_path:=${MAP_PATH} vehicle_model:=sample_vehicle sensor_model:=sample_sensor_kit" +MAP_PATH="" +LAUNCH_CMD="" WORKSPACE_PATH="${PWD}" USER_ID="" @@ -80,14 +80,28 @@ set_variables() { USER_ID="-e LOCAL_UID=$(id -u) -e LOCAL_GID=$(id -g) -e LOCAL_USER=$(id -un) -e LOCAL_GROUP=$(id -gn)" WORKSPACE="-v ${WORKSPACE_PATH}:/workspace" LAUNCH_CMD="" + + # Echo + echo -e "\nStarting Autoware devel container..." + echo "WORKSPACE: ${WORKSPACE_PATH}" else if [ "$MAP_PATH" == "" ]; then print_help exit 1 fi + if [ "$LAUNCH_CMD" == "" ]; then + LAUNCH_CMD="ros2 launch autoware_launch autoware.launch.xml map_path:=${MAP_PATH} vehicle_model:=sample_vehicle sensor_model:=sample_sensor_kit" + fi + MAP="-v ${MAP_PATH}:/${MAP_PATH}" IMAGE="ghcr.io/autowarefoundation/autoware-openadk:runtime-$rosdistro-latest" WORKSPACE="" + + # Echo + + echo -e "\nStarting Autoware..." + echo "MAP PATH: ${MAP_PATH}" + echo "LAUNCH CMD: ${LAUNCH_CMD}" fi } @@ -118,6 +132,11 @@ main() { set_x_display # Launch Autoware with custom map + echo + echo "Executing Docker command:" + echo "docker run -it --rm --net=host ${GPU_FLAG} ${USER_ID} ${MOUNT_X} ${WORKSPACE} ${MAP} ${IMAGE} ${LAUNCH_CMD}" + echo "------------------------------------" + sleep 2 docker run -it --rm --net=host ${GPU_FLAG} ${USER_ID} ${MOUNT_X} \ ${WORKSPACE} ${MAP} ${IMAGE} \ ${LAUNCH_CMD}