Local builder setup
Introduction
The redpesk platform offers a Continuous Integration (CI) chain. But sometimes, the need is to have a short build cycle where you can build your package after modifying some files. This is for this need the local builder has been developed.
To use this tool, you have to install a container. This document will help you to install this container and to use use it.
In this part, another tool will be used. This is redpesk command line interface, or rp-cli. It will be the link between the user and the local builder. Thanks to that you will be able to develop locally.
Installation
You have to have either incus
or docker
installed on your host. For more information, please refer to the localbuilder installation section.
You also have installed rp-cli
on your host. If not, please refer to redpesk command line tool installation section.
Firstly, we need to create some directories on your computer, depending if you already have installed rp-cli
, these directories may already exist.
mkdir -p $HOME/my_rp_builder_dir/gitsources
mkdir -p $HOME/my_rp_builder_dir/gitpkgs
NOTE:
Below commands may also refer tojq
tool that is useful to parse output formatted in json.
Please also think to install this tool on you host usingapt install jq
(on debian like distributions) ordnf install jq
(on rpm like distributions)
Docker
- For Debian/Ubuntu:
docker run --detach \
--init \
--pull=always \
--cap-add=SYS_ADMIN \
--security-opt apparmor:unconfined \
--user $(id -u):$(id -g) \
--publish 8080:8080 \
--volume ~/my_rp_builder_dir:/home/devel/rp-build:z \
--name redpesk-localbuilder \
registry.redpesk.bzh/redpesk-ci/redpesk-localbuilder:latest
- For Almalinux/Fedora:
docker run --detach \
--init \
--pull=always \
--cap-add=SYS_ADMIN \
--security-opt label:disable \
--user $(id -u):$(id -g) \
--publish 8080:8080 \
--volume ~/my_rp_builder_dir:/home/devel/rp-build:z \
--name redpesk-localbuilder \
registry.redpesk.bzh/redpesk-ci/redpesk-localbuilder:latest
Incus
# Get the latest redpesk localbuilder container
wget https://download.redpesk.bzh/redpesk-ci/redpesk-builder/lxc/redpesk-localbuilder_latest.tar.gz
wget https://download.redpesk.bzh/redpesk-ci/redpesk-builder/lxc/redpesk-localbuilder_latest.md5
# Check the image integrity
md5sum --check redpesk-localbuilder_latest.md5
# Import the image in incus
incus image import ./redpesk-localbuilder.tar.gz --alias redpesk-localbuilder-image
# Create the container using the image previously downloaded
incus launch redpesk-localbuilder-image redpesk-localbuilder --config security.privileged=true --config security.nesting=true
# Add the loop-control device
incus config device add redpesk-localbuilder loop-control unix-char path=/dev/loop-control
# Import your ssh key
incus config device add redpesk-localbuilder my_ssh disk source=~/.ssh path=/home/devel/.ssh
# Mapping host directories in the container
incus config device add redpesk-localbuilder my_rp_build disk source=$HOME/my_rp_builder_dir path=/home/devel/rp-build
# Restart the local-builder
incus restart redpesk-localbuilder
Local builder connection with rp-cli
Before using the local builder with rp-cli, be sure that this one is well configured. Please follow the steps detailed in the rp-cli part.
Once the connection to the redpesk infrastructure is completed, or if you have answered no (n
) to the first question, the rp-cli onboard
command then asks if you want to configure the redpesk localbuilder connection.
If you want to, answer yes (Y
).
$ rp-cli onboard
Do you want to configure the redpesk backend connection? (Y/n)
> n
Do you want to configure the redpesk local-builder connection? (Y/n)
> Y
-- Local builder link configuration requested by user --
Current available connections: [NONE]
Please enter the IP of the local builder you want to interact with (ex: 10.231.232.2), then press enter:
> 10.231.232.187
Modification of the local builder file...[OK]
The default mounted directory (/home/armand/my_rp_builder_dir/gitsources) exists on the host, should it be used as 'gitsources' directory? (Y/n)
> Y
The default mounted directory (/home/armand/my_rp_builder_dir/gitpkgs) exists on the host, should it be used as 'gitpkgs' directory? (Y/n)
> Y
rp-cli
requests the IP of the local builder. Enter the IP of the corresponding container running on your host and press enter. To get this IP, two methods are available, depending if you are using incus
or docker
.
- With
incus
> incus ls redpesk-localbuilder
+----------------------+---------+---------------------+------+-----------+-----------+
| NAME | STATE | IPV4 | IPV6 | TYPE | SNAPSHOTS |
+----------------------+---------+---------------------+------+-----------+-----------+
| redpesk-localbuilder | RUNNING | 10.171.7.234 (eth0) | | CONTAINER | 0 |
+----------------------+---------+---------------------+------+-----------+-----------+
- With
docker
> docker inspect -f json redpesk-localbuilder |jq .[].NetworkSettings.IPAddress
"172.17.0.3"
Then, rp-cli
checks if the default mounted directories exist on the system. These directories are the one created by default at the local-builder installation.
So, if during local builder installation you follow what we give in this documentation, you can answer ‘yes’ to the questions asked like in the example above.
If rp-cli
does not detect these directories in your system, he asks for the directories to use and creates them if they do not exist.