Skip to content

Commit

Permalink
update where the docker node backs up keys, fix the node command (#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
dmikey authored Mar 23, 2023
1 parent 3c9216c commit 6ddba9e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
7 changes: 6 additions & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"]
14 changes: 11 additions & 3 deletions docker/run.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
CONFIG_PATH=/app/keys

if [ -n "$KEY_PATH" ]; then
s3_uri_base="s3://${KEY_PATH}"
Expand All @@ -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"
Expand All @@ -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

Expand All @@ -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
Expand All @@ -76,4 +78,10 @@ fi

# run the node
cd /app
./b7s

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

0 comments on commit 6ddba9e

Please sign in to comment.