Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Add readiness check for docker container #9804

Merged
merged 2 commits into from
Oct 26, 2018
Merged
Show file tree
Hide file tree
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
4 changes: 3 additions & 1 deletion scripts/docker/hub/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ ARG TARGET
ENV TARGET ${TARGET}

# install tools and dependencies
RUN apt update && apt install -y --no-install-recommends openssl libudev-dev file
RUN apt update && apt install -y --no-install-recommends openssl libudev-dev file curl jq

# show backtraces
ENV RUST_BACKTRACE 1
Expand All @@ -31,6 +31,8 @@ COPY artifacts/x86_64-unknown-linux-gnu/$TARGET ./bin/$TARGET
RUN echo "#!/bin/bash \n ${TARGET} \$@" > ./entrypoint.sh
RUN chmod +x ./entrypoint.sh

ADD check_sync.sh /check_sync.sh
Copy link
Contributor

Choose a reason for hiding this comment

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

missing a leading dot here ./check_sync.sh

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The script should still be executable and I would prefer to invoke it from /check_sync.sh rather than /home/parity/check_sync.sh

Either works though, the latter is just more cumbersome.


# setup ENTRYPOINT
EXPOSE 5001 8080 8082 8083 8545 8546 8180 30303/tcp 30303/udp
ENTRYPOINT ["./entrypoint.sh"]
13 changes: 13 additions & 0 deletions scripts/docker/hub/check_sync.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
# checks if parity has a fully synced blockchain

ETH_SYNCING=$(curl -X POST --data '{"jsonrpc":"2.0","method":"eth_syncing","params":[],"id":1}' http://localhost:8545 -H 'Content-Type: application/json')
RESULT=$(echo "$ETH_SYNCING" | jq -r .result)

if [ "$RESULT" == "false" ]; then
echo "Parity is ready to start accepting traffic"
exit 0
else
echo "Parity is still syncing the blockchain"
exit 1
fi