From 12787c8f5595231116d2eca9c9e43c4c74515d8f Mon Sep 17 00:00:00 2001 From: Andreas Kluge Svendsrud <89779148+kluge7@users.noreply.github.com> Date: Sun, 26 Jan 2025 13:25:59 +0100 Subject: [PATCH] feat: added support for docker (#514) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: add dockerfile for ros2 workspace setup and colcon build * ci: add ci pipeline for docker image build and ros2 colcon build * refactor: dockerfile use multi-stage builds to only include necessary files * refactor: dockerfile use smaller base image to make image size smaller --------- Co-authored-by: Andreas Kluge Svendsrud Co-authored-by: Anders Høgden --- .github/workflows/ci-docker-build.yaml | 14 +++++++++++++ .github/workflows/industrial-ci.yaml | 2 +- .gitmodules | 3 +++ README.md | 27 ++++++++++++++++++++++++++ vortex_auv.repos => dependencies.repos | 2 +- docker/docker-ros | 1 + entrypoint.sh | 5 +++++ 7 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/ci-docker-build.yaml create mode 100644 .gitmodules rename vortex_auv.repos => dependencies.repos (84%) create mode 160000 docker/docker-ros create mode 100644 entrypoint.sh diff --git a/.github/workflows/ci-docker-build.yaml b/.github/workflows/ci-docker-build.yaml new file mode 100644 index 000000000..8a089be04 --- /dev/null +++ b/.github/workflows/ci-docker-build.yaml @@ -0,0 +1,14 @@ +on: + push: + tags: + - 'v*' +jobs: + docker-ros: + runs-on: ubuntu-latest + steps: + - uses: ika-rwth-aachen/docker-ros@v1.6.1 + with: + base-image: rwthika/ros2:humble + target: dev # Specify the dev stage + image-tag: ${{ github.ref_name }} + platform: linux/arm64,linux/amd64 diff --git a/.github/workflows/industrial-ci.yaml b/.github/workflows/industrial-ci.yaml index 76461c2c6..49f393a7b 100644 --- a/.github/workflows/industrial-ci.yaml +++ b/.github/workflows/industrial-ci.yaml @@ -9,5 +9,5 @@ jobs: call_reusable_workflow: uses: vortexntnu/vortex-ci/.github/workflows/reusable-industrial-ci.yml@main with: - upstream_workspace: './vortex_auv.repos' + upstream_workspace: './dependencies.repos' before_install_target_dependencies: 'cp ./requirements.sh /tmp/requirements.sh && chmod +x /tmp/requirements.sh && /tmp/requirements.sh' diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 000000000..3f09324cb --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "docker/docker-ros"] + path = docker/docker-ros + url = https://github.com/ika-rwth-aachen/docker-ros.git diff --git a/README.md b/README.md index a7aac8a45..0a3b42b46 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,33 @@ This repo contains software for operating UUVs, developed by students at NTNU. The software is based on the ROS2 Humble framework, and aims to be hardware independent. Although the main focus of Vortex is autonomous operation, this software stack supports both AUV and ROV operations. +## Docker +This project uses the (docker-ros)[https://github.com/ika-rwth-aachen/docker-ros] repository for building and managing Docker images. The docker-ros repository is included as a Git submodule and is configured to build images locally. + +### Prerequisites +1. Docker must be installed on your system. Follow the instructions [here](https://docs.docker.com/get-docker/) to install Docker. + +### Cloning +1. To clone this repository with the docker-ros submodule, use the following command: +```bash +git clone --recurse-submodules https://github.com/vortexntnu/vortex-auv.git +``` +Alternatively, if you have already cloned the repository, run the following command to initialize the submodule: +```bash +git submodule update --init --recursive +``` +2. Once added, docker-ros provide a script to build Docker images locally. +### Building and Running +1. Run the following command to build the Docker image: +```bash +./entrypoint.sh +``` +Or, you can pull the appropriate image from (Github packages)[https://github.com/vortexntnu/vortex-auv/pkgs/container/vortex-auv] +2. Once the image is built, run the following command to start the container: +```bash +docker run -it --privileged --network host --ipc=host "auv-image:latest" +``` +NOTE: If running on MacOS, the `--network host` flag is not supported. ## Documentation * TODO: Drivers and hardware specifics for each drone will be added to the wiki. Link them here. diff --git a/vortex_auv.repos b/dependencies.repos similarity index 84% rename from vortex_auv.repos rename to dependencies.repos index 32f842011..4475316e4 100644 --- a/vortex_auv.repos +++ b/dependencies.repos @@ -1,4 +1,4 @@ repositories: - vortex_msgs: + vortex-msgs: type: git url: https://github.com/vortexntnu/vortex-msgs.git diff --git a/docker/docker-ros b/docker/docker-ros new file mode 160000 index 000000000..85feaea4f --- /dev/null +++ b/docker/docker-ros @@ -0,0 +1 @@ +Subproject commit 85feaea4ff6362cfca4d82163ccb4a62fc9f8bc3 diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 000000000..d0cf91084 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,5 @@ +IMAGE="auv-image:latest" \ +BASE_IMAGE="rwthika/ros2:humble" \ +TARGET="dev" \ +PLATFORM="linux/arm64,linux/amd64" \ +./docker/docker-ros/scripts/build.sh