Container based imagebuilder runtime

I made a container for using the imagebuilder as I often found myself having to install tons of perl dependencies on my system of which many I'm never going to use again and I don't want them dangling.

Containerfile:

# for building with the imagebuilders
# build: podman build . --tag openwrt-builder
# run like: cd openwrt-imagebuilder*; podman run --rm -i -v ./:/src:rw,Z openwrt-builder <your build command, e.g. image PROFILE="_" PACKAGES="_">
# output will be on the same openwrt-imagebuilder directory
FROM registry.access.redhat.com/ubi9/ubi-minimal:latest

RUN microdnf install -y make patch perl bzip2 wget diffutils && microdnf clean all && rm -rf /var/lib/{rpm,dnf}
VOLUME [ "/src" ]
WORKDIR /src
ENTRYPOINT [ "/usr/bin/make" ]
CMD []

place it on an empty dir named "Containerfile" (or "Dockerfile") and run podman build . --tag openwrt-builder
then on the openwrt-imagebuilder-${version}-* dir run podman run --rm -i -v ./:/src:rw,Z openwrt-builder <your build command without make>

e.g.
podman run --rm -i -v ./:/src:rw,Z openwrt-builder help

podman run --rm -i -v ./:/src:rw,Z openwrt-builder image PROFILE="xiaomi_redmi-router-ax6s" PACKAGES="base-files ca-bundle dnsmasq dropbear firewall4 fitblk fstools kmod-gpio-button-hotplug kmod-leds-gpio kmod-mt7622-firmware kmod-nft-offload libc libgcc libustream-mbedtls logd mtd netifd nftables odhcp6c odhcpd-ipv6only opkg ppp ppp-mod-pppoe procd-ujail uboot-envtools uci uclient-fetch urandom-seed urngd wpad-basic-mbedtls kmod-mt7915-firmware luci ddns-scripts ddns-scripts-digitalocean ddns-scripts-cloudflare diffutils jq luci-app-ddns luci-app-upnp luci-proto-wireguard luci-app-wol qrencode drill"

output will be on the imagebuilder dir

then you can get rid of the container image with podman rmi openwrt-builder to free the space from all those deps or keep it for further builds without polluting your system

cheers :slight_smile:

Would the pre-built imagebuilder containers make anything easier for you? https://github.com/openwrt/docker

Below is pretty much what the ASU server is doing, with some different volume mounts for repo config and stuff, but mostly identical. The (newer) containers are initially empty, you have to source the setup.sh script to get it set up, then you just treat it like any other imagebuilder. When ASU server uses it for the build, it copies the desired artifacts (the bin/.../manifest and imgs) to the store dir, so you don't have any transient junk to clean up on the host (other that the images you've already mentioned).

$ podman run -it -v ./store/:/builder/store:rw,U,Z ghcr.io/openwrt/imagebuilder:x86-64-openwrt-24.10
buildbot@fb186b2727db:~$ ls -la
total 16
drwxr-xr-x. 1 buildbot buildbot   88 Jul 10 13:46 .
dr-xr-xr-x. 1 root     root       12 Jul 10 13:46 ..
-rw-r--r--. 1 buildbot buildbot  220 Mar 27  2022 .bash_logout
-rw-r--r--. 1 buildbot buildbot 3526 Mar 27  2022 .bashrc
drwxr-xr-x. 1 buildbot buildbot  156 Jun 12 06:14 keys
-rw-r--r--. 1 buildbot buildbot  807 Mar 27  2022 .profile
-rwxr-xr-x. 1 root     root      995 Jun 12 06:12 setup.sh
drwxr-xr-x. 1 buildbot buildbot  134 Jul 10 13:42 store

buildbot@fb186b2727db:~$ . setup.sh
2025-07-10 13:47:52 URL:https://downloads.openwrt.org/releases/24.10-SNAPSHOT/targets/x86/64/sha256sums [5222880/5222880] -> "sha256sums" [1]
...
removed 'openwrt-imagebuilder-24.10-SNAPSHOT-x86-64.Linux-x86_64.tar.zst'

buildbot@fb186b2727db:~$ make help
Available Commands:
        help:   This help text
...
1 Like

I was not aware these existed!!! thanks!!!

I found that you don't even need to source the setup script if you use a tag
just pulled quay.io/openwrt/imagebuilder:mediatek-mt7622-24.10.2 for my AX3200 and ran my make command and it produced the images. nice!
maybe could be better documented, or even shown on the firmware-selector.openwrt.org site when customizing packages as an alternative to making openwrt's servers do it :slight_smile:

I'm surprised the buildworker's image doesn't even install any perl packages. how does that even work?!

I think all the buildbot infrastructure is python, so no perl at all in the runners.