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⿻
-
Clone your ROS application:
-
Open your terminal and run:This command will download your ROS project to your local workspace.
-
-
Create a new branch:
-
Use Git to create a branch where you'll configure your CI setup:
-
2. Onboard to Robotair build⿻
-
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".
3. Containerize your application⿻
-
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.
-
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).
-
Add Dependencies:
- System Dependencies: Installed via
apt
. (List them inpackage.xml
). -
Python Dependencies: Installed via
pip
(use arequirements.txt
file). You can generate one by running:
- System Dependencies: Installed via
-
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
- Hostname: Base URL for the git service (
-
ROS Package Dependencies
- List these in a
.repos
or.rosinstall
file. To generate a.repos
file from your ROS workspace
- List these in a
-
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.
4. Packaging your application⿻
-
Configure your image:
- Set the name for your container image (e.g.,
myrobot/app:latest
) and choose the architecture (amd64
for most desktops orarm64
for Raspberry Pi and embedded systems).
- Set the name for your container image (e.g.,
-
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!
5. Generate CI files for your repository⿻
-
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.
6. Integrate the CI files with your repository⿻
-
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.
- Download the
- 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 .
- Download the
- For GitHub users,
- Once the build is created, download the CI files for either GitHub or GitLab and also the Rigelfile
-
Set Secrets:
-
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 (
-
Commit and Push:
-
Add the CI file to your
ci/robotair
branch and push it:
-
-
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 🚀.