Distrobuilder Images
Recipes that turn a service into a ready-to-run container image, built the same way every time.
In short
-
One recipe, one image
Each service is a YAML recipe that builds an Incus container image with its packages, config and startup already in place.
-
Thin on purpose
No secrets, hostnames or databases baked in. Config ships with placeholders that get filled in when the container is set up.
-
Three trusted bases
Every recipe starts from the official Alpine, AlmaLinux or Debian template, with my changes fenced off so upstream stays easy to compare.
-
Two commands
One script builds any image or group of images; another imports them into an Incus host under the name the rest of the pipeline expects.
- Images
- 17
- Base distros
- 3
- Scripts
- 3
- Secrets baked in
- 0
In detail
What's in the box
The recipes sit in three folders, and the folder says what kind of image it is:
- Base: copies of the upstream templates for Alpine, AlmaLinux and Debian. Never built on their own; every other recipe starts as a copy of one.
- Core: the identity services everything else leans on: FreeIPA, FreeRADIUS and Keycloak.
- Applications: everything that serves people or routes traffic, from Traefik and a full mail server to Nextcloud, Forgejo, Moodle, BookStack and a media server.
Most images are Alpine. A few use AlmaLinux where the software expects a Red Hat family system, and one uses Debian because a module it needs isn't packaged for Alpine.
Building and importing
One registry maps each service name to its recipe and image name, so the scripts take names or groups:
scripts/build.sh --list # everything that can be built
scripts/build.sh traefik # build one image
scripts/build.sh prod # build the production set
scripts/import.sh traefik # copy it to the Incus host and import it
Each build leaves one log and one image file. Importing replaces the image under its name, and OpenTofu rebuilds a container from it when told to.
House rules
- Placeholders, not values. Config files carry
__UPPER_SNAKE__tokens that the matching Ansible role replaces. - Edit the stock config, don't rewrite it. Change the package's own file in place, then check the result where it matters.
- Pin versions by name. PHP is always
php84-*orphp85-*, never whatever the distro calls "php" this month. - Fixed user and group numbers for any account a recipe creates, kept in one registry, so shared storage lines up across images.
- Every image can be managed: each one carries SSH and Python for Ansible.
- HTTPS ends at Traefik. Application images listen on plain HTTP behind it.
Lessons learned the hard way
Don't write /etc/resolv.conf during a build. Distrobuilder mounts the build machine's own file over it, so the write lands on the build machine and breaks its DNS, while the image keeps an empty file. Images that need one ship it as a file instead.
MariaDB can quietly listen on every interface. Adding bind-address to the end of Alpine's config puts it in a section newer MariaDB ignores. The recipes edit the existing line instead, and most fail the build unless MariaDB reports it's bound to localhost.
On Alpine 3.24, plain php means PHP 8.5. An image staying on 8.4 has to point /usr/bin/php at it, or every cron job and command line tool fails with "not found".
Busybox cron runs a user's crontab through their login shell. Service accounts with no login shell never run theirs, silently. Their jobs live in root's crontab instead, run as the service user.