Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(docker images): add chainflip-node probe scripts 🩺 #5033

Merged
merged 10 commits into from
Jul 17, 2024
2 changes: 1 addition & 1 deletion ci/docker/development/chainflip-broker-api.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ WORKDIR /etc/chainflip
RUN chmod +x /usr/local/bin/chainflip-broker-api

RUN apt-get update \
&& apt-get install -y ca-certificates --no-install-recommends \
&& apt-get install -y ca-certificates curl jq --no-install-recommends \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

Expand Down
2 changes: 1 addition & 1 deletion ci/docker/development/chainflip-cli.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ WORKDIR /etc/chainflip
RUN chmod +x /usr/local/bin/chainflip-cli

RUN apt-get update \
&& apt-get install -y ca-certificates --no-install-recommends \
&& apt-get install -y ca-certificates curl jq --no-install-recommends \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

Expand Down
2 changes: 1 addition & 1 deletion ci/docker/development/chainflip-engine.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ WORKDIR /etc/chainflip
RUN chmod +x /usr/local/bin/chainflip-engine

RUN apt-get update \
&& apt-get install -y ca-certificates --no-install-recommends \
&& apt-get install -y ca-certificates curl jq --no-install-recommends \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ WORKDIR /etc/chainflip
RUN chmod +x /usr/local/bin/chainflip-ingress-egress-tracker

RUN apt-get update \
&& apt-get install -y ca-certificates --no-install-recommends \
&& apt-get install -y ca-certificates curl jq --no-install-recommends \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

Expand Down
2 changes: 1 addition & 1 deletion ci/docker/development/chainflip-lp-api.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ WORKDIR /etc/chainflip
RUN chmod +x /usr/local/bin/chainflip-lp-api

RUN apt-get update \
&& apt-get install -y ca-certificates --no-install-recommends \
&& apt-get install -y ca-certificates curl jq --no-install-recommends \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

Expand Down
6 changes: 5 additions & 1 deletion ci/docker/development/chainflip-node.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,12 @@ WORKDIR /etc/chainflip

RUN chmod +x /usr/local/bin/chainflip-node

COPY ./ci/docker/scripts/chainflip-node /usr/local/bin
RUN chmod +x /usr/local/bin/liveness.sh \
&& chmod +x /usr/local/bin/readiness.sh

RUN apt-get update \
&& apt-get install -y ca-certificates --no-install-recommends \
&& apt-get install -y ca-certificates curl jq --no-install-recommends \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

Expand Down
2 changes: 1 addition & 1 deletion ci/docker/development/generate-genesis-keys.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ WORKDIR /etc/chainflip
RUN chmod +x /usr/local/bin/generate-genesis-keys

RUN apt-get update \
&& apt-get install -y ca-certificates --no-install-recommends \
&& apt-get install -y ca-certificates curl jq --no-install-recommends \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

Expand Down
2 changes: 1 addition & 1 deletion ci/docker/production/chainflip-broker-api.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ RUN chmod +x /usr/local/bin/chainflip-broker-api \
&& chown -R 1000:1000 /etc/chainflip

RUN apt-get update \
&& apt-get install -y ca-certificates --no-install-recommends \
&& apt-get install -y ca-certificates curl jq --no-install-recommends \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

Expand Down
2 changes: 1 addition & 1 deletion ci/docker/production/chainflip-cli.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ RUN chmod +x /usr/local/bin/chainflip-cli \
&& chown -R 1000:1000 /etc/chainflip

RUN apt-get update \
&& apt-get install -y ca-certificates --no-install-recommends \
&& apt-get install -y ca-certificates curl jq --no-install-recommends \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

Expand Down
2 changes: 1 addition & 1 deletion ci/docker/production/chainflip-engine.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ RUN chmod +x /usr/local/bin/chainflip-engine \
&& chown -R 1000:1000 /etc/chainflip

RUN apt-get update \
&& apt-get install -y ca-certificates --no-install-recommends \
&& apt-get install -y ca-certificates curl jq --no-install-recommends \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ WORKDIR /etc/chainflip
RUN chmod +x /usr/local/bin/chainflip-ingress-egress-tracker

RUN apt-get update \
&& apt-get install -y ca-certificates --no-install-recommends \
&& apt-get install -y ca-certificates curl jq --no-install-recommends \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

Expand Down
2 changes: 1 addition & 1 deletion ci/docker/production/chainflip-lp-api.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ RUN chmod +x /usr/local/bin/chainflip-lp-api \
&& chown -R 1000:1000 /etc/chainflip

RUN apt-get update \
&& apt-get install -y ca-certificates --no-install-recommends \
&& apt-get install -y ca-certificates curl jq --no-install-recommends \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

Expand Down
6 changes: 5 additions & 1 deletion ci/docker/production/chainflip-node.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,16 @@ COPY --chown=1000:1000 ./state-chain/node/chainspecs/berghain.chainspec.raw.json

WORKDIR /etc/chainflip

COPY --chown=1000:1000 ./ci/docker/scripts/chainflip-node /usr/local/bin
RUN chmod +x /usr/local/bin/liveness.sh \
&& chmod +x /usr/local/bin/readiness.sh

RUN chmod +x /usr/local/bin/chainflip-node \
&& useradd -m -u 1000 -U -s /bin/sh -d /flip flip \
&& chown -R 1000:1000 /etc/chainflip

RUN apt-get update \
&& apt-get install -y ca-certificates --no-install-recommends \
&& apt-get install -y ca-certificates curl jq --no-install-recommends \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

Expand Down
14 changes: 14 additions & 0 deletions ci/docker/scripts/chainflip-node/liveness.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

# RPC endpoint
ENDPOINT="http://localhost:9944"

# Check if RPC server is up by sending a simple request
RESPONSE=$(curl --max-time 30 -s -o /dev/null -w "%{http_code}" $ENDPOINT/health)

# If the server responds with a 200 status code, it is live
if [ "$RESPONSE" -eq 200 ]; then
exit 0
else
exit 1
fi
17 changes: 17 additions & 0 deletions ci/docker/scripts/chainflip-node/readiness.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

# RPC endpoint
ENDPOINT="http://localhost:9944"

# Check node health using the system_health RPC method
HEALTH=$(curl -s -X POST --max-time 30 --header "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"system_health","params":[],"id":1}' $ENDPOINT)

# Parse isSyncing status using jq (make sure jq is installed in the image)
IS_SYNCING=$(echo $HEALTH | jq -r '.result.isSyncing')

# If isSyncing is false, the node is fully synced and ready
if [ "$IS_SYNCING" = "false" ]; then
exit 0
else
exit 1
fi
Loading