Skip to content

Commit

Permalink
docker: add BOOTSTRAP_URL to Docker entrypoint
Browse files Browse the repository at this point in the history
  • Loading branch information
veaceslavdoina committed Feb 4, 2025
1 parent 0595723 commit dfd1020
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions docker/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,34 @@ if [[ -n "${ENV_PATH}" ]]; then
set +a
fi

# Bootstrap node from URL
if [[ -n "${BOOTSTRAP_URL}" ]]; then
BOOTSTRAP_URL="${BOOTSTRAP_URL}/api/codex/v1/spr"
WAIT=${BOOTSTRAP_URL_WAIT:-300}
SECONDS=0
SLEEP=5
# Run and retry if fail
while (( SECONDS < WAIT )); do
SPR=$(curl -s -f -m 5 -H 'Accept: text/plain' "${BOOTSTRAP_URL}")
# Check if exit code is 0 and returned value is not empty
if [[ $? -eq 0 && -n "${SPR}" ]]; then
export CODEX_BOOTSTRAP_NODE="${SPR}"
echo "Bootstrap node: CODEX_BOOTSTRAP_NODE=${CODEX_BOOTSTRAP_NODE}"
break
else
# Sleep and check again
echo "Can't get SPR from ${BOOTSTRAP_URL} - Retry in $SLEEP seconds / $((WAIT - SECONDS))"
sleep $SLEEP
fi
done
fi

# Stop Codex run if unable to get SPR
if [[ -z "${CODEX_BOOTSTRAP_NODE}" ]]; then
echo "Unable to get SPR from ${BOOTSTRAP_URL} in ${BOOTSTRAP_URL_WAIT} seconds - Stop Codex run"
# exit 1
fi

# Parameters
if [[ -z "${CODEX_NAT}" ]]; then
if [[ "${NAT_IP_AUTO}" == "true" && -z "${NAT_PUBLIC_IP_AUTO}" ]]; then
Expand Down

0 comments on commit dfd1020

Please sign in to comment.