8000 GitHub - cilki/goldboot: Build golden images with CI · GitHub
[go: up one dir, main page]

Skip to content
cilkiPublic

Repository files navigation

License build Discord GitHub repo size Turbine Stars


People usually don't reinstall their OS from scratch very often. When they do, chaos ensues the moment they reach that pristine desktop or terminal. Settings get changed, applications are installed, bloatware is removed, files are downloaded here and there. The system is generally altered from its original state into a new "customized" state by a manual flurry of mouse clicks and key presses.

This standard approach is like mutable infrastructure, meaning you mutate the state of your system repeatedly until it eventually suits your needs. And when something goes awry, you have to make the necessary changes to get it back in line.

For most people, mutable infrastructure works out fine until something major breaks or they have to migrate to a new computer altogether. In these cases, they probably end up starting over from scratch and reapply their changes again (and probably slightly differently this time).

Sophisticated computer elites probably practice immutable infrastructure. Meaning that, every time they boot their system, its state begins almost identically to the time before. Any changes that are made during the course of runtime vanish on reboot. This approach has some real benefits, but requires quite a bit of effort from the user.

goldboot is a tool that builds machine images for real hardware that can help you achieve something close to immutable infrastructure without creating a lot of extra work for yourself.

In the goldboot approach, you create a declarative configuration file for each machine that you want to deploy. Using this configuration, goldboot builds an image either on your local machine or on a CI platform like Github Actions. The resulting image can be deployed to real hardware via a USB drive or through PXE boot.

Warning: this tool is totally unfinshed and should be used for testing only! Proceed at your own risk!


goldboot is approximately what you would get if docker and packer were mixed together. Instead of building containers or virtual machines, goldboot builds images for real hardware.

These machine images (also known as golden images) contain your operating system(s), applications, software patches, and configuration all rolled into one easily deployable package.

Like Docker, goldboot is split into a client and a daemon. The daemon (goldboot-registry) builds images in virtual machines and stores them; the goldboot command talks to it over HTTP to start builds, manage images, and pull them onto real hardware. Every command that involves images needs a running registry.

Installation

Docker

Docker Pulls Docker Image Size Docker Stars

Install from DockerHub

alias goldboot="docker run --rm -v .:/root fossable/goldboot"
Crates.io

Crates.io Total Downloads

Install from crates.io

cargo install goldboot
Arch Linux

AUR Votes AUR Version AUR Last Modified

Install from the AUR

  cd /tmp
  curl https://aur.archlinux.org/cgit/aur.git/snapshot/goldboot.tar.gz | tar xf -
  makepkg -si
Nixpkgs

Install from nixpkgs

nix-shell -p goldboot
Github Releases

GitHub Downloads

Install manually from Github releases

curl -o /usr/bin/goldboot https://github.com/fossable/goldboot/releases/download/goldboot-v0.0.7/goldboot_<platform>
chmod +x /usr/bin/goldboot
Dependencies
apt-get install -y libudev1 libgtk-4-1 libglib2.0-0
Github Actions

Running on Github actions

Building golden images with CI is common practice, so there's also a Github action to make it easy:

steps:
  - name: Checkout
    uses: actions/checkout@v4

  - name: Build goldboot image
    uses: fossable/goldboot-action@main
    with:
      config-path: goldboot.json
      output-path: image.gb

  - name: Save image artifact
    uses: actions/upload-artifact@v3
    with:
      name: my_image.gb
      path: image.gb

Registry

goldboot-registry is the daemon that builds, stores, and serves goldboot images. It intentionally does not terminate TLS and does not perform any authentication of its own — both jobs belong to a reverse proxy like nginx, which is already battle-tested and far more flexible (LDAP, mTLS, oauth2-proxy, IP allowlists, etc.).

Running the server

goldboot-registry \
  --bind 127.0.0.1:3000 \
  --data-dir /var/lib/goldboot-registry

Builds run on the registry's host, so it needs QEMU (qemu-system-* and qemu-img), UEFI firmware for each architecture it builds (usually shipped with QEMU or in the distribution's ovmf/edk2-ovmf and aavmf/edk2-aarch64 packages), and, for reasonable build times, access to /dev/kvm.

Warning

Anyone who can reach the registry's API can run virtual machines on its host and, through build pre-steps, arbitrary commands. It binds to loopback by default; only expose it through a proxy that authenticates.

Pointing the client at it

goldboot looks for a registry at http://127.0.0.1:3000 unless told otherwise:

goldboot --registry registry.example.com image list

# or
export GOLDBOOT_REGISTRY=registry.example.com

An image reference that names a host (registry.example.com/archlinux:v1) uses that registry instead.

nginx in front of it

map $http_upgrade $connection_upgrade {
    default upgrade;
    ''      close;
}

server {
    listen 443 ssl http2;
    server_name registry.example.com;

    ssl_certificate     /etc/letsencrypt/live/registry.example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/registry.example.com/privkey.pem;

    client_max_body_size 32G;

    auth_basic           "goldboot registry";
    auth_basic_user_file /etc/nginx/goldboot.htpasswd;

    location / {
        proxy_pass         http://127.0.0.1:3000;
        proxy_set_header   Host              $host;
        proxy_set_header   X-Forwarded-For   $remote_addr;
        proxy_request_buffering off;   # stream large image uploads
        proxy_read_timeout 30m;

        # Test VM consoles are WebSockets
        proxy_http_version 1.1;
        proxy_set_header   Upgrade           $http_upgrade;
        proxy_set_header   Connection        $connection_upgrade;
    }
}

Create the htpasswd file with bcrypt-hashed passwords:

htpasswd -B -c /etc/nginx/goldboot.htpasswd alice

Authentication

The goldboot client speaks HTTPS by default (type http:// explicitly to opt out) and can send HTTP Basic Auth credentials when the proxy requires them:

goldboot image list --registry registry.example.com \
  --username alice --password "$PASS"

Credentials can also be supplied via environment variables, which is the recommended way to run inside CI:

export GOLDBOOT_REGISTRY_USERNAME=alice
export GOLDBOOT_REGISTRY_PASSWORD=secret
goldboot image list

Moving images between registries

Images are built directly into the registry. To copy one elsewhere, pull it into a .gb file and push that file to the other registry:

goldboot image pull archlinux:v1 --output archlinux.gb
goldboot image push archlinux.gb --registry registry.example.com

If your proxy uses a self-signed TLS certificate (homelab, internal CA), drop the CA bundle at ~/.config/goldboot/registry-cas.pem and the client will trust it without disabling certificate verification.

Install media that can't be downloaded

Some install media (Windows, for example) has no stable download link. Upload it to the registry's ISO library and reference it from a config by name and tag:

goldboot iso push Win11_24H2_English_x64.iso windows-11:24h2-amd64
goldboot iso list
iso: Iso(url: "registry:windows-11:24h2-amd64", checksum: Some("sha256:...")),

goldboot iso push and goldboot iso info print the exact line to use.

PXE netboot

The registry can netboot machines directly: build an image with netboot: true in its OS config, map the machine's MAC address to the image, and the registry serves a bootable UKI (kernel + initrd + cmdline in a single EFI binary) over TFTP. See the goldboot-registry README for setup details and a dnsmasq example.

Examples

The goldboot-examples repo contains example configurations of all supported OS types and system architectures. They are built on a weekly schedule against the latest version of goldboot.

Linux Windows macos
Alpine x86_64 Windows 10 x86_64 macOS x86_64
Arch Linux x86_64
Debian x86_64
Ubuntu x86_64

Example walkthrough

Let's build a basic Arch Linux ArchLinux image to prove we're real Linux users.

First, create a directory to hold our configuration (which can later be tracked in version control):

mkdir Test && cd Test

Make sure a registry is running (see Registry), then initialize the directory and choose ArchLinux to start with:

goldboot init \
  --name Test \
  --os ArchLinux

This will create Test.goldboot.ron which contains configuration options that can be tweaked to suit your needs. For example:

ArchLinux(
    arch: Arch(Amd64),
    minimum_size: MinimumSize("20 GiB"),
    iso: (
        url: "http://mirrors.edge.kernel.org/archlinux/iso/latest/archlinux-2026.03.01-x86_64.iso",
        checksum: None,
    ),
)

There are many ways to customize the image, but for now just build it:

goldboot build .

The registry runs the build and stores the resulting image, which shows up in goldboot image list. To deploy the image to the local machine, install goldboot along with the image to your boot partition:

goldboot install --include Test

If you don't have enough storage space under /boot, you can alternatively install to a USB drive by setting --dest.

Now you should be able to boot into goldboot:

Select the source image and target disk and off you go.

Configuring goldboot.ron the easy way

Goldboot comes with an LSP server to make editing goldboot.ron easier. To use it, configure your editor to use goldboot lsp as an LSP server for files named goldboot.ron.

Helix

[language-server]
goldboot-lsp = { command = "goldboot", args = ["lsp"] }

[[language]]
name = "ron"
auto-format = true
scope = "source.ron"
injection-regex = "ron"
file-types = ["ron", { glob = "goldboot.ron" }]
comment-token = "//"
block-comment-tokens = { start = "/*", end = "*/" }
indent = { tab-width = 4, unit = "    " }
roots = ["Cargo.toml"]
language-servers = ["goldboot-lsp"]

Releases

Sponsor this project

Used by

Contributors

Languages

0