From 8864b2659b7c64b89dc978c5992916decfc3fc76 Mon Sep 17 00:00:00 2001 From: conache Date: Fri, 9 Aug 2024 22:47:52 +0300 Subject: [PATCH] Remove utility scripts and add worker-data to .gitignore --- .gitignore | 1 + Dockerfile => Dockerfile_inference | 0 Dockerfile_worker | 7 +++++ docker-compose.yml | 13 ++++++--- init.config | 42 ------------------------------ worker-data/env_file | 3 --- worker-data/scripts/init.sh | 33 ----------------------- 7 files changed, 17 insertions(+), 82 deletions(-) rename Dockerfile => Dockerfile_inference (100%) create mode 100644 Dockerfile_worker delete mode 100755 init.config delete mode 100644 worker-data/env_file delete mode 100644 worker-data/scripts/init.sh diff --git a/.gitignore b/.gitignore index 97056b3..f8947f5 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ logs/* .allorad .cache inference-data +worker-data config.json env diff --git a/Dockerfile b/Dockerfile_inference similarity index 100% rename from Dockerfile rename to Dockerfile_inference diff --git a/Dockerfile_worker b/Dockerfile_worker new file mode 100644 index 0000000..119a53d --- /dev/null +++ b/Dockerfile_worker @@ -0,0 +1,7 @@ +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"] \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 5d856e3..a8c959b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,7 +1,9 @@ services: inference: container_name: inference-basic-eth-pred - build: . + build: + context: . + dockerfile: Dockerfile_inference command: python -u /app/app.py ports: - "8000:8000" @@ -15,7 +17,9 @@ services: updater: container_name: updater-basic-eth-pred - build: . + build: + context: . + dockerfile: Dockerfile_inference environment: - INFERENCE_API_ADDRESS=http://inference:8000 command: > @@ -32,13 +36,14 @@ 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: diff --git a/init.config b/init.config deleted file mode 100755 index 2057f07..0000000 --- a/init.config +++ /dev/null @@ -1,42 +0,0 @@ -#!/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 -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 ./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 \ No newline at end of file diff --git a/worker-data/env_file b/worker-data/env_file deleted file mode 100644 index c5ab53a..0000000 --- a/worker-data/env_file +++ /dev/null @@ -1,3 +0,0 @@ -ALLORA_OFFCHAIN_NODE_CONFIG_JSON='{"wallet":{"addressKeyName":"test-basic","addressRestoreMnemonic":"your mnemonic will go here","alloraHomeDir":"","gas":"1000000","gasAdjustment":1,"nodeRpc":"https://allora-rpc.devnet.behindthecurtain.xyz","maxRetries":1,"delay":1,"submitTx":false},"worker":[{"topicId":1,"inferenceEntrypointName":"api-worker-reputer","loopSeconds":5,"parameters":{"InferenceEndpoint":"http://inference:8000/inference/{Token}","Token":"ETH"}}]}' -NAME=test-basic -ENV_LOADED=true diff --git a/worker-data/scripts/init.sh b/worker-data/scripts/init.sh deleted file mode 100644 index 0e6af84..0000000 --- a/worker-data/scripts/init.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/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