Skip to content
Closed
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
10 changes: 6 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ RUN cp /app/target/$BUILD_PROFILE/ev-reth /ev-reth
FROM ubuntu:24.04 AS runtime

RUN apt-get update && \
apt-get install -y ca-certificates curl jq libssl-dev pkg-config strace tini && \
apt-get install -y ca-certificates curl jq tini && \
rm -rf /var/lib/apt/lists/*

WORKDIR /app
Expand All @@ -65,8 +65,10 @@ COPY LICENSE-* ./
# Expose ports: P2P, Discovery, Metrics, JSON-RPC, WebSocket, GraphQL, Engine API
EXPOSE 30303 30303/udp 9001 8545 8546 7545 8551

# Add health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=40s --retries=3 \
CMD /usr/local/bin/ev-reth --version || exit 1
HEALTHCHECK --interval=30s --timeout=3s --start-period=60s --retries=3 \
CMD curl -sf http://localhost:8545/ -X POST -H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"eth_syncing","params":[],"id":1}' || exit 1
Comment on lines +69 to +70
Copy link
Contributor

Choose a reason for hiding this comment

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

high

The current healthcheck only verifies that curl exits successfully. However, a JSON-RPC server can return a successful HTTP status (200 OK) even if there's an error in the response payload (e.g., {"jsonrpc":"2.0","error":{...},"id":1}).

To make the healthcheck more robust, you can pipe the output to jq and verify that the response contains a result field, which indicates a successful RPC call. The jq utility is already installed in the image.

    CMD curl -sf http://localhost:8545/ -X POST -H "Content-Type: application/json" \
    -d '{"jsonrpc":"2.0","method":"eth_syncing","params":[],"id":1}' | jq -e '.result != null'


STOPSIGNAL SIGTERM

ENTRYPOINT ["/usr/bin/tini", "--", "/usr/local/bin/ev-reth"]