From 6ddba9e5606496ba1d5a7d1f054cc546fb4ec92d Mon Sep 17 00:00:00 2001 From: Derek Anderson Date: Thu, 23 Mar 2023 16:51:16 -0500 Subject: [PATCH] update where the docker node backs up keys, fix the node command (#57) --- docker/Dockerfile | 7 ++++++- docker/run.sh | 14 +++++++++++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 45e86688..947d15e0 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -27,6 +27,7 @@ RUN curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2 && /usr/src/aws/install --bin-dir /usr/bin ## setup +RUN mkdir /app/keys COPY ./dist/b7s b7s COPY ./dist/b7s-keygen b7s-keygen COPY ./configs/docker-config.yaml docker-config.yaml @@ -35,13 +36,17 @@ COPY ./configs/docker-config.yaml docker-config.yaml COPY ./docker/run.sh ./run.sh RUN chmod +x ./run.sh -ENV CONFIG_PATH="/app/keys" ENV AWS_ACCESS_KEY_ID= ENV AWS_SECRET_ACCESS_KEY= ENV S3_HOST="${S3_HOST:-https://s3.filebase.com}" ENV KEY_PATH="" ENV KEY_PASSWORD="" ENV CHAIN_RPC_NODE="http://0.0.0.0:26657" +ENV NODE_KEY_PATH=/app/keys/priv.bin +ENV WORKSPACE_ROOT=/tmp/node +ENV RUNETIME_PATH=/app/runtime +ENV REST_API=8080 +ENV P2P_PORT=9527 ## run script ENTRYPOINT ["/app/run.sh"] diff --git a/docker/run.sh b/docker/run.sh index 707977a5..a355a3fa 100644 --- a/docker/run.sh +++ b/docker/run.sh @@ -1,4 +1,5 @@ #!/bin/bash +CONFIG_PATH=/app/keys if [ -n "$KEY_PATH" ]; then s3_uri_base="s3://${KEY_PATH}" @@ -15,7 +16,7 @@ restore_key () { if [[ -z $existing ]]; then echo "$1 backup not found" else - echo "Restoring $1" + echo "Restoring $1 to $CONFIG_PATH" aws $aws_args s3 cp "${s3_uri_base}/$1" $CONFIG_PATH/$1$file_suffix if [ -n "$KEY_PASSWORD" ]; then echo "Decrypting" @@ -41,6 +42,7 @@ backup_key () { # Restore keys if [ -n "$KEY_PATH" ]; then for f in $(aws $aws_args s3 ls "${s3_uri_base}/" | awk '{print $4}'); do + cd /app/keys restore_key "$f" done @@ -56,7 +58,7 @@ if [ -f "$CONFIG_PATH/identity" ]; then else echo "Generating New Node Identity" blsd keys add node --keyring-backend=test --home=/app/.blockless-chain > /dev/null 2>&1 - mkdir keys && cd keys + cd /app/keys if [ -n "$KEY_PASSWORD" ]; then echo $KEY_PASSWORD | blsd keys export node --keyring-backend=test --home=/app/.blockless-chain > /app/keys/wallet.key fi @@ -76,4 +78,10 @@ fi # run the node cd /app -./b7s \ No newline at end of file + +if [ "$NODE_ROLE" = "head" ]; then + ./b7s --db /var/tmp/b7s/db --log-level debug --port $P2P_PORT --role head --workspace $WORKSPACE_ROOT --private-key $NODE_KEY_PATH --rest-api :$REST_API + +else + ./b7s --db ./database --log-level debug --port $P2P_PORT --role worker --runtime /app/runtime --workspace $WORKSPACE_ROOT --private-key $NODE_KEY_PATH +fi