Easily and quickly build LEDE or OpenWRT custom images using a self-contained docker container and the LEDE or OpenWrt image builder. On the builder host, Docker is the only requirement.
The lede-dockerbuilder uses pre-compiled packages to build the final image. Look here if you are looking for a docker images to compile LEDE/OpenWRT completely from source.
- customized and optimized (size) images with your personal configurations
- full automatic image creation (could be run in CI)
- reproducable results
- easy configuration, fast build (in minutes)
$ git clone https://github.com/jandelgado/lede-dockerbuilder.git
$ cd lede-dockerbuilder
$ ./builder.sh build example-nexx-wt3020.conf
Your custom images can now be found in the output
diretory.
The build
command will first build the docker image containing the LEDE image
builder. The resulting docker image is per default tagged with
lede-imagebuilder:<Release>-<Target>-<Subtarget>
. Afterwards a container,
which builds the actual LEDE image, is run. The final LEDE/OpenWRT image will be
available in the output/
directory.
Dockerized LEDE/OpenWRT image builder.
Usage: ./builder.sh COMMAND CONFIGFILE [OPTIONS]
COMMAND is one of:
build-docker-image- just build the docker image
build - build docker image, then start container and build the LEDE image
shell - start shell in docker container
CONFIGFILE - configuraton file to use
OPTIONS:
-o OUTPUT_DIR - output directory
-f ROOTFS_OVERLAY - rootfs-overlay directory
--skip-sudo - call docker directly, without sudo
command line options -o, -f, -r override config file settings.
Example:
./builder.sh build example.cfg -o output -f myrootfs
The configuration file is quiet self-explanatory. The following parameters are mandatory:
LEDE_TARGET
- Target architectureLEDE_SUBTARGET
- Sub target architectureLEDE_RELEASE
- LEDE release to useLEDE_PROFILE
- LEDE profile to useLEDE_BUILDER_URL
- URL of the LEDE image builder to useLEDE_PACKAGES
- list of packages to include/exclude. Prepend package to be excluded with-
.
LEDE_TARGET
, LEDE_SUBTARGET
and LEDE_RELEASE
are used to construct the
URL of the image builder binary, LEDE_BUILDER_URL
as well as for the
construction for the tag of the docker image.
You can find the proper values (for LEDE 17.01) by browsing the LEDE website here and here.
In addition the following optional parameters can be set, to further control output and image creation:
OUTPUT_DIR
- path where resulting images are stored. Defaults tooutput
in the scripts directory (can be overridden by -o parameter)ROOTFS_OVERLAY
- path of the root file system overlay directory. Defaults torootfs-overlay
in the scripts directory (can be overridden by -f parameter)
Use the BASEDIR_CONFIG_FILE
variable to set locations of OUTPUT_DIR
or
ROOTFS_OVERLAY
relative to the configuration files location. This allows
self-contained projects outside of the lede-dockerbuilder folder. If e.g.
ROOTFS_OVERLAY=$BASEDIR_CONFIG_FILE/rootfs-overlay
is set, then the
rootfs-overlay directory is expected to be in the same directory as the
configuration file.
Example configuration for my NEXX WT3020 router, where I have an encrypted USB disk attached so I can use it as a simple NAS.
# LEDE profile to use
LEDE_PROFILE=wt3020-8M
# specify the URL where the builder can be downloaded.
LEDE_RELEASE=17.01.1
LEDE_TARGET=ramips
LEDE_SUBTARGET=mt7620
LEDE_BUILDER_URL="https://downloads.lede-project.org/releases/$LEDE_RELEASE/targets/$LEDE_TARGET/$LEDE_SUBTARGET/lede-imagebuilder-$LEDE_RELEASE-$LEDE_TARGET-$LEDE_SUBTARGET.Linux-x86_64.tar.xz"
# list packages to include in LEDE image. prepend packages to deinstall with "-".
LEDE_PACKAGES="samba36-server kmod-usb-storage kmod-scsi-core kmod-fs-ext4 ntfs-3g\
kmod-nls-cp437 kmod-nls-iso8859-1 vsftpd cryptsetup kmod-crypto-xts\
kmod-crypto-iv block-mount kmod-usb-ohci kmod-usb2 kmod-dm\
kmod-crypto-misc kmod-crypto-cbc kmod-crypto-crc32c kmod-crypto-hash\
kmod-crypto-user iwinfo tcpdump\
-ppp -kmod-ppp -kmod-pppoe -kmod-pppox -ppp-mod-pppoe"
Place any files and folders that should be copied to the root file system of
the resulting image to the directory pointed to by ROOTFS_OVERLAY
(default:
rootfs-overlay/
), which can be overridden by the -f command line option.
The following is an example directoy layout, which I use to create a customized LEDE image for my NEXX WT3020 router (including the generated output).
├── builder.sh
├── docker
│ ├── Dockerfile
│ └── etc
│ └── entrypoint.sh
├── example.cfg
├── example-openwrt.cfg
├── output
│ ├── lede-17.01.1-ramips-mt7620-device-wt3020-8m.manifest
│ ├── lede-17.01.1-ramips-mt7620-wt3020-8M-squashfs-factory.bin
│ ├── lede-17.01.1-ramips-mt7620-wt3020-8M-squashfs-sysupgrade.bin
│ └── sha256sums
├── README.md
└── rootfs-overlay
├── etc
│ ├── config
│ │ ├── dhcp
│ │ ├── dropbear
│ │ ├── firewall
│ │ ├── network
│ │ ├── samba
│ │ ├── system
│ │ ├── wireless
│ ├── dropbear
│ │ └── authorized_keys
│ ├── hotplug.d
│ │ └── block
│ │ └── 10-mount
│ ├── passwd
│ ├── rc.local
│ ├── shadow
│ └── vsftpd.conf
├── README.md
└── usr
└── local
└── bin
└── fix_sta_ap.sh
Run ./builder.sh shell CONFIGFILE
to get a shell into the docker container,
e.g. ./builder.sh shell example.cfg
.
The file example-openwrt-wrt1043nd.conf contains an example which uses the OpenWRT image builder to create an image for the TP-Link WR1043ND router.
These examples evolved from images I use myself.
- Minimal LEDE image with LUCI web GUI for the Raspberry PI 2. Just ~8MB gziped. I use this image on my home dnsmasq/openvpn 'server'.
- OpenWRT image for the TP-Link WR1043ND
- LEDE image with samba, vsftpd and encrypted usb disk for NEXX-WT3020. Predessor of ...
- LEDE image with samba, vsftpd and encrypted usb disk for GINET-GL-M300N. This is my travel router setup where I have an encrypted USB disk connected to the router.
To build an example run ./builder.sh build <config-file>
, e.g.
$ ./builder.sh build example-rpi2.conf
The resulting image can be found in the output/
directory.
Jan Delgado
Apache License 2.0