From 32ee7feea833bf0aa482f69878a49adb629ad444 Mon Sep 17 00:00:00 2001 From: Alex Grintsvayg Date: Mon, 16 Sep 2019 09:51:22 -0400 Subject: [PATCH] download wallet snapshot on first run --- lbry/scripts/Dockerfile.wallet_server | 5 +++-- lbry/scripts/wallet_server_entrypoint.sh | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) create mode 100755 lbry/scripts/wallet_server_entrypoint.sh diff --git a/lbry/scripts/Dockerfile.wallet_server b/lbry/scripts/Dockerfile.wallet_server index 6178ded9b..80c29be52 100644 --- a/lbry/scripts/Dockerfile.wallet_server +++ b/lbry/scripts/Dockerfile.wallet_server @@ -8,7 +8,7 @@ RUN mkdir -p /home/$user/ RUN chown -R $user:$user /home/$user/ # install python, pip, git and clean up -RUN apt-get update && apt-get -y --no-install-recommends install build-essential git python3.7 python3.7-dev python3-pip && rm -rf /var/lib/apt/lists/* +RUN apt-get update && apt-get -y --no-install-recommends install build-essential git tar wget python3.7 python3.7-dev python3-pip && rm -rf /var/lib/apt/lists/* # create and chown database dir ARG db_dir=/database @@ -53,4 +53,5 @@ ENV BANDWIDTH_LIMIT=1000000000000000000000000000000000000000000 ENV MAX_SESSIONS=1000000000 ENV MAX_SEND=1000000000000000000 ENV EVENT_LOOP_POLICY=uvloop -ENTRYPOINT ["/home/lbry/.local/bin/torba-server"] +COPY ./lbry/scripts/wallet_server_entrypoint.sh /entrypoint.sh +ENTRYPOINT ["/entrypoint.sh"] diff --git a/lbry/scripts/wallet_server_entrypoint.sh b/lbry/scripts/wallet_server_entrypoint.sh new file mode 100755 index 000000000..ead599a61 --- /dev/null +++ b/lbry/scripts/wallet_server_entrypoint.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +# entrypoint for wallet server Docker image + +SNAPSHOT_URL="${SNAPSHOT_URL:-}" #off by default. latest snapshot at https://lbry.com/snapshot/wallet + +if [[ -n "$SNAPSHOT_URL" ]] && [[ ! -f /database/claims.db ]]; then + echo "Downloading wallet snapshot from $SNAPSHOT_URL" + wget -O wallet_snapshot.tar.bz2 "$SNAPSHOT_URL" + echo "Extracting snapshot..." + tar xvjf wallet_snapshot.tar.bz2 --directory /database + rm wallet_snapshot.tar.bz2 +fi + +/home/lbry/.local/bin/torba-server "$@"