Build Server, Part 1
Create your first GitOps event-driven build server
Build Server, Part 1
Introduction
Bruce is a lightweight build server designed for efficient iteration and seamless integration with your workflows. In this tutorial, we'll guide you through setting up your first Bruce build server on a Debian-based system.
Requirements & Getting Started
To start, I set up my personal build server with a /data
partition and install Docker to handle
compiling and building most sources without cluttering my system. The server runs a minimal Debian installation,
but you can choose another distribution like Fedora or Arch Linux.
The /data
partition is formatted with ext4 and has an initial capacity of 120GB, which I can expand
later if needed.
Let's Get Started!
First, create a user for Bruce to run under (instead of running it as root) and add it to the Docker group so it can execute commands for building data. On a production server, you might consider giving the Bruce user a non-login shell for added security. However, for this demo, I use a login shell for easier troubleshooting.
If you haven’t created a /data
partition yet, you can do so with tools like fdisk
or
parted
, and mount it using mount /dev/sdX /data
. Alternatively, you can use your home
directory, /opt
, or another storage medium for this tutorial.
useradd -m -d /data/bruce bruce # Create a new user named 'bruce' with a home directory at /data/bruce
usermod -aG docker bruce # Add the 'bruce' user to the 'docker' group for Docker access
Next, download Bruce from the
official downloads page. Use the following commands to retrieve
the latest release for Linux, extract it, and move the binary to /usr/local/bin
for global
availability:
wget -qO- $(wget -qO- https://api.github.com/repos/configset/bruce/releases/latest | grep "linux_amd64" | grep https | cut -d : -f 2,3 | tr -d \" | awk '{print $1}') | tar -xvz
sudo mv ./bruce /usr/local/bin/
This command performs the following steps:
- Fetches the latest release from the Bruce GitHub repository.
- Extracts the tarball containing the binary.
- Moves the
bruce
binary to/usr/local/bin
for easy execution.
Verify the installation by checking the version:
bruce version
BRUCE version: 1.4.3
Latest version: v1.4.3
Creating a Systemd Unit File
To run Bruce as a server that starts automatically on system reboot, create a unit file as shown below.
Save this file to /etc/systemd/system/bruce.service
.
[Unit]
Description=Bruce Build Server
After=docker.service
Requires=docker.service
[Service]
User=bruce
Group=bruce
TimeoutStartSec=5
Restart=always
ExecStart=/usr/local/bin/bruce server /data/bruce/server-config.yml
[Install]
WantedBy=multi-user.target
Agent Configuration
To configure the Bruce agent, visit the Bruce Tools page. Refer to the screenshot below for an example of the agent configuration interface:
Once you have your Agent ID and Secret, create the server configuration file at
/data/bruce/server-config.yml
.
---
endpoint: <Agent Endpoint>
runner-id: <Agent ID>
authorization: <Auth Key>
execution:
- name: node action
action: default
type: event
target: /data/bruce/node.yml
Testing Your Setup
Before starting the Bruce service, ensure proper permissions for the configuration files:
sudo chown bruce:bruce /data/bruce/server-config.yml
sudo chown bruce:bruce /data/bruce/node.yml
sudo systemctl daemon-reload
sudo systemctl enable bruce
sudo systemctl start bruce
sudo systemctl status bruce
Verify that the service is running with systemctl status bruce
. You should see output like this:
● bruce.service - Bruce Build Server
Loaded: loaded (/etc/systemd/system/bruce.service; enabled; preset: enabled)
Active: active (running) since Sat 2024-12-07 10:00:25 EST; 36s ago
Main PID: 1968 (bruce)
Tasks: 8 (limit: 2305)
Memory: 10.0M
CPU: 71ms
CGroup: /system.slice/bruce.service
└─1968 /usr/local/bin/bruce server /data/bruce/server-config.yml
Dec 07 10:00:25 bruce-1 systemd[1]: Started bruce.service - Bruce Build Server.
Dec 07 10:00:25 bruce-1 bruce[1968]: 10:00AM INF Starting Bruce in server mode
Dec 07 10:00:25 bruce-1 bruce[1968]: 10:00AM INF SocketRunner load balancing request on:
wss://bruce.tools/workers
Congratulations! Your Bruce build server is now set up and running. Stay tuned for the next guide, where we'll explore building and deploying your first application with Bruce.