Revert initial changes and use simpler approach
This commit is contained in:
parent
8864b2659b
commit
d703835d29
@ -1,7 +0,0 @@
|
||||
FROM alloranetwork/allora-offchain-node:latest
|
||||
|
||||
COPY ./config.json /app/config.json
|
||||
|
||||
ENV ALLORA_OFFCHAIN_NODE_CONFIG_FILE_PATH=/app/config.json
|
||||
|
||||
CMD ["./allora_offchain_node"]
|
@ -1,9 +1,7 @@
|
||||
services:
|
||||
inference:
|
||||
container_name: inference-basic-eth-pred
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile_inference
|
||||
build: .
|
||||
command: python -u /app/app.py
|
||||
ports:
|
||||
- "8000:8000"
|
||||
@ -17,9 +15,7 @@ services:
|
||||
|
||||
updater:
|
||||
container_name: updater-basic-eth-pred
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile_inference
|
||||
build: .
|
||||
environment:
|
||||
- INFERENCE_API_ADDRESS=http://inference:8000
|
||||
command: >
|
||||
@ -36,14 +32,13 @@ services:
|
||||
worker:
|
||||
container_name: worker
|
||||
image: alloranetwork/allora-offchain-node:latest
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile_worker
|
||||
volumes:
|
||||
- ./worker-data:/data
|
||||
depends_on:
|
||||
inference:
|
||||
condition: service_healthy
|
||||
env_file:
|
||||
- ./worker-data/env_file
|
||||
|
||||
volumes:
|
||||
inference-data:
|
||||
|
43
init.config
Executable file
43
init.config
Executable file
@ -0,0 +1,43 @@
|
||||
#!/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 wallet name provided for the node, please provide your preferred wallet name. config.json >> wallet.addressKeyName"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
json_content=$(cat ./config.json)
|
||||
stringified_json=$(echo "$json_content" | jq -c .)
|
||||
|
||||
mnemonic=$(jq -r '.wallet.addressRestoreMnemonic' config.json)
|
||||
if [ -n "$mnemonic" ]; then
|
||||
echo "ALLORA_OFFCHAIN_NODE_CONFIG_JSON='$stringified_json'" > ./worker-data/env_file
|
||||
echo "NAME=$nodeName" >> ./worker-data/env_file
|
||||
echo "ENV_LOADED=true" >> ./worker-data/env_file
|
||||
|
||||
echo "wallet mnemonic already provided by you, loading config.json . Please proceed to run docker compose"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -f ./worker-data/env_file ]; then
|
||||
echo "ENV_LOADED=false" > ./worker-data/env_file
|
||||
fi
|
||||
|
||||
ENV_LOADED=$(grep '^ENV_LOADED=' ./worker-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)/worker-data:/data -v $(pwd)/scripts:/scripts -e NAME="${nodeName}" -e ALLORA_OFFCHAIN_NODE_CONFIG_JSON="${stringified_json}" alloranetwork/allora-chain:latest -c "bash /scripts/init.sh"
|
||||
echo "config.json saved to ./worker-data/env_file"
|
||||
else
|
||||
echo "config.json is already loaded, skipping the operation. You can set ENV_LOADED variable to false in ./worker-data/env_file to reload the config.json"
|
||||
fi
|
||||
|
33
scripts/init.sh
Normal file
33
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