Skip to content

Commit 0b2c58d

Browse files
committed
build: add eBPF profiling-friendly debug image and observability docs
1 parent 0e37ffc commit 0b2c58d

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

Dockerfile.debug

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ COPY --from=planner /app/recipe.json recipe.json
1818
ARG BUILD_PROFILE=release
1919
ENV BUILD_PROFILE=$BUILD_PROFILE
2020

21+
# Build flags for profiling-friendly binaries.
22+
# Defaults enable call-stack unwinding and symbol data for better eBPF flamegraphs.
23+
ARG RUSTFLAGS="-C force-frame-pointers=yes -C debuginfo=1 -C symbol-mangling-version=v0"
24+
ENV RUSTFLAGS=$RUSTFLAGS
25+
2126
# Builds dependencies with debug profile (faster linking, keeps symbols)
2227
RUN cargo chef cook --profile $BUILD_PROFILE --recipe-path recipe.json
2328

@@ -31,9 +36,20 @@ RUN cp /app/target/release/bera-reth /app/bera-reth
3136
# Use Ubuntu as the release image
3237
FROM ubuntu:24.04 AS runtime
3338

34-
# Install runtime dependencies
39+
# Install runtime dependencies and eBPF observability tooling.
40+
# Note: eBPF tooling requires extra container privileges at runtime
41+
# (for example: --privileged, or CAP_BPF + CAP_PERFMON + CAP_SYS_ADMIN,
42+
# and usually --pid=host with host /sys mounted).
3543
RUN apt-get update && \
36-
apt-get install -y ca-certificates libssl-dev && \
44+
apt-get install -y \
45+
ca-certificates \
46+
libssl-dev \
47+
linux-tools-common \
48+
bpftrace \
49+
bpfcc-tools \
50+
procps \
51+
psmisc \
52+
strace && \
3753
rm -rf /var/lib/apt/lists/*
3854

3955
# Copy bera-reth over from the build stage
@@ -49,5 +65,6 @@ EXPOSE 30303 30303/udp 9001 8545 8546 8551
4965
# Set environment to show we're in debug mode
5066
ENV RUST_LOG=debug
5167
ENV BUILD_TYPE=release
68+
ENV BPFTRACE_CACHE_USER_SYMBOLS=1
5269

5370
ENTRYPOINT ["/usr/local/bin/bera-reth"]

Makefile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,17 @@ docker-build-debug: ## Fast debug build using Docker multistage (no cross-compil
5050
docker build --file Dockerfile.debug --tag $(DOCKER_IMAGE_NAME):debug \
5151
--build-arg COMMIT=$(GIT_SHA) \
5252
--build-arg VERSION=$(GIT_TAG) \
53+
--build-arg BUILD_PROFILE=$(PROFILE) \
54+
.
55+
56+
.PHONY: docker-build-debug-profiling
57+
docker-build-debug-profiling: ## Build profiling-friendly debug image (frame pointers + debuginfo) for flamegraphs.
58+
@echo "Building profiling debug Docker image..."
59+
docker build --file Dockerfile.debug --tag $(DOCKER_IMAGE_NAME):debug-profiling \
60+
--build-arg COMMIT=$(GIT_SHA) \
61+
--build-arg VERSION=$(GIT_TAG) \
62+
--build-arg BUILD_PROFILE=$(PROFILE) \
63+
--build-arg RUSTFLAGS="-C force-frame-pointers=yes -C debuginfo=1 -C symbol-mangling-version=v0" \
5364
.
5465

5566
.PHONY: docker-build-push-nightly

0 commit comments

Comments
 (0)