Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 19 additions & 21 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,35 +22,25 @@ ARG TAG_NAME=unknown

ADD . /graph-node

RUN apt-get update \
&& apt-get install -y cmake protobuf-compiler && \
cd /graph-node && \
RUSTFLAGS="-g" cargo build --release --package graph-node \
RUN apt-get update && apt-get install -y cmake protobuf-compiler

RUN cd /graph-node \
&& RUSTFLAGS="-g -C force-frame-pointers=yes" cargo build --release --package graph-node \
&& cp target/release/graph-node /usr/local/bin/graph-node \
&& cp target/release/graphman /usr/local/bin/graphman \
# Reduce the size of the layer by removing unnecessary files.
&& cargo clean \
&& objcopy --only-keep-debug /usr/local/bin/graph-node /usr/local/bin/graph-node.debug \
&& strip -g /usr/local/bin/graph-node \
&& strip -g /usr/local/bin/graphman \
&& cd /usr/local/bin \
&& objcopy --add-gnu-debuglink=graph-node.debug graph-node \
&& echo "REPO_NAME='$REPO_NAME'" > /etc/image-info \
&& cp /usr/local/bin/graph-node /usr/local/bin/graph-node-debug \
&& cp /usr/local/bin/graphman /usr/local/bin/graphman-debug \
&& strip -g /usr/local/bin/graph-node /usr/local/bin/graphman

RUN echo "REPO_NAME='$REPO_NAME'" > /etc/image-info \
&& echo "TAG_NAME='$TAG_NAME'" >> /etc/image-info \
&& echo "BRANCH_NAME='$BRANCH_NAME'" >> /etc/image-info \
&& echo "COMMIT_SHA='$COMMIT_SHA'" >> /etc/image-info \
&& echo "CARGO_VERSION='$(cargo --version)'" >> /etc/image-info \
&& echo "RUST_VERSION='$(rustc --version)'" >> /etc/image-info \
&& echo "CARGO_DEV_BUILD='$CARGO_DEV_BUILD'" >> /etc/image-info

# Debug image to access core dumps
FROM graph-node-build AS graph-node-debug
RUN apt-get update \
&& apt-get install -y curl gdb postgresql-client

COPY docker/Dockerfile /Dockerfile
COPY docker/bin/* /usr/local/bin/

# The graph-node runtime image with only the executable
FROM debian:bookworm-20241111-slim AS graph-node
ENV RUST_LOG=""
Expand Down Expand Up @@ -97,8 +87,7 @@ EXPOSE 8020
EXPOSE 8030

RUN apt-get update \
&& apt-get install -y libpq-dev ca-certificates \
netcat-openbsd
&& apt-get install -y libpq-dev ca-certificates netcat-openbsd

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

# Debug and profiling image
# Build with: docker build --target graph-node-debug -f docker/Dockerfile .
FROM graph-node AS graph-node-debug
COPY --from=graph-node-build /usr/local/bin/graph-node-debug /usr/local/bin/graph-node
COPY --from=graph-node-build /usr/local/bin/graphman-debug /usr/local/bin/graphman
RUN apt-get update \
&& apt-get install -y curl gdb postgresql-client linux-perf procps binutils
COPY docker/Dockerfile /Dockerfile
COPY docker/bin/* /usr/local/bin/
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should also copy /etc/image-info to help identify what exact graph-node version is in the image