Add init scripts
This commit is contained in:
parent
2f97575d52
commit
9db05c7140
13
.gitignore
vendored
13
.gitignore
vendored
@ -2,11 +2,10 @@
|
||||
__pycache__
|
||||
*.pyc
|
||||
logs/*
|
||||
.env
|
||||
inference-data
|
||||
worker-data
|
||||
head-data
|
||||
offchain-node-data
|
||||
|
||||
.env.*
|
||||
!.env.*.example
|
||||
.allorad
|
||||
.cache
|
||||
inference-data
|
||||
|
||||
config.json
|
||||
env
|
||||
|
@ -1,8 +1,7 @@
|
||||
ALLORA_OFFCHAIN_NODE_CONFIG_JSON='{
|
||||
{
|
||||
"wallet": {
|
||||
"addressKeyName": "test",
|
||||
"addressRestoreMnemonic": "",
|
||||
"addressAccountPassphrase": "",
|
||||
"alloraHomeDir": "",
|
||||
"gas": "1000000",
|
||||
"gasAdjustment": 1.0,
|
||||
@ -17,9 +16,9 @@ ALLORA_OFFCHAIN_NODE_CONFIG_JSON='{
|
||||
"inferenceEntrypointName": "api-worker-reputer",
|
||||
"loopSeconds": 5,
|
||||
"parameters": {
|
||||
"InferenceEndpoint": "http://inference:8000/inference/{Token}",
|
||||
"InferenceEndpoint": "http://source:8000/inference/{Token}",
|
||||
"Token": "ETH"
|
||||
}
|
||||
}
|
||||
]
|
||||
}'
|
||||
}
|
@ -6,7 +6,7 @@ services:
|
||||
dockerfile: Dockerfile_inference
|
||||
command: python -u /app/app.py
|
||||
ports:
|
||||
- "8000:8000"
|
||||
- "8002:8000"
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-f", "http://localhost:8000/inference/ETH"]
|
||||
interval: 10s
|
||||
@ -34,7 +34,7 @@ services:
|
||||
condition: service_healthy
|
||||
|
||||
node:
|
||||
container_name: offchain_node_test
|
||||
container_name: offchain_node
|
||||
image: allora-offchain-node:latest
|
||||
volumes:
|
||||
- ./offchain-node-data:/data
|
||||
@ -42,7 +42,7 @@ services:
|
||||
inference:
|
||||
condition: service_healthy
|
||||
env_file:
|
||||
- ./env.offchain-node
|
||||
- ./offchain-node-data/env_file
|
||||
|
||||
networks:
|
||||
eth-model-local:
|
||||
@ -53,4 +53,4 @@ networks:
|
||||
|
||||
volumes:
|
||||
inference-data:
|
||||
worker-data:
|
||||
offchain-node-data:
|
||||
|
29
init.offchain-node
Executable file
29
init.offchain-node
Executable file
@ -0,0 +1,29 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
if [ ! -f config.json ]; then
|
||||
echo "Error: config.json file not found, please provide one"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
nodeName=$(jq -r '.wallet.addressKeyName' config.json)
|
||||
if [ -z "$nodeName" ]; then
|
||||
echo "No name was provided for the node, please provide value for wallet.addressKeyName in the config.json"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -f ./offchain-node-data/env_file ]; then
|
||||
echo "ENV_LOADED=false" > ./offchain-node-data/env_file
|
||||
fi
|
||||
|
||||
ENV_LOADED=$(grep '^ENV_LOADED=' ./offchain-node-data/env_file | cut -d '=' -f 2)
|
||||
if [ "$ENV_LOADED" = "false" ]; then
|
||||
json_content=$(cat ./config.json)
|
||||
stringified_json=$(echo "$json_content" | jq -c .)
|
||||
|
||||
docker run -it --entrypoint=bash -v $(pwd)/offchain-node-data:/data -e NAME="${nodeName}" -e ALLORA_OFFCHAIN_NODE_CONFIG_JSON="${stringified_json}" alloranetwork/allora-chain:latest -c "bash /data/scripts/init.sh"
|
||||
echo "config.json saved to ./offchain-node-data/env_file"
|
||||
else
|
||||
echo "config.json is already loaded, skipping the operation. You can set ENV_LOADED variable to false in ./offchain-node-data/env_file to reload the config.json"
|
||||
fi
|
4
offchain-node-data/env_file
Normal file
4
offchain-node-data/env_file
Normal file
@ -0,0 +1,4 @@
|
||||
ALLORA_OFFCHAIN_NODE_CONFIG_JSON='{"wallet":{"addressKeyName":"basic-coin-prediction-offchain-node","addressRestoreMnemonic":"rich note fetch lava bless snake delay theme era anger ritual sea pluck neck hazard dish talk ranch trophy clap fancy human divide gun","addressAccountPassphrase":"secret","alloraHomeDir":"","gas":"1000000","gasAdjustment":1,"nodeRpc":"https://allora-rpc.devnet.behindthecurtain.xyz","maxRetries":1,"minDelay":1,"maxDelay":2,"submitTx":false},"worker":[{"topicId":1,"inferenceEntrypointName":"api-worker-reputer","loopSeconds":5,"parameters":{"InferenceEndpoint":"http://inference:8000/inference/{Token}","Token":"ETH"}}]}'
|
||||
ALLORA_OFFCHAIN_ACCOUNT_ADDRESS=allo14wkkdeg93mdc0sd770z9p4mpjz7w9mysz328um
|
||||
NAME=basic-coin-prediction-offchain-node
|
||||
ENV_LOADED=true
|
33
offchain-node-data/scripts/init.sh
Normal file
33
offchain-node-data/scripts/init.sh
Normal file
@ -0,0 +1,33 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
if allorad keys --home=/data/.allorad --keyring-backend test show $NAME > /dev/null 2>&1 ; then
|
||||
echo "allora account: $NAME already imported"
|
||||
else
|
||||
echo "creating allora account: $NAME"
|
||||
output=$(allorad keys add $NAME --home=/data/.allorad --keyring-backend test 2>&1)
|
||||
address=$(echo "$output" | grep 'address:' | sed 's/.*address: //')
|
||||
mnemonic=$(echo "$output" | tail -n 1)
|
||||
|
||||
# Parse and update the JSON string
|
||||
updated_json=$(echo "$ALLORA_OFFCHAIN_NODE_CONFIG_JSON" | jq --arg name "$NAME" --arg mnemonic "$mnemonic" '
|
||||
.wallet.addressKeyName = $name |
|
||||
.wallet.addressRestoreMnemonic = $mnemonic
|
||||
')
|
||||
|
||||
stringified_json=$(echo "$updated_json" | jq -c .)
|
||||
|
||||
echo "ALLORA_OFFCHAIN_NODE_CONFIG_JSON='$stringified_json'" > /data/env_file
|
||||
echo ALLORA_OFFCHAIN_ACCOUNT_ADDRESS=$address >> /data/env_file
|
||||
echo "NAME=$NAME" >> /data/env_file
|
||||
|
||||
echo "Updated ALLORA_OFFCHAIN_NODE_CONFIG_JSON saved to /data/env_file"
|
||||
fi
|
||||
|
||||
|
||||
if grep -q "ENV_LOADED=false" /data/env_file; then
|
||||
sed -i 's/ENV_LOADED=false/ENV_LOADED=true/' /data/env_file
|
||||
else
|
||||
echo "ENV_LOADED=true" >> /data/env_file
|
||||
fi
|
Loading…
Reference in New Issue
Block a user