mirror of
https://github.com/status-im/nim-dagger.git
synced 2025-02-22 03:18:29 +00:00
docker: add BOOTSTRAP_NODE_URL to Docker entrypoint (#1098)
This commit is contained in:
parent
0595723f66
commit
54d499be41
@ -9,6 +9,34 @@ if [[ -n "${ENV_PATH}" ]]; then
|
|||||||
set +a
|
set +a
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Bootstrap node from URL
|
||||||
|
if [[ -n "${BOOTSTRAP_NODE_URL}" ]]; then
|
||||||
|
BOOTSTRAP_NODE_URL="${BOOTSTRAP_NODE_URL}/api/codex/v1/spr"
|
||||||
|
WAIT=${BOOTSTRAP_NODE_URL_WAIT:-300}
|
||||||
|
SECONDS=0
|
||||||
|
SLEEP=1
|
||||||
|
# Run and retry if fail
|
||||||
|
while (( SECONDS < WAIT )); do
|
||||||
|
SPR=$(curl -s -f -m 5 -H 'Accept: text/plain' "${BOOTSTRAP_NODE_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_NODE_URL} - Retry in $SLEEP seconds / $((WAIT - SECONDS))"
|
||||||
|
sleep $SLEEP
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Stop Codex run if unable to get SPR
|
||||||
|
if [[ -n "${BOOTSTRAP_NODE_URL}" && -z "${CODEX_BOOTSTRAP_NODE}" ]]; then
|
||||||
|
echo "Unable to get SPR from ${BOOTSTRAP_NODE_URL} in ${BOOTSTRAP_NODE_URL_WAIT} seconds - Stop Codex run"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
# Parameters
|
# Parameters
|
||||||
if [[ -z "${CODEX_NAT}" ]]; then
|
if [[ -z "${CODEX_NAT}" ]]; then
|
||||||
if [[ "${NAT_IP_AUTO}" == "true" && -z "${NAT_PUBLIC_IP_AUTO}" ]]; then
|
if [[ "${NAT_IP_AUTO}" == "true" && -z "${NAT_PUBLIC_IP_AUTO}" ]]; then
|
||||||
|
Loading…
x
Reference in New Issue
Block a user