Building from Source
This guide covers container and host builds. Run all commands from the repository root. See go.mod for the required Go version.
When updating from a version with io_health, iolatency, or iocost object names, run make clean, then make gen-build, before make build, make check, or make unit. This prevents stale objects and generated Go ABI files from mixing with the new names.
Container Build
Run the script to build in a container and perform static checks:
$ sh build/build-run-testing-image.sh
Or run the steps separately:
1. Prepare the build environment
$ docker build --network host -t huatuo/huatuo-bamai-dev:latest -f ./Dockerfile.devel .
2. Start the build container
$ docker run -it --pid=host --privileged --cgroupns=host --network=host -v $(pwd):/go/huatuo-bamai huatuo/huatuo-bamai-dev:latest sh
3. Build inside the container
$ make
Runtime Image
The following command builds a local runtime image. It does not push the image to a registry:
docker build --network host -t huatuo/huatuo-bamai:latest .
Host Build
Install Dependencies
Ubuntu 24.04:
apt install make git clang libbpf-dev linux-tools-common curl capnproto
Fedora 40:
dnf install make git clang libbpf-devel bpftool curl capnproto capnproto-devel glibc-static
go install mvdan.cc/gofumpt@v0.8.0
go install mvdan.cc/sh/v3/cmd/shfmt@v3.11.0
go install golang.org/x/tools/cmd/goimports@v0.36.0
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.62.2
go install github.com/vektra/mockery/v2@v2.53.6
go install capnproto.org/go/capnp/v3/capnpc-go@v3.1.0-alpha.2
Build
$ make
BPF Debug Build
Set BPF_DEBUG=1 to pass -DDEBUG_BPF to Clang and compile debug code into the BPF object:
$ make BPF_DEBUG=1 # Or regenerate artifacts only: make BPF_DEBUG=1 gen-build
See Debugging for instrumentation, runtime switches, and logs.