Skip to content

Create CI/CD pipeline and Containers with Robotair 📦

Estimated time to read: 6 minutes


This section will guide you through the process of using Robotair to automate the packaging and building of your ROS application using Docker. By the end of this tutorial, you’ll have a working build process for your ROS project that pushes container images to a registry.

Prerequisites

  • A working ROS application (ROS/ROS 2).
  • A user account on Robotair, and access to a container registry (e.g., DockerHub).

1. Prepare your repository

  1. Clone your ROS application:

    • Open your terminal and run:This command will download your ROS project to your local workspace.

      git clone <link/to/ros/repository>
      
  2. Create a new branch:

    • Use Git to create a branch where you'll configure your CI setup:

      git checkout -b ci/robotair
      

2. Onboard to Robotair build

  1. Login to Robotair:

    • Navigate to the Robotair and login to your account with username and password
    • Go to the "Builds" section and click on "Create New Build".

    robotair_builds

3. Containerize your application

  1. Configure Your Build:

    • Name your build (you can follow semantic versioning).
    • Select the ROS version that your application uses (e.g., Jazzy,Noetic), and click Next.

    robotair_builds

  2. Choose Build Requirements:

    • Base Image: Robotair defaults to the official OSRF image, but you can choose a custom base image if needed.
    • Compiler: You can select your preferred compiler.
    • Execution Command: Choose the command that will run when the container starts.

    Example

    • ros2 launch <package> <launch_file>
    • ros2 run <package> <node>
    • Bash or Python scripts (for custom logic).

    robotair_builds

  3. Add Dependencies:

    • System Dependencies: Installed via apt. (List them in package.xml).
    • Python Dependencies: Installed via pip (use a requirements.txt file). You can generate one by running:

      pip freeze > requirements.txt
      
  4. Add Deploy keys your private repositories:

    Info

    To securely clone private repositores in your image, you need to provide the Deploy keys

    • Hostname: Base URL for the git service (https://github.com/ / https://yourcompany.gitlab.com/)
    • Secret name: SSH_KEYS Name of repository secret holding SSH deploy key. To set the variable on the git service

      • GitHub: Your repository > Settings > Secrets and variables > Actions > New Repository Secret robotair_builds robotair_builds

      • GitLab : Your repository > Settings > CI/CD > Variables

  5. ROS Package Dependencies

    • List these in a .repos or .rosinstall file. To generate a .repos file from your ROS workspace
      vcs export > my_package.repos
      

    robotair_builds

  6. Add Startup commands

    • Provide your set of startup commands for your ROS application. You can provide any number of commands in the order of your preference.

    robotair_builds

4. Packaging your application

  1. Configure your image:

    • Set the name for your container image (e.g., myrobot/app:latest) and choose the architecture (amd64 for most desktops or arm64 for Raspberry Pi and embedded systems).

    robotair_builds

  2. Configure Container Registry:

    • Add the credentials for your container registry (e.g., DockerHub, GitLab, or private).
    • Registry url: Default registry URL is for DockerHub
    • Username: Provide username for the private image registry.
    • Password: REGISTRY_PASSWORD Provide the name of CI/CD pipeline secret holding the password for the private image registry.

    Warning

    Do not provide the password directly as this value will be stored unencrypted in the generated build configuration files!

    • GitHub: Your repository > Settings > Secrets and variables > Actions > New Repository Secret robotair_builds

    robotair_builds

5. Generate CI files for your repository

  1. Finalize and Preview:

    • Review the configuration details. You can also edit the builds after creation.
    • Click Create to generate the CI files for your project repository.

    robotair_builds

6. Integrate the CI files with your repository

robotair_builds

  1. Download CI Files:

    • Once the build is created, download the CI files for either GitHub or GitLab and also the Rigelfile
      • For GitHub users,
        • Download the main.yaml file and place it in .github/workflows/.
        • Download the Rigelfile and place it in the root of your repo.
      • For GitLab users,
        • Download the gitlab-ci.yaml file and rename it to .gitlab-ci.yaml.
        • Download the Rigelfile and place it in the root of your repo .
  2. Set Secrets:

    • In GitHub or GitLab, add secrets for pushing to your container registry:
      • REGISTRY_PASSWORD: Your registry password.
        robotair_builds
  3. Deploy Keys:

    • Hostname: Base URL for the git service (https://github.com/ / https://yourcompany.gitlab.com/)
    • Secret name: Name of repository secret holding SSH deploy key. To set the variable on the git service

      • GitHub: Your repository > Settings > Secrets and variables > Actions > New Repository Secret
      • GitLab : Your repository > Settings > CI/CD > Variables
    • To securely clone private repositores in your image, you need to provide the Deploy keys

      • Hostname: Base URL for the git service (https://github.com/ / https://yourcompany.gitlab.com/)
      • Secret name: SSH_KEYS Name of repository secret holding SSH deploy key. To set the variable on the git service robotair_builds
  4. Commit and Push:

    • Add the CI file to your ci/robotair branch and push it:

      git add --all
      git commit -m "ci: Added Robotair CI configuration"
      git push origin ci/robotair
      
  5. Monitor Build pipeline:

    • When you merge the Pull Request (PR) or Merge Request (MR), the CI process will run automatically.
    • Once successful, your container image will be pushed to the registry 🚀.