98 lines
2.8 KiB
Markdown
98 lines
2.8 KiB
Markdown
# docker-builder
|
|
|
|
A small toolchain for setting up, caching and sharing build
|
|
environments.
|
|
|
|
## Existing envs
|
|
|
|
### [openwrt/](./openwrt/)
|
|
|
|
For building OpenWrt. Helps you manage build inputs.
|
|
|
|
See commit 7b2d32b for more details on how to use this, or read on.
|
|
|
|
#### Setup
|
|
TL;DR:
|
|
|
|
- Fix the value of `$docker_src` in `./docker_vars.sh` and at the top
|
|
of the main Makefile.
|
|
|
|
- You may also want to tweak `$build_threads`.
|
|
|
|
- In Docker: Make sure you are using a storage driver (often different
|
|
than the volume driver) big enough to hold the interim build
|
|
process; e.g. overlay2. Default Docker as of Ubuntu 20.04 has a 10G
|
|
limit on volumes.
|
|
|
|
```json
|
|
# /etc/docker/daemon.json
|
|
{
|
|
"storage-driver": "overlay2"
|
|
}
|
|
```
|
|
|
|
- Make sure you point dockerd somewhere you have sufficient space for
|
|
docker to store images. Example setup, using an override.conf to
|
|
reset ExecStart and point (`-g`) `dockerd` at a 100G-large
|
|
`/dockervl` filesystem:
|
|
|
|
```txt
|
|
$ systemctl cat docker
|
|
# /lib/systemd/system/docker.service
|
|
# :
|
|
# :
|
|
# /etc/systemd/system/docker.service.d/override.conf
|
|
[Service]
|
|
ExecStart=
|
|
ExecStart=/usr/bin/dockerd -g /dockervl -H fd:// --containerd=/run/containerd/containerd.sock
|
|
|
|
[Unit]
|
|
After=dockervl.mount
|
|
$ sudo df -h /dockervl
|
|
Filesystem Size Used Avail Use% Mounted on
|
|
/dev/mapper/vg00-dockervl 100G 12G 89G 12% /dockervl
|
|
```
|
|
|
|
#### Usage
|
|
- Add new remotes by name-tab-URL to `openwrt-remotes.txt`.
|
|
|
|
- The main Makefile will manage building containers ('builders'); the
|
|
submakefile in `openwrt/` will deal with actually collecting inputs
|
|
and building.
|
|
|
|
- Set up the diffconfig and file tree for the target you want to
|
|
build. (The `openwrt/menuconfig-%` target wraps the menuconfig
|
|
OpenWrt target for this purpose; see the next point.)
|
|
|
|
- Run `make` on the right (.PHONY) target to build the necessary
|
|
containers and e.g. build OpenWrt. The target name is based on the
|
|
action, remote and revision you want; with `$action` being output,
|
|
menuconfig or debug.
|
|
|
|
- The full name format is: `openwrt/${action}-${remote}_${revision}`,
|
|
where `$remote` is in `openwrt-remotes.txt`, and with `$revision`
|
|
being e.g. a tag, a branch, etc. at the remote you use.
|
|
|
|
- Additional files can be added under `openwrt/files/`.
|
|
|
|
- Example run:
|
|
|
|
```sh
|
|
cd ${docker_src}/;
|
|
make openwrt/menuconfig-mirror_21.02
|
|
# Wait for build and go through menuconfig
|
|
# Save the OpenWrt .config file to the default location, then quit.
|
|
# Once you quit, the diffconfig will be collected and dropped to output/diffconfig.
|
|
|
|
cp openwrt/output/diffconfig mr16-for-testing.diffconfig
|
|
cp mr16-for-testing.diffconfig openwrt/diffconfig
|
|
mkdir -p openwrt/files/etc
|
|
touch openwrt/files/etc/hello # This will end up in the image at /etc/hello
|
|
|
|
# With the diffconfig + files in place:
|
|
nohup make openwrt/output-mirror_21.02 &
|
|
|
|
# Watch the output at:
|
|
tail -f openwrt/output/screen.log
|
|
```
|