From b756407a58c56e17a4572f6e347cb806d02f4850 Mon Sep 17 00:00:00 2001 From: biao Date: Sat, 28 Sep 2024 13:27:08 +0800 Subject: [PATCH 01/11] init --- .github/workflows/docker-image.yml | 37 +++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 22ea3da..7fc194a 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -1,17 +1,38 @@ -name: docker image build +name: Build and Push Docker Image to GHCR on: push: - branches: [ "**" ] - + branches: + - main # 你可以根据需要更改为你的主分支 + pull_request: + branches: + - main # 你可以根据需要更改为你的主分支 jobs: - build: - runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - name: Build the Docker image - run: docker build . --file Dockerfile --tag my-image-name:$(date +%s) + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Log in to GHCR + run: echo ${{ secrets.GHCR_TOKEN }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin + + - name: Extract Docker metadata + id: meta + uses: docker/metadata-action@v4 + with: + images: ghcr.io/${{ github.repository }} + + - name: Build and push Docker image + uses: docker/build-push-action@v4 + with: + context: . + platforms: linux/amd64,linux/arm64 + push: true + tags: v1 + labels: ${{ steps.meta.outputs.labels }} From 8a6e30e604df9158361390c13ce95c3401957c08 Mon Sep 17 00:00:00 2001 From: biao Date: Sat, 28 Sep 2024 13:28:19 +0800 Subject: [PATCH 02/11] x --- .github/workflows/docker-image.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 7fc194a..43af066 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -6,7 +6,7 @@ on: - main # 你可以根据需要更改为你的主分支 pull_request: branches: - - main # 你可以根据需要更改为你的主分支 + - main # 你可以根据需要更改为你的主分支x jobs: build: From 10a1c126579343af4574fd4bdbe711b1e90b330d Mon Sep 17 00:00:00 2001 From: biao Date: Sat, 28 Sep 2024 13:29:13 +0800 Subject: [PATCH 03/11] x --- .github/workflows/docker-image.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 43af066..eb07711 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -4,9 +4,11 @@ on: push: branches: - main # 你可以根据需要更改为你的主分支 + - master pull_request: branches: - main # 你可以根据需要更改为你的主分支x + - master jobs: build: From 3996a4faee1341e158a33ba9fafb6c30f9e66944 Mon Sep 17 00:00:00 2001 From: biao Date: Sat, 28 Sep 2024 13:34:53 +0800 Subject: [PATCH 04/11] x --- .github/workflows/docker-image.yml | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index eb07711..46afc53 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -9,6 +9,9 @@ on: branches: - main # 你可以根据需要更改为你的主分支x - master +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} jobs: build: @@ -21,14 +24,18 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 - - name: Log in to GHCR - run: echo ${{ secrets.GHCR_TOKEN }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin + - name: Log in to the Container registry + uses: docker/login-action@v2 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} - name: Extract Docker metadata id: meta uses: docker/metadata-action@v4 with: - images: ghcr.io/${{ github.repository }} + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - name: Build and push Docker image uses: docker/build-push-action@v4 @@ -36,5 +43,5 @@ jobs: context: . platforms: linux/amd64,linux/arm64 push: true - tags: v1 + tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} From 25ada83d1a41116a22e2bf9b432071b4040f0b21 Mon Sep 17 00:00:00 2001 From: biao Date: Sat, 28 Sep 2024 15:47:38 +0800 Subject: [PATCH 05/11] update ros --- Dockerfile | 4 +++- README.md | 51 ++++++++++++++++++++++++++++++++++++++++++++++ docker-compose.yml | 2 +- setup.sh | 2 +- 4 files changed, 56 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index faed60d..66fe0fd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,7 @@ # Use the official ROS image as the base image -FROM ros:humble-ros-core-jammy +# FROM ros:humble-ros-core-jammy + +FROM ros:noetic-ros-core-focal # Set shell for running commands SHELL ["/bin/bash", "-c"] diff --git a/README.md b/README.md index 0fd93de..306ccb9 100644 --- a/README.md +++ b/README.md @@ -60,3 +60,54 @@ nvidia-docker2 jazz. You can use rocker. You can also use Intel Integrated Graph This is under active development, so please feel free to contribute to the project. If you have any questions, please open an issue on the GitHub repo. Thanks! + + + + +首先,需要加载您的Zsh配置文件。 +将以下内容添加到zshrc的尾部 +``` +ros_dev() { + # Check if the correct number of arguments were provided + if (( $# % 2 != 0 )); then + echo "Usage: ros_dev [ ...]" + return 1 + fi + + while (( $# >= 2 )); do + # Set environment variables + ROS_DEV_CONTAINER_NAME=$1 + ROS_PROJECT_PATH=$2 + shift 2 + + # Run docker-compose from the correct directory + cd "$SCRIPT_DIR" && docker-compose up -d + done +} +``` +然后加载配置文件 +```sh +source ~/.zshrc +``` + +接下来,运行ROS2 Docker开发环境。 + + +``` +# ros_dev <容器名> <代码目录> +ros_dev ros2 $(pwd) +``` + +进入容器,加载ROS入口点脚本 + +``` +docker exec -it ros2 bash +source ros_entrypoint.sh +``` + +最后,运行RViz2可视化工具。 + + +```bash +rviz2 +``` \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 56ff9db..ce44f09 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -11,7 +11,7 @@ version: '3.8' services: ros_dev_env: container_name: ${ROS_DEV_CONTAINER_NAME} - image: ${ROS_DEV_CONTAINER_NAME} ## For now, the names are the same. Can change if ever a need arises. + image: ghcr.io/imdingtalk/ros2-docker-dev:master build: ./ volumes: - ${ROS_PROJECT_PATH}:/ros2_ws/src/ diff --git a/setup.sh b/setup.sh index 929d09f..7c979c1 100644 --- a/setup.sh +++ b/setup.sh @@ -22,7 +22,7 @@ echo 'ros_dev() { shift 2 # Run docker-compose from the correct directory - cd "$SCRIPT_DIR" && docker-compose up -d --build + cd "$SCRIPT_DIR" && docker-compose up -d done } ' >> "$HOME/.bashrc" From 0d7a560a0b678683101bfdba3b78b20451a66119 Mon Sep 17 00:00:00 2001 From: biao Date: Sat, 28 Sep 2024 15:53:05 +0800 Subject: [PATCH 06/11] x --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 66fe0fd..ea3b9cc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -29,7 +29,7 @@ RUN colcon mixin add default \ colcon metadata update RUN apt-get update && apt-get install -y --no-install-recommends \ - ros-humble-desktop=0.10.0-1* \ + ros-noetic-desktop\ && rm -rf /var/lib/apt/lists/* # Set the entrypoint to source ROS setup.bash and run a bash shell From cad00e005749198be484539da42e320140cb184d Mon Sep 17 00:00:00 2001 From: biao Date: Sat, 28 Sep 2024 16:09:54 +0800 Subject: [PATCH 07/11] x --- .github/workflows/docker-image.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 46afc53..9dab235 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -5,6 +5,8 @@ on: branches: - main # 你可以根据需要更改为你的主分支 - master + tags: + - '*' pull_request: branches: - main # 你可以根据需要更改为你的主分支x From 3ba70bd76d8f3f7a65cfcd5e2f83989cf97a3427 Mon Sep 17 00:00:00 2001 From: biao Date: Sat, 28 Sep 2024 16:39:04 +0800 Subject: [PATCH 08/11] roscore --- Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index ea3b9cc..1a6456b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -32,5 +32,6 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ ros-noetic-desktop\ && rm -rf /var/lib/apt/lists/* +ENTRYPOINT ["/ros_entrypoint.sh"] # Set the entrypoint to source ROS setup.bash and run a bash shell -CMD ["/bin/bash"] +CMD ["roscore"] From 9e3bf2f8138333dbf1cd756b1a866cae78766cef Mon Sep 17 00:00:00 2001 From: biao Date: Sat, 28 Sep 2024 16:57:57 +0800 Subject: [PATCH 09/11] update --- README.md | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 306ccb9..453c3e0 100644 --- a/README.md +++ b/README.md @@ -98,16 +98,13 @@ source ~/.zshrc ros_dev ros2 $(pwd) ``` -进入容器,加载ROS入口点脚本 +进入容器,加载ROS入口点脚本,运行RViz2可视化工具 ``` docker exec -it ros2 bash -source ros_entrypoint.sh +source ros_entrypoint.sh rviz ``` -最后,运行RViz2可视化工具。 +最后打开本地浏览器查看 - -```bash -rviz2 -``` \ No newline at end of file +http://localhost:8080/ \ No newline at end of file From f37ed4eaf79d263bd64bd8ea722e8f6d82809ce7 Mon Sep 17 00:00:00 2001 From: biao Date: Sat, 28 Sep 2024 17:56:25 +0800 Subject: [PATCH 10/11] noetic --- README.md | 6 ++++-- docker-compose.yml | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 453c3e0..a17da15 100644 --- a/README.md +++ b/README.md @@ -95,13 +95,15 @@ source ~/.zshrc ``` # ros_dev <容器名> <代码目录> -ros_dev ros2 $(pwd) +export ROS_DEV_CONTAINER_NAME=ros +export ROS_PROJECT_PATH=$(pwd) +ros_dev ros $(pwd) ``` 进入容器,加载ROS入口点脚本,运行RViz2可视化工具 ``` -docker exec -it ros2 bash +docker exec -it ros bash source ros_entrypoint.sh rviz ``` diff --git a/docker-compose.yml b/docker-compose.yml index ce44f09..77e03cc 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -11,7 +11,7 @@ version: '3.8' services: ros_dev_env: container_name: ${ROS_DEV_CONTAINER_NAME} - image: ghcr.io/imdingtalk/ros2-docker-dev:master + image: ghcr.io/imdingtalk/ros2-docker-dev:ros-noetic build: ./ volumes: - ${ROS_PROJECT_PATH}:/ros2_ws/src/ From 6cf237d5138cb67c2b915aaae00111aff4eff6bd Mon Sep 17 00:00:00 2001 From: imdingtalk Date: Thu, 17 Oct 2024 11:51:04 +0800 Subject: [PATCH 11/11] Update Dockerfile --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 1a6456b..83cf9ae 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,7 @@ FROM ros:noetic-ros-core-focal -# Set shell for running commands +# Set shell for running commandsx SHELL ["/bin/bash", "-c"] # install bootstrap tools