Skip to content

Commit 65ff988

Browse files
committed
docker: Add profiling support to graph-node-debug image (#6418)
Build with frame pointers enabled for all builds. Rebase graph-node-debug on the slim runtime image instead of the full Rust build stage, add linux-perf for CPU profiling alongside existing debug tools. Remove unused objcopy debug link dance from production build since the .debug file was never copied to the final image.
1 parent 53c96d6 commit 65ff988

1 file changed

Lines changed: 19 additions & 21 deletions

File tree

docker/Dockerfile

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -22,35 +22,25 @@ ARG TAG_NAME=unknown
2222

2323
ADD . /graph-node
2424

25-
RUN apt-get update \
26-
&& apt-get install -y cmake protobuf-compiler && \
27-
cd /graph-node && \
28-
RUSTFLAGS="-g" cargo build --release --package graph-node \
25+
RUN apt-get update && apt-get install -y cmake protobuf-compiler
26+
27+
RUN cd /graph-node \
28+
&& RUSTFLAGS="-g -C force-frame-pointers=yes" cargo build --release --package graph-node \
2929
&& cp target/release/graph-node /usr/local/bin/graph-node \
3030
&& cp target/release/graphman /usr/local/bin/graphman \
31-
# Reduce the size of the layer by removing unnecessary files.
3231
&& cargo clean \
33-
&& objcopy --only-keep-debug /usr/local/bin/graph-node /usr/local/bin/graph-node.debug \
34-
&& strip -g /usr/local/bin/graph-node \
35-
&& strip -g /usr/local/bin/graphman \
36-
&& cd /usr/local/bin \
37-
&& objcopy --add-gnu-debuglink=graph-node.debug graph-node \
38-
&& echo "REPO_NAME='$REPO_NAME'" > /etc/image-info \
32+
&& cp /usr/local/bin/graph-node /usr/local/bin/graph-node-debug \
33+
&& cp /usr/local/bin/graphman /usr/local/bin/graphman-debug \
34+
&& strip -g /usr/local/bin/graph-node /usr/local/bin/graphman
35+
36+
RUN echo "REPO_NAME='$REPO_NAME'" > /etc/image-info \
3937
&& echo "TAG_NAME='$TAG_NAME'" >> /etc/image-info \
4038
&& echo "BRANCH_NAME='$BRANCH_NAME'" >> /etc/image-info \
4139
&& echo "COMMIT_SHA='$COMMIT_SHA'" >> /etc/image-info \
4240
&& echo "CARGO_VERSION='$(cargo --version)'" >> /etc/image-info \
4341
&& echo "RUST_VERSION='$(rustc --version)'" >> /etc/image-info \
4442
&& echo "CARGO_DEV_BUILD='$CARGO_DEV_BUILD'" >> /etc/image-info
4543

46-
# Debug image to access core dumps
47-
FROM graph-node-build AS graph-node-debug
48-
RUN apt-get update \
49-
&& apt-get install -y curl gdb postgresql-client
50-
51-
COPY docker/Dockerfile /Dockerfile
52-
COPY docker/bin/* /usr/local/bin/
53-
5444
# The graph-node runtime image with only the executable
5545
FROM debian:bookworm-20241111-slim AS graph-node
5646
ENV RUST_LOG=""
@@ -97,8 +87,7 @@ EXPOSE 8020
9787
EXPOSE 8030
9888

9989
RUN apt-get update \
100-
&& apt-get install -y libpq-dev ca-certificates \
101-
netcat-openbsd
90+
&& apt-get install -y libpq-dev ca-certificates netcat-openbsd
10291

10392
ADD docker/wait_for docker/start /usr/local/bin/
10493
COPY --from=graph-node-build /usr/local/bin/graph-node /usr/local/bin/graphman /usr/local/bin/
@@ -107,3 +96,12 @@ COPY --from=envsubst /go/bin/envsubst /usr/local/bin/
10796
COPY docker/Dockerfile /Dockerfile
10897
CMD ["start"]
10998

99+
# Debug and profiling image
100+
# Build with: docker build --target graph-node-debug -f docker/Dockerfile .
101+
FROM graph-node AS graph-node-debug
102+
COPY --from=graph-node-build /usr/local/bin/graph-node-debug /usr/local/bin/graph-node
103+
COPY --from=graph-node-build /usr/local/bin/graphman-debug /usr/local/bin/graphman
104+
RUN apt-get update \
105+
&& apt-get install -y curl gdb postgresql-client linux-perf procps binutils
106+
COPY docker/Dockerfile /Dockerfile
107+
COPY docker/bin/* /usr/local/bin/

0 commit comments

Comments
 (0)