This folder contains a Makefile to build pmacct docker images. It simplifies
the build process, particularly for multi-platform images.
A number of environment variables control the build process (make):
PLATFORMS: comma separated list of platforms to pass todocker buildx --platforms. Default:linux/amd64.BUILD_REGISTRY: intermediate registry to build multi-platform images. Default:""(none).PUSH: push to docker registry$PUSH. The registry should NOT have a trailing/. Default""(don't push).TAGS: whenPUSHis defined, it will push all the tags listed inTAGS. Default:"".V: when set to1output is verbose. Default:"".
To build:
make
Once completed, base:_build and all <daemon>:_build images will be loaded to
your local images.
Building multi-platform images for pmacct using docker buildx is a bit tricky.
Today docker/dockerd's local image registry doesn't support more than one
platfor (the host's one). In other words, docker buildx's argument --load
only works for a single platform matching your host. This limitation might be
lifted in the future, but for now we need to live with it.
pmacct daemon Dockerfile files require the base container to build.
Technically, daemon containers are the same container with a different
entrypoint.
TL;DR you will need an auxiliary docker registry that supports multiple platforms to build multi-platform images.
It is highly recommended to use a temporary/adhoc docker registry for the
build process, to avoid clogging the real registries with _build tags and
avoid concurrency issues when parallel builds are fired (e.g. from CI).
Launch a temporary registry:
docker run -d -p 5000:5000 --name registry registry:2
Use docker inspect to get the IP address of the container:
docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' registry
With the hostname or IP address of the registry above, launch the multi-platform build process:
PLATFORMS="linux/amd64,linux/arm64" \
BUILD_REGISTRY_REPO=<REGISTRY_HOSTNAME_IP>:5000 \
PUSH=<REGISTRY_TO_PUSH> \
TAGS="<list of comma separated tags to push to REGISTRY_TO_PUSH>" \
make
Get some 🍿 for the xcompilation...
Make sure to tear down and remove the registry:
docker stop registry
docker rm registry
Define PUSH=<registry> without the trailing /. Make sure to add some
meaningful TAGS. _base tag will NOT be pushed.
Don't touch unless you know what are you doing:
N_WORKERS: number of parallel workers to pass to make for compiling C/C++ code. Default:2MEMORY: memory limit passed todocker buildx. Default:8g.DAEMONS: list ofDAEMONSto build the container for. Default: all pmacct daemons.