diff --git a/base-consensus-entrypoint b/base-consensus-entrypoint index cd2801fce..fe7c176ee 100755 --- a/base-consensus-entrypoint +++ b/base-consensus-entrypoint @@ -1,26 +1,8 @@ #!/bin/bash set -eu -get_public_ip() { - # Define a list of HTTP-based providers - local PROVIDERS=( - "http://ifconfig.me" - "http://api.ipify.org" - "http://ipecho.net/plain" - "http://v4.ident.me" - ) - # Iterate through the providers until an IP is found or the list is exhausted - for provider in "${PROVIDERS[@]}"; do - local IP - IP=$(curl -s --max-time 10 --connect-timeout 5 "$provider") - # Check if IP contains a valid format (simple regex for an IPv4 address) - if [[ $IP =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then - echo "$IP" - return 0 - fi - done - return 1 -} +# shellcheck source=helpers.sh +source "$(dirname "$0")/helpers.sh" if [[ -z "${BASE_NODE_NETWORK:-}" ]]; then echo "expected BASE_NODE_NETWORK to be set" 1>&2 diff --git a/geth/Dockerfile b/geth/Dockerfile index c32881405..bdf6821a4 100644 --- a/geth/Dockerfile +++ b/geth/Dockerfile @@ -29,7 +29,7 @@ FROM ubuntu:24.04 RUN apt-get update && \ apt-get install -y jq curl supervisor && \ - rm -rf /var/lib/apt/lists + rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/log/supervisor WORKDIR /app @@ -38,6 +38,7 @@ COPY --from=op /app/op-node/bin/op-node ./ COPY --from=geth /app/build/bin/geth ./ COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf COPY geth/geth-entrypoint ./execution-entrypoint +COPY helpers.sh . COPY op-node-entrypoint . COPY consensus-entrypoint . diff --git a/helpers.sh b/helpers.sh new file mode 100644 index 000000000..63298afbf --- /dev/null +++ b/helpers.sh @@ -0,0 +1,23 @@ +#!/bin/bash +# Shared helper functions for consensus entrypoints + +get_public_ip() { + # Define a list of HTTP-based providers + local PROVIDERS=( + "http://ifconfig.me" + "http://api.ipify.org" + "http://ipecho.net/plain" + "http://v4.ident.me" + ) + # Iterate through the providers until an IP is found or the list is exhausted + for provider in "${PROVIDERS[@]}"; do + local IP + IP=$(curl -s --max-time 10 --connect-timeout 5 "$provider") + # Check if IP contains a valid format (simple regex for an IPv4 address) + if [[ $IP =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo "$IP" + return 0 + fi + done + return 1 +} diff --git a/nethermind/Dockerfile b/nethermind/Dockerfile index 4c2df2a0e..bc48bc62c 100644 --- a/nethermind/Dockerfile +++ b/nethermind/Dockerfile @@ -45,6 +45,7 @@ COPY --from=build /publish ./ COPY --from=op /app/op-node/bin/op-node ./ COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf COPY nethermind/nethermind-entrypoint ./execution-entrypoint +COPY helpers.sh . COPY op-node-entrypoint . COPY consensus-entrypoint . diff --git a/op-node-entrypoint b/op-node-entrypoint index 893015882..6c137b128 100755 --- a/op-node-entrypoint +++ b/op-node-entrypoint @@ -1,26 +1,8 @@ #!/bin/bash set -eu -get_public_ip() { - # Define a list of HTTP-based providers - local PROVIDERS=( - "http://ifconfig.me" - "http://api.ipify.org" - "http://ipecho.net/plain" - "http://v4.ident.me" - ) - # Iterate through the providers until an IP is found or the list is exhausted - for provider in "${PROVIDERS[@]}"; do - local IP - IP=$(curl -s --max-time 10 --connect-timeout 5 "$provider") - # Check if IP contains a valid format (simple regex for an IPv4 address) - if [[ $IP =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then - echo "$IP" - return 0 - fi - done - return 1 -} +# shellcheck source=helpers.sh +source "$(dirname "$0")/helpers.sh" if [[ -z "$OP_NODE_NETWORK" && -z "$OP_NODE_ROLLUP_CONFIG" ]]; then echo "expected OP_NODE_NETWORK to be set" 1>&2 diff --git a/reth/Dockerfile b/reth/Dockerfile index 2c9eec55f..2b3366988 100644 --- a/reth/Dockerfile +++ b/reth/Dockerfile @@ -68,6 +68,7 @@ COPY --from=reth-base /app/target/maxperf/base-consensus ./ COPY --from=reth-base /app/target/maxperf/base-reth-node ./ COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf COPY ./reth/reth-entrypoint ./execution-entrypoint +COPY helpers.sh . COPY op-node-entrypoint . COPY base-consensus-entrypoint . COPY consensus-entrypoint .