README.md: add clearer ImageBuilder examples using Docker and Podman

Document building firmware using Docker or Podman with one-liners, including
snapshot support.

Signed-off-by: George Sapkin <george@sapk.in>
main
George Sapkin 2026-08-17 20:45:04 +03:00 committed by Paul Spooren
parent e077925f1d
commit c0ddfae186
1 changed files with 54 additions and 8 deletions

View File

@ -9,7 +9,7 @@ for our CI you may use the scripts to build containers on your own.
> [!WARNING] > [!WARNING]
> Starting with the branch of OpenWrt 24.10 any snapshot (aka nightly), builds no > Starting with the branch of OpenWrt 24.10 any snapshot (aka nightly), builds no
> longer contain the actual binaries but instead a `setup.sh` script. The > longer contain the actual binaries, but instead a `setup.sh` script. The
> environment variables are set automatically per container to download the > environment variables are set automatically per container to download the
> correct archive containing the SDK/ImageBuilder/rootfs. This dramatically > correct archive containing the SDK/ImageBuilder/rootfs. This dramatically
> reduces bandwidth and storage usage. Sorry for the inconvenience. > reduces bandwidth and storage usage. Sorry for the inconvenience.
@ -74,15 +74,61 @@ via CI.
### ImageBuilder Example ### ImageBuilder Example
Built images will be stored in `bin`, and cached packages, that can be reused
for other builds - in `dl`. Packages from differenet platforms/versions might
have the same package names, but different checksums, which will cause
errors during build, so working directories shouldn't be shared between
different image builders.
> If you're running on a SELinux-enabled system (e.g. RHEL), volumes must be
> mounted with a `:z` flag:
>
> ```shell
> --volume "$(pwd)"/bin/:/builder/bin:z
> ```
Using Docker:
```shell ```shell
docker run --rm -v "$(pwd)"/bin/:/builder/bin -it openwrt/imagebuilder # NB: Replace these variables, according to your needs
# inside the Docker container PLATFORM=ath79-generic
[ ! -d ./scripts ] && ./setup.sh VERSION=25.12.5
make image PROFILE=generic PACKAGES=tmate PROFILE=tplink_archer-c7-v2
PACKAGES="ath10k-firmware-qca988x kmod-ath10k kmod-usb-ledtrig-usbport kmod-usb-net-cdc-ether kmod-usb2 luci luci-ssl luci-app-sqm luci-app-attendedsysupgrade owut -ppp -ppp-mod-pppoe -luci-proto-ppp -ath10k-firmware-qca988x-ct -kmod-ath10k-ct"
mkdir -p openwrt-${PLATFORM}-${VERSION}/{bin,dl}
cd openwrt-${PLATFORM}-${VERSION}
docker run --rm \
--volume "$(pwd)"/bin/:/builder/bin \
--volume "$(pwd)"/dl:/builder/dl \
openwrt/imagebuilder:${PLATFORM}-${VERSION} \
sh -c "
[ ! -d ./scripts ] && ./setup.sh;
make image PROFILE='${PROFILE}' PACKAGES='${PACKAGES}'
"
``` ```
Enjoy a local OpenWrt ImageBuilder container building an image for x86/64 and Using Podman we need to map user account to same UID within container using
store the binary in hosts `./bin` folder. `--userns=keep-id`:
```shell
# Same variables as above
podman run --rm \
--userns=keep-id \
--volume "$(pwd)"/bin/:/builder/bin \
--volume "$(pwd)"/dl:/builder/dl \
openwrt/imagebuilder:${PLATFORM}-${VERSION} \
sh -c "
[ ! -d ./scripts ] && ./setup.sh;
make image PROFILE='${PROFILE}' PACKAGES='${PACKAGES}'
"
```
Variables can be inlined to make these into one-liners.
> For snapshots use `VERSION=SNAPSHOT`.
### ImageBuilder Tags ### ImageBuilder Tags