summaryrefslogtreecommitdiff
path: root/scripts/build-with-docker.sh
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-05-06 09:35:55 +0300
committerPaul Buetow <paul@buetow.org>2026-05-06 09:35:55 +0300
commitfbb7c9a9ad8d03d5d095ac441a58b37537e0ab8d (patch)
tree2ccb042e90ca3ed99e13d9e7bf36948e7e362936 /scripts/build-with-docker.sh
parent3b20f2c4d16c7b7f583e9ab2b51213e9ddc94fd5 (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 'scripts/build-with-docker.sh')
-rwxr-xr-xscripts/build-with-docker.sh50
1 files changed, 50 insertions, 0 deletions
diff --git a/scripts/build-with-docker.sh b/scripts/build-with-docker.sh
new file mode 100755
index 0000000..02eb60f
--- /dev/null
+++ b/scripts/build-with-docker.sh
@@ -0,0 +1,50 @@
+#!/usr/bin/env bash
+# Build the ior binary inside a Rocky Linux 9 container and write it to the
+# current directory. The container image is built once and reused on subsequent
+# runs. The ior source tree is mounted as a volume so the resulting binary
+# lands directly in $(pwd)/ior.
+#
+# Usage:
+# ./build-with-docker.sh # build image + compile ior
+# ./build-with-docker.sh --build # force rebuild of the Docker image
+# ./build-with-docker.sh --run # skip image build, only compile ior
+set -euo pipefail
+
+IMAGE="ior-builder:rocky9"
+REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
+
+# Derive the Go version from go.mod so the Docker image always matches the
+# minimum toolchain declared by the project.
+GO_VERSION="$(grep '^go ' "${REPO_ROOT}/go.mod" | awk '{print $2}')"
+
+BUILD_IMAGE=true
+RUN_BUILD=true
+
+for arg in "$@"; do
+ case "$arg" in
+ --build) BUILD_IMAGE=true; RUN_BUILD=false ;;
+ --run) BUILD_IMAGE=false; RUN_BUILD=true ;;
+ esac
+done
+
+if $BUILD_IMAGE; then
+ echo "==> Building Docker image ${IMAGE} (this takes ~15-20 min on first run)..."
+ docker build --build-arg "GO_VERSION=${GO_VERSION}" -t "${IMAGE}" "${REPO_ROOT}"
+ echo "==> Image build complete."
+fi
+
+if $RUN_BUILD; then
+ echo "==> Compiling ior inside the container..."
+ # --privileged gives full host capabilities.
+ # tracefs (/sys/kernel/tracing) and BTF (/sys/kernel/btf) are not auto-mounted
+ # by Docker even with --privileged, so they are mounted explicitly:
+ # - /sys/kernel/tracing : mage generate reads available syscall tracepoints
+ # - /sys/kernel/btf : mage bpfBuild reads vmlinux BTF for vmlinux.h
+ docker run --rm \
+ --privileged \
+ -v /sys/kernel/tracing:/sys/kernel/tracing \
+ -v /sys/kernel/btf:/sys/kernel/btf \
+ -v "${REPO_ROOT}:/git/ior" \
+ "${IMAGE}"
+ echo "==> Done. Binary written to ${REPO_ROOT}/ior"
+fi