diff options
| author | Paul Buetow <paul@buetow.org> | 2026-05-06 09:35:55 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-05-06 09:35:55 +0300 |
| commit | fbb7c9a9ad8d03d5d095ac441a58b37537e0ab8d (patch) | |
| tree | 2ccb042e90ca3ed99e13d9e7bf36948e7e362936 /Dockerfile | |
| parent | 3b20f2c4d16c7b7f583e9ab2b51213e9ddc94fd5 (diff) | |
add Dockerfile and Rocky Linux 9 build docs
Introduces a Docker-based build path so ior can be compiled on any
Linux host without a native Rocky 9 toolchain setup:
- Dockerfile: Rocky 9 minimal image with Go (version from ARG, default
from go.mod), static libelf/libzstd built from source, libbpfgo at
v0.9.2-libbpf-1.5.1, and mage; CMD runs mage generate + mage all
against the repo root mounted as a volume.
- scripts/build-with-docker.sh: reads GO_VERSION from go.mod, passes it
as --build-arg to docker build, mounts tracefs and BTF into the
container, writes the binary to the repo root.
- Magefile.go: adds BuildDocker target that wraps the script.
- README.md: simplified to the two build paths (Docker + native) with
links to docs/; removed GOTOOLCHAIN=auto throughout.
- docs/build-rocky-linux-9.md: full manual Rocky 9 steps, libbpfgo
toolchain setup/rollback, compile-once-run-everywhere explanation,
and timing semantics.
- docs/tui-reference.md: complete TUI hotkey reference, recording mode
details, and the .ior.zst vs Parquet trade-off table.
- AGENTS.md: removed GOTOOLCHAIN=auto from all build commands.
- internal/c/generated_tracepoints.c: regenerated against the host kernel.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'Dockerfile')
| -rw-r--r-- | Dockerfile | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..d190056 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,75 @@ +FROM rockylinux:9-minimal + +# Update GO_VERSION here to upgrade the Go toolchain baked into the image. +ARG GO_VERSION=1.26.2 + +# Install full dnf and plugin support (minimal image ships only microdnf) +RUN microdnf install -y dnf dnf-plugins-core && \ + microdnf clean all + +# Enable CRB (ships zlib-static / glibc-static), EPEL, and the BaseOS source +# repo (provides the elfutils source RPM needed to build libelf.a). +RUN dnf config-manager --set-enabled crb && \ + dnf config-manager --set-enabled baseos-source && \ + dnf install -y epel-release && \ + dnf clean all + +# Build-time toolchain: C compiler, clang/LLVM (for BPF), bpftool, BPF/elf +# headers, static archives for zlib and glibc, and packaging helpers. +RUN dnf install -y \ + gcc clang bpftool \ + elfutils-libelf-devel \ + zlib-static glibc-static libzstd-devel \ + git make cmake wget rpmdevtools && \ + dnf builddep -y elfutils && \ + dnf clean all + +# Install Go from go.dev — Rocky 9 ships an older release, ior needs 1.26+. +RUN wget -q "https://go.dev/dl/go${GO_VERSION}.linux-amd64.tar.gz" -O /tmp/go.tar.gz && \ + tar -C /usr/local -xf /tmp/go.tar.gz && \ + rm /tmp/go.tar.gz + +ENV PATH="/usr/local/go/bin:/root/go/bin:${PATH}" +ENV GOPATH="/root/go" + +# Build libelf.a from the Rocky 9 elfutils source RPM. +# Rocky 9 does not ship libelf.a (no *-static packages exist in the distro). +RUN mkdir -p /root/src && cd /root && \ + dnf download --source elfutils-libelf && \ + rpm -ivh elfutils-*.src.rpm && \ + tar -C /root/src -xjf rpmbuild/SOURCES/elfutils-*.tar.bz2 && \ + cd /root/src/elfutils-* && \ + ./configure --enable-deterministic-archives --disable-debuginfod --disable-libdebuginfod && \ + make -C lib -j$(nproc) && \ + make -C libelf -j$(nproc) && \ + cp -v libelf/libelf.a /usr/lib64/ && \ + rm -rf /root/src /root/rpmbuild /root/elfutils-*.src.rpm + +# Build libzstd.a from upstream — libzstd-devel does not ship the static archive. +RUN wget -q https://github.com/facebook/zstd/releases/download/v1.5.5/zstd-1.5.5.tar.gz \ + -O /tmp/zstd.tar.gz && \ + tar -C /tmp -xzf /tmp/zstd.tar.gz && \ + make -C /tmp/zstd-1.5.5/lib -j$(nproc) libzstd.a && \ + cp -v /tmp/zstd-1.5.5/lib/libzstd.a /usr/lib64/ && \ + rm -rf /tmp/zstd-1.5.5 /tmp/zstd.tar.gz + +# Clone libbpfgo at the required tag and build the static archive. +# Placed at /git/libbpfgo so it is a sibling of the ior mount at /git/ior, +# matching the default LIBBPFGO=../libbpfgo path used by Magefile.go. +RUN mkdir -p /git && \ + git clone https://github.com/aquasecurity/libbpfgo /git/libbpfgo && \ + git -C /git/libbpfgo checkout v0.9.2-libbpf-1.5.1 && \ + git -C /git/libbpfgo submodule update --init --recursive && \ + make -C /git/libbpfgo libbpfgo-static + +# Install the mage build tool +RUN go install github.com/magefile/mage@latest + +# The ior source tree is mounted at /git/ior at runtime (see build-with-docker.sh). +WORKDIR /git/ior + +# Generate kernel-specific tracepoint code then compile the static ior binary. +# IOR_FORCE_GENERATE=1 skips the strict diff against the committed syscall-coverage +# audit, which was generated on a different kernel build than the container host. +# The container runs as root so bpftool and /sys/kernel/tracing are used directly. +CMD ["sh", "-c", "IOR_FORCE_GENERATE=1 mage generate && mage all"] |
