This guide walks you step by step until you get a Buildbot main server, a.k.a. build master, published as a service on the Edge that can be accessed on the Internet.
Make sure that all of the mandatory prerequisites have been met before progressing further.
Name | Source | Description |
---|---|---|
<CONTAINER_NAME> | User input | The name of the Linux container where the app will be run. |
<IP_ADDRESS__CONTAINER> | Generated | The IPv4 address of the contaier run by the server on the Edge. |
<ROOT_PWD__CONTAINER> | User input | The password of the root user in the container. |
<IP_ADDRESS_INET_GW> | Linux VPS Admin Panel | |
<BUILDBOT_DOMAIN> | User input | The host for the A record created with your domain registrar, e.g. ci.myowndomain.net . |
Run the following commands on your server on the Edge.
incus launch images:debian/bookworm/cloud <CONTAINER_NAME>
incus exec <CONTAINER_NAME> bash
You may need to change the default MTU for HTTPS connections to function. Run
ip link set dev eth0 mtu 1000
if you findapt update
orapt upgrade
stuck for long time. This setting is non persistent and it is lost when the container reboots.
apt update && apt upgrade && apt install fish
If you are not already within the container, run the following command on your server on the Edge to log in as
root
.
incus exec <CONTAINER_NAME> fish
passwd
Set a password for the root user and make a (mental) note of it. It will be denoted with a variable <ROOT_PWD__CONTAINER>.
From here on the root user will use fish
as default shell.
chsh -s /usr/bin/fish
Let's create the buildbot
user and set a system password for it.
useradd -m -s /usr/bin/fish buildbot
passwd buildbot
The ability to establish SSH connections from the server on the Edge to the container is key for the upcoming Ansible automation. There is an Ansible connection driver for Linux containers with limited capabilities. The default Ansible connection driver through SSH is much more robust and powerful.
You can perform this step now or in future, when you make up your mind to give the automated solutions for system and application maintanence a try.
In order to complete this stage you need to perform the following commands in the container run by the server on the Edge.
apt update && apt install openssh-server
vi /etc/ssh/sshd_config
Add the following line to the file.
PermitRootLogin yes
systemctl enable ssh
systemctl start ssh
systemctl restart ssh
Run the following commands on your server on the Edge, i.e. outside of the container.
Run ssh-keygen
only if you haven't generated SSH private and public keys on the server on the Edge. Otherwise use the already existing pair.
ssh-keygen
incus ls | grep <CONTAINER_NAME>
Make a note of the IPV4 value <IP_ADDRESS__CONTAINER>.
ssh-copy-id root@<IP_ADDRESS__CONTAINER>
Pass the password for the root
user in the container as prompted.
From here on SSH connection as the
root
user will be possible from the server on the Edge to the container. Containers are not visible and accessible to any other network devices.
Run the following commands on your server on the Edge.
incus exec <CONTAINER_NAME> fish
Let's harden the setup of the ssh server running in the container by disabling the password for logging in with root
.
vi /etc/ssh/sshd_config
Delete the line PermitRootLogin yes
.
Append the line PermitRootLogin prohibit-password
.
systemctl restart ssh
You should have a fully functional Linux container named
<CONTAINER_NAME>
that has also a non-administrative userbuildbot
. In addition, the server on the Edge listens for SSH connections with theroot
user. You know all login credentials.
If you are not already within the container, run the following command on your server on the Edge to log in as
root
.
incus exec <CONTAINER_NAME> fish
apt update && apt install python3-pip \
build-essential python3-dev libssl-dev libffi-dev
Installing
buildbot
withpip
using the--break-system-packages
option is a good workaround until we find better ways to install it on systems running cutting edge versions of Python 3. We have tried usingpipx
and it turned out that it messed up with Buildbot's plugin concept, which is pretty much based on Python packages and the way they used to install and interoperate till now.
sudo -u buildbot pip install --break-system-packages buildbot[bundle]
mkdir /opt/bb-main-1
chown buildbot:buildbot /opt/bb-main-1
sudo -u buildbot /home/buildbot/.local/bin/buildbot \
create-master -r /opt/bb-main-1
sudo -u buildbot mv /opt/bb-main-1/master.cfg.sample \
/opt/bb-main-1/master.cfg
If you are not already within the container, run the following command on your server on the Edge to log in as
root
.
incus exec <CONTAINER_NAME> fish
vi /etc/systemd/system/bb-main-1.service
Add the following content to /etc/systemd/system/bb-main-1.service
. Make sure that all paths match the setup in your container.
[Unit]
Description=Buildbot main server service
After=network.target
[Service]
Type=forking
ExecStart=/home/buildbot/.local/bin/buildbot start /opt/bb-main-1
Restart=always
User=buildbot
WorkingDirectory=/opt/bb-main-1
[Install]
WantedBy=multi-user.target
systemctl daemon-reload
systemctl enable bb-main-1
systemctl start bb-main-1
You should be able to run a successful HTTP request against the Buildbot main server from within the container.
curl http://localhost:8010
Edit /opt/bb-main-1/master.cfg
and amend the c['buildbotURL']
value to be the URL to the Internet address of the Buildbot main server, i.e. make sure that /opt/bb-main-1/master.cfg
contains a line like the one below.
c['buildbotURL'] = "https://<BUILDBOT_DOMAIN>/"
In order to complete this stage you need to perform the following commands in the container run by the server on the Edge.
If you are not already within the container, run the following command on your server on the Edge to log in as
root
.
incus exec <CONTAINER_NAME> fish
apt update && apt install caddy
Generate self signed TLS certificate and private key.
mkdir /opt/buildbot-tls
openssl req -x509 -nodes -newkey rsa:4096 -days 365 \
-keyout /opt/buildbot-tls/key.pem \
-out /opt/buildbot-tls/cert.pem
chown caddy:caddy -R /opt/buildbot-tls
Modify /etc/caddy/Caddyfile
, e.g. vi /etc/caddy/Caddyfile
, and make sure it only contains the snippet below.
:443 {
tls /opt/buildbot-tls/cert.pem /opt/buildbot-tls/key.pem
reverse_proxy localhost:8010
}
systemctl enable caddy
systemctl start caddy
Now the Buildbot main server should be accessible within the container.
curl -k https://localhost
In a terminal on on the server on the Edge run the following command to forward incoming HTTPS connections on port 10443
of the server to port 443
on the container.
incus config device add <CONTAINER_NAME> \
https-10443-443 proxy listen=tcp:0.0.0.0:10443 \
connect=tcp:127.0.0.1:443
From here on the Buidbot main server instance should be accessible from the Server on the Edge and any other device in the same network.
curl -k https://localhost:10443
Make sure that you have created an A domain record for <BUILDBOT_DOMAIN> with your domain registrar and you have waited for this record to become active.
If you use a domain name and that's not picked up by the domain name servers yet, Caddy will not be able to serve HTTPS requests because of Let's Encrypt (An SSL certificate authority) failing to verify the validity (ownership over) of the domain.
ssh mycelium@<IP_ADDRESS__INET_GW>
sudo su -
Add the following to /etc/caddy/Caddyfile
.
<BUILDBOT_DOMAIN> {
reverse_proxy https://10.6.6.2:10443
}
systemctl reload caddy
If everything is configured well, you should be able to access the Buildbot main server through its domain name by using a web browser by typing
https://<BUILDBOT_DOMAIN>
in the address bar.
You won't be able to trigger any builds through the user interface of the Buildbot server at this stage. Refer to the next steps section for further guidance.
You will need to create and start at least one Buildbot Worker instance that will connect with the main server and will be executing Buildbot builds end to end.