From 97f5fcfd1363be40753ce7517d3caae302182c38 Mon Sep 17 00:00:00 2001 From: Leopere Date: Tue, 6 Nov 2018 15:11:20 -0500 Subject: [PATCH 01/26] adding update-bootstrap --- chainquery/quick-bootstrap.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/chainquery/quick-bootstrap.sh b/chainquery/quick-bootstrap.sh index 8c235cf..91a038a 100755 --- a/chainquery/quick-bootstrap.sh +++ b/chainquery/quick-bootstrap.sh @@ -63,6 +63,14 @@ case $1 in # rm -Rf ./data # rm -f ./chainquery.zip ;; + update-bootstrap ) + ## This is a function just to ensure that we keep checkpoint data up to date. + docker-compose stop chainquery + docker-compose stop mysql + zip -r chainquery-data.zip data + aws s3 cp ./chainquery-data.zip s3://chainquery-data/chainquery-data.new + aws s3 rm s3://chainquery-data/chainquery-data.zip + aws s3 mv s3://chainquery-data/chainquery-data.new s3://chainquery-data/chainquery-data.zip * ) echo "==================================================" echo "You look like you need usage examples let me help." From 5279bc2b4d0176ac8617b968508bc5b853b565ff Mon Sep 17 00:00:00 2001 From: Leopere Date: Tue, 6 Nov 2018 15:13:56 -0500 Subject: [PATCH 02/26] naming consistency --- chainquery/quick-bootstrap.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chainquery/quick-bootstrap.sh b/chainquery/quick-bootstrap.sh index 91a038a..ea70b8f 100755 --- a/chainquery/quick-bootstrap.sh +++ b/chainquery/quick-bootstrap.sh @@ -48,7 +48,7 @@ done case $1 in getdata ) ## Get DB Checkpoint data. - axel -a -n 6 http://chainquery-data.s3.amazonaws.com/data.zip -o ./chainquery.zip + axel -a -n 6 http://chainquery-data.s3.amazonaws.com/chainquery-data.zip -o ./chainquery.zip ;; extract ) ## Unpack the data again if need be. From bf4d5c7d84754f5871662a5f91952a5bb14354bc Mon Sep 17 00:00:00 2001 From: Leopere Date: Tue, 6 Nov 2018 15:19:50 -0500 Subject: [PATCH 03/26] closed case --- chainquery/quick-bootstrap.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/chainquery/quick-bootstrap.sh b/chainquery/quick-bootstrap.sh index ea70b8f..85554d0 100755 --- a/chainquery/quick-bootstrap.sh +++ b/chainquery/quick-bootstrap.sh @@ -63,7 +63,7 @@ case $1 in # rm -Rf ./data # rm -f ./chainquery.zip ;; - update-bootstrap ) + upload-latest-checkpoint-data ) ## This is a function just to ensure that we keep checkpoint data up to date. docker-compose stop chainquery docker-compose stop mysql @@ -71,6 +71,7 @@ case $1 in aws s3 cp ./chainquery-data.zip s3://chainquery-data/chainquery-data.new aws s3 rm s3://chainquery-data/chainquery-data.zip aws s3 mv s3://chainquery-data/chainquery-data.new s3://chainquery-data/chainquery-data.zip + ;; * ) echo "==================================================" echo "You look like you need usage examples let me help." From ac7802f158e639977f95daec0f049fecca0fd4ec Mon Sep 17 00:00:00 2001 From: Leopere Date: Tue, 6 Nov 2018 15:32:38 -0500 Subject: [PATCH 04/26] Adding second checkpoint function --- chainquery/quick-bootstrap.sh | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/chainquery/quick-bootstrap.sh b/chainquery/quick-bootstrap.sh index 85554d0..d0f8c6c 100755 --- a/chainquery/quick-bootstrap.sh +++ b/chainquery/quick-bootstrap.sh @@ -63,11 +63,17 @@ case $1 in # rm -Rf ./data # rm -f ./chainquery.zip ;; - upload-latest-checkpoint-data ) - ## This is a function just to ensure that we keep checkpoint data up to date. + compress-latest-checkpoint-data ) + ## This is not intended for public use. docker-compose stop chainquery docker-compose stop mysql - zip -r chainquery-data.zip data + sudo zip -r chainquery-data.zip data + docker-compose up -d mysql + sleep 30 + docker-compose up -d chainquery + ;; + upload-latest-checkpoint-data ) + ## This is not intended for public use. aws s3 cp ./chainquery-data.zip s3://chainquery-data/chainquery-data.new aws s3 rm s3://chainquery-data/chainquery-data.zip aws s3 mv s3://chainquery-data/chainquery-data.new s3://chainquery-data/chainquery-data.zip From 2295a9df066abb12c258c5018d1a2cb6772cb97b Mon Sep 17 00:00:00 2001 From: Leopere Date: Tue, 6 Nov 2018 16:00:34 -0500 Subject: [PATCH 05/26] Add documentation for quick-bootstrap.sh --- chainquery/quick-bootstrap.sh | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/chainquery/quick-bootstrap.sh b/chainquery/quick-bootstrap.sh index d0f8c6c..4a7a021 100755 --- a/chainquery/quick-bootstrap.sh +++ b/chainquery/quick-bootstrap.sh @@ -82,6 +82,23 @@ case $1 in echo "==================================================" echo "You look like you need usage examples let me help." echo "==================================================" - echo "Add documentation on script params HERE" + echo "./quick-boostrap.sh {Parameter}" + echo "Example: ./quick-bootstrap.sh getdata # Downloads the latest Chainquery checkpoint data from a LBRYio official aws instance." + echo "" + echo "" + echo "==================================================" + echo "Usage example and available parameters" + echo "==================================================" + echo "" + echo "getdata # This function grabs the latest Chainquery checkpoint data." + echo "extract # Unpacks the chainquery data into the correct directory. ./data/" + echo "cleanup # Removes chainquery.zip" + echo "reset # Reset the state of these containers entirely, use if all else fails." + echo "" + echo "" + echo "==================================================" + echo "==================================================" + echo "Any other functions that are not documented here are not intended for public use." + echo " These functions are included in this repository to keep things in one place." ;; esac From 27066dceca8f395ec6d4d33aec3103c85d54950f Mon Sep 17 00:00:00 2001 From: Leopere Date: Tue, 6 Nov 2018 16:23:12 -0500 Subject: [PATCH 06/26] Document everything in chainquery Dockerfile --- chainquery/Dockerfile | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/chainquery/Dockerfile b/chainquery/Dockerfile index 1c4c76e..adb37c6 100644 --- a/chainquery/Dockerfile +++ b/chainquery/Dockerfile @@ -2,37 +2,51 @@ FROM ubuntu:18.04 as prep LABEL MAINTAINER="leopere [at] nixc [dot] us" +## Install everything needed to unzip the file containing Chainquery RUN apt-get update && \ apt-get -y install unzip curl && \ apt-get autoclean -y && \ rm -rf /var/lib/apt/lists/* && \ mkdir /download +## Download and extract the latest Zip containing Linux binary for Chainquery. RUN curl -L -o /download/chainquery.zip $(curl -s https://api.github.com/repos/lbryio/chainquery/releases | fgrep 'Linux_x86_64.zip' | grep download | head -n 1 | cut -d'"' -f4) && \ cd /download && \ ls -lAh /download && pwd && \ unzip chainquery.zip && \ rm chainquery.zip -## I really want to use this instead of all the curl stuff at one point. + +## TODO: Use this instead of everything above here at some point. To do this we will need the LBRY team to host all of their release binaries in their latest form internally I guess since github doesn't support latest tags. # ADD --chown=1000:1000 https://github.com/lbryio/chainquery/releases/download/latest/chainquery_latest_Linux_x86_64.zip /download -## Switch to Alpine eventually we might need to compile in Alpine for this. +# TODO: Switch to Alpine eventually we might need to compile in Alpine for this. FROM ubuntu:18.04 as app +## Run as unprivileged user. RUN adduser chainquery --gecos GECOS --shell /bin/bash --disabled-password --home /home/chainquery +# Pull chainquery executable from prep container. COPY --from=0 /download/chainquery /usr/bin # ADD --chown=1000:1000 https://github.com/lbryio/chainquery/releases/download/latest/chainquery_latest_Linux_x86_64.zip /usr/bin COPY chainqueryconfig.toml /etc/chainquery/ -ADD --chown=1000:1000 https://raw.githubusercontent.com/lbryio/chainquery/master/config/default/chainqueryconfig.toml /etc/chainquery/chainqueryconfig.toml.orig -COPY start.sh /usr/local/bin/start -COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint +## Get latest chainqueryconfig.toml from master on github as template. +# TODO: add magic which pattern matches for chainqueryconfig.toml DEFAULT strings and replaces them with configured settings on container start. +ADD --chown=1000:1000 https://raw.githubusercontent.com/lbryio/chainquery/master/config/default/chainqueryconfig.toml /etc/chainquery/chainqueryconfig.toml.orig + +## Install start.sh as executable script in container $PATH +COPY start.sh /usr/local/bin/start + +# TODO: Implement docker-entrypoint if later required this might be handy if we need certain maintainence tasks to be executed in the live container. +# COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint + +## From here onward we're doing this with no root. USER chainquery ## Expose Chainquery API port EXPOSE 6300 +## Execute start script earlier installed into $PATH CMD ["start"] From 6df6beef34a9bd5cc9a1cf87b138793d73802e23 Mon Sep 17 00:00:00 2001 From: Leopere Date: Tue, 6 Nov 2018 16:26:26 -0500 Subject: [PATCH 07/26] Document everything in quick-bootstrap.sh --- chainquery/quick-bootstrap.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/chainquery/quick-bootstrap.sh b/chainquery/quick-bootstrap.sh index 4a7a021..2e30166 100755 --- a/chainquery/quick-bootstrap.sh +++ b/chainquery/quick-bootstrap.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -## Be Polite and ask for permission. +## TODO: Be Polite and ask for confirmation. function QandA() { read -r -p "Continue with $1 [y/N] " response response=${response,,} # tolower @@ -14,6 +14,7 @@ function QandA() { ## Check your $PATH for required dependencies. ## Stop and complain for now, later automagically install them. +## TODO: Add dependency checker. function test_for_deps() { ## Test for Command if ! [ -x "$(command -v $1)" ]; then From 9e5b5fd7d38cac7afec2c29a9f10e2ad226d3579 Mon Sep 17 00:00:00 2001 From: Leopere Date: Tue, 6 Nov 2018 16:26:54 -0500 Subject: [PATCH 08/26] Comment everything and added TODO tags --- chainquery/start.sh | 47 ++++++++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/chainquery/start.sh b/chainquery/start.sh index 271f4eb..63bbb80 100755 --- a/chainquery/start.sh +++ b/chainquery/start.sh @@ -1,28 +1,31 @@ #!/usr/bin/env bash -######################### -## Chainquery Settings ## -######################### -RPC_USER=lbryrpc ## Not super necessery to change this. -RPC_PASSWORD=changeme ## Please replace changeme. -RPC_ALLOW_IP=10.5.1.3 ## You're better off not changing this. +# TODO: Remove this notes section. +## Keeping this here as notes for later sed magic. +# ######################### +# ## Chainquery Settings ## +# ######################### +# RPC_USER=lbryrpc ## Not super necessery to change this. +# RPC_PASSWORD=changeme ## Please replace changeme. +# RPC_ALLOW_IP=10.5.1.3 ## You're better off not changing this. +# +# ################# +# ## Mysql Creds ## +# ################# +# MYSQL_SERVER=10.5.1.10 ## You're better off not changing this. +# MYSQL_USER=changeme ## This could be changed. +# MYSQL_PASSWORD=changeme ## This could be set to something random it sets this string for both Mysql's main user and Chainquery's MysqlDSN. +# MYSQL_DATABASE=chainquery ## This can stay the same. +# MYSQL_ROOT_PASSWORD=changeme ## Set this to something random and obnoxious we're not using it. -################# -## Mysql Creds ## -################# -MYSQL_SERVER=10.5.1.10 ## You're better off not changing this. -MYSQL_USER=changeme ## This could be changed. -MYSQL_PASSWORD=changeme ## This could be set to something random it sets this string for both Mysql's main user and Chainquery's MysqlDSN. -MYSQL_DATABASE=chainquery ## This can stay the same. -MYSQL_ROOT_PASSWORD=changeme ## Set this to something random and obnoxious we're not using it. - -sed -i '' - - -debugmode=${DEBUGMODE:-false} -lbrycrdurl="rpc://${RPC_USER:-lbryrpc}:${RPC_PASSWORD:-changeme}@10.5.1.2:9245" -mysqldsn="${MYSQL_USER:-changeme}:${MYSQL_PASSWORD:-changeme}@tcp(${MYSQL_SERVER:-10.5.1.10}:3306)/${MYSQL_DATABASE:-chainquery}" -apimysqldsn="${MYSQL_USER:-changeme}:${MYSQL_PASSWORD:-changeme}@tcp(${MYSQL_SERVER:-10.5.1.10}:3306)/${MYSQL_DATABASE:-chainquery}" +# TODO: Add chainquery startup magic for configuration. +# sed -i '' +# +# +# debugmode=${DEBUGMODE:-false} +# lbrycrdurl="rpc://${RPC_USER:-lbryrpc}:${RPC_PASSWORD:-changeme}@10.5.1.2:9245" +# mysqldsn="${MYSQL_USER:-changeme}:${MYSQL_PASSWORD:-changeme}@tcp(${MYSQL_SERVER:-10.5.1.10}:3306)/${MYSQL_DATABASE:-chainquery}" +# apimysqldsn="${MYSQL_USER:-changeme}:${MYSQL_PASSWORD:-changeme}@tcp(${MYSQL_SERVER:-10.5.1.10}:3306)/${MYSQL_DATABASE:-chainquery}" ## For now keeping this simple. Potentially eventually add all command args as envvars for the Dockerfile or use safe way to add args via docker-compose.yml chainquery serve -c "/etc/chainquery/" From e2627b008ffcd9eb3f5256ed06ed384fb81ef040 Mon Sep 17 00:00:00 2001 From: Leopere Date: Tue, 6 Nov 2018 17:01:07 -0500 Subject: [PATCH 09/26] Adding some more commands, start and completed reset --- chainquery/quick-bootstrap.sh | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/chainquery/quick-bootstrap.sh b/chainquery/quick-bootstrap.sh index 2e30166..b2797e0 100755 --- a/chainquery/quick-bootstrap.sh +++ b/chainquery/quick-bootstrap.sh @@ -25,6 +25,7 @@ function test_for_deps() { fi } +## TODO: Don't bother caring about host dependencies just use Docker for everything. ## Declare Linux app dependencies to check for. DEPENDENCIES=( wget @@ -36,6 +37,7 @@ BONUS_DEPENDENCIES=( docker-compose ) +## TODO: If the host doesn't have a dependency aside from docker, just use docker to do it and set the containers to remove themselves. function check_deps() { for i in "${!DEPENDENCIES[@]}"; do echo ${DEPENDENCIES[$i]}"_KEY" @@ -49,20 +51,41 @@ done case $1 in getdata ) ## Get DB Checkpoint data. - axel -a -n 6 http://chainquery-data.s3.amazonaws.com/chainquery-data.zip -o ./chainquery.zip + echo Asked to get the latest checkpoint data from + wget http://chainquery-data.s3.amazonaws.com/chainquery-data.zip -o ./chainquery.zip ;; extract ) ## Unpack the data again if need be. + echo Asked to unpack chainquery.zip if downloaded. + # TODO: add some magic here which will check for the presence of chainquery.zip and notify if its already gone. unzip ./chainquery.zip ;; cleanup ) ## Remove any junk here. + echo Asked to clean up leftover chainquery.zip to save on disk space. rm chainquery.zip ;; reset ) ## Give up on everything and try again. - # rm -Rf ./data - # rm -f ./chainquery.zip + docker-compose kill + docker-compose rm -f + rm -Rf ./data + rm -f ./chainquery.zip + ## TODO: Consider moving this somewhere as a function. + # docker-compose up -d mysql + # sleep 30 + # docker-compose up -d chainquery + ;; + start ) + ## Unsupported start command to start containers. + ## You can use this if you want to start this thing gracefully. + ## Ideally you would not use this in production. + echo "Asked to start chainquery gracefully for you." + docker-compose up -d mysql + echo "giving mysql some time to establish schema, crypto, users, permissions, and tables" + sleep 30 + echo "Starting Chainquery" + docker-compose up -d chainquery ;; compress-latest-checkpoint-data ) ## This is not intended for public use. From 40a914cbdde80a2d7a0db1bb5c79f6b43426b862 Mon Sep 17 00:00:00 2001 From: Leopere Date: Tue, 6 Nov 2018 17:26:57 -0500 Subject: [PATCH 10/26] Going dependency-less except for docker stuff now. --- chainquery/quick-bootstrap.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/chainquery/quick-bootstrap.sh b/chainquery/quick-bootstrap.sh index b2797e0..01be7ef 100755 --- a/chainquery/quick-bootstrap.sh +++ b/chainquery/quick-bootstrap.sh @@ -52,13 +52,13 @@ case $1 in getdata ) ## Get DB Checkpoint data. echo Asked to get the latest checkpoint data from - wget http://chainquery-data.s3.amazonaws.com/chainquery-data.zip -o ./chainquery.zip + docker run -v $(pwd)/:/download --rm leopere/axel-docker http://chainquery-data.s3.amazonaws.com/chainquery-data.zip -o ./chainquery.zip ;; extract ) ## Unpack the data again if need be. echo Asked to unpack chainquery.zip if downloaded. # TODO: add some magic here which will check for the presence of chainquery.zip and notify if its already gone. - unzip ./chainquery.zip + docker run -v $(pwd)/:/data --rm leopere/unzip-docker ./chainquery.zip ;; cleanup ) ## Remove any junk here. From 817af4589976e713adfed73ea1ac3f8a2393be28 Mon Sep 17 00:00:00 2001 From: Leopere Date: Tue, 6 Nov 2018 17:36:18 -0500 Subject: [PATCH 11/26] Reduced dependencies and adjusted todo items --- chainquery/quick-bootstrap.sh | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/chainquery/quick-bootstrap.sh b/chainquery/quick-bootstrap.sh index 01be7ef..8a850c4 100755 --- a/chainquery/quick-bootstrap.sh +++ b/chainquery/quick-bootstrap.sh @@ -25,19 +25,13 @@ function test_for_deps() { fi } -## TODO: Don't bother caring about host dependencies just use Docker for everything. ## Declare Linux app dependencies to check for. DEPENDENCIES=( - wget - unzip docker -) -## Recommended. -BONUS_DEPENDENCIES=( docker-compose ) -## TODO: If the host doesn't have a dependency aside from docker, just use docker to do it and set the containers to remove themselves. +## TODO: Check for docker and docker-compose function check_deps() { for i in "${!DEPENDENCIES[@]}"; do echo ${DEPENDENCIES[$i]}"_KEY" From f20df01251b513ce7d1734871a2b2deed08d1d99 Mon Sep 17 00:00:00 2001 From: Leopere Date: Tue, 6 Nov 2018 18:14:41 -0500 Subject: [PATCH 12/26] Home path suddenly was a problem. https://i.imgur.com/rAM1VWk.png --- lbrycrd/start.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lbrycrd/start.sh b/lbrycrd/start.sh index 842a092..526bc9f 100755 --- a/lbrycrd/start.sh +++ b/lbrycrd/start.sh @@ -25,7 +25,7 @@ case ${RUN_MODE:-default} in default ) lbrycrdd \ -server \ - -conf=$HOME/.lbrycrd/lbrycrd.conf \ + -conf=$HOME.lbrycrd/lbrycrd.conf \ -printtoconsole ;; reindex ) @@ -33,14 +33,14 @@ case ${RUN_MODE:-default} in -server \ -txindex \ -reindex \ - -conf=$HOME/.lbrycrd/lbrycrd.conf \ + -conf=$HOME.lbrycrd/lbrycrd.conf \ -printtoconsole ;; chainquery ) lbrycrdd \ -server \ -txindex \ - -conf=$HOME/.lbrycrd/lbrycrd.conf \ + -conf=$HOME.lbrycrd/lbrycrd.conf \ -printtoconsole ;; esac From 100d990d5d2f44fb27c8356d8ee76406cef5bc37 Mon Sep 17 00:00:00 2001 From: Leopere Date: Tue, 6 Nov 2018 18:16:03 -0500 Subject: [PATCH 13/26] Removed deprected config directory --- lbrycrd/docker-compose.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/lbrycrd/docker-compose.yml b/lbrycrd/docker-compose.yml index 57795e0..ccc3f5b 100644 --- a/lbrycrd/docker-compose.yml +++ b/lbrycrd/docker-compose.yml @@ -25,4 +25,3 @@ services: ## host volumes for persistent data such as wallet private keys. volumes: - ./data/:/data - - ./config:/etc/lbrycrdd From 03e5bb494ff0b72cede0d79da316a1cfe49b2be5 Mon Sep 17 00:00:00 2001 From: Leopere Date: Tue, 6 Nov 2018 18:19:25 -0500 Subject: [PATCH 14/26] Remove junk --- lbrycrd/compiler/.gitignore | 1 - 1 file changed, 1 deletion(-) delete mode 100644 lbrycrd/compiler/.gitignore diff --git a/lbrycrd/compiler/.gitignore b/lbrycrd/compiler/.gitignore deleted file mode 100644 index 8fce603..0000000 --- a/lbrycrd/compiler/.gitignore +++ /dev/null @@ -1 +0,0 @@ -data/ From b430ed411d500e25a8d7f431e1fceb24a8cedcd9 Mon Sep 17 00:00:00 2001 From: Leopere Date: Tue, 6 Nov 2018 18:24:47 -0500 Subject: [PATCH 15/26] Lets try $HOME/ instead of ~/ --- lbrycrd/start.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lbrycrd/start.sh b/lbrycrd/start.sh index 526bc9f..da82d25 100755 --- a/lbrycrd/start.sh +++ b/lbrycrd/start.sh @@ -16,9 +16,9 @@ rm -f /var/run/lbrycrdd.pid mkdir -p ~/.lbrycrd ## Set config params -echo -e "rpcuser=lbryrpc\nrpcpassword=${RPC_PASSWORD:-changeme}" > ~/.lbrycrd/lbrycrd.conf -echo -e "rpcallowip=${RPC_ALLOW_IP:-10.5.1.3}" >> ~/.lbrycrd/lbrycrd.conf -echo -e "rpcuser=${RPC_USER:-lbryrpc}" >> ~/.lbrycrd/lbrycrd.conf +echo -e "rpcuser=lbryrpc\nrpcpassword=${RPC_PASSWORD:-changeme}" > $HOME/.lbrycrd/lbrycrd.conf +echo -e "rpcallowip=${RPC_ALLOW_IP:-10.5.1.3}" >> $HOME/.lbrycrd/lbrycrd.conf +echo -e "rpcuser=${RPC_USER:-lbryrpc}" >> $HOME/.lbrycrd/lbrycrd.conf ## Control this invocation through envvar. case ${RUN_MODE:-default} in From dc7317022e43489f518dd31a7a383f289524dafe Mon Sep 17 00:00:00 2001 From: Leopere Date: Tue, 6 Nov 2018 18:29:26 -0500 Subject: [PATCH 16/26] Adding data directory with permissions to see if I can just ship it with it setup correctly --- lbrycrd/.gitignore | 2 +- lbrycrd/data/.gitkeep | 0 lbrycrd/start.sh | 6 +++--- 3 files changed, 4 insertions(+), 4 deletions(-) create mode 100644 lbrycrd/data/.gitkeep diff --git a/lbrycrd/.gitignore b/lbrycrd/.gitignore index 8fce603..b2840a0 100644 --- a/lbrycrd/.gitignore +++ b/lbrycrd/.gitignore @@ -1 +1 @@ -data/ +data/.lbrycrd diff --git a/lbrycrd/data/.gitkeep b/lbrycrd/data/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/lbrycrd/start.sh b/lbrycrd/start.sh index da82d25..52ff3cf 100755 --- a/lbrycrd/start.sh +++ b/lbrycrd/start.sh @@ -10,9 +10,9 @@ ## Ensure perms are correct prior to running main binary chown -R 1000:1000 /data chmod -R 755 /data -chown -R 1000:1000 /etc/lbrycrdd -chmod -R 755 /etc/lbrycrdd -rm -f /var/run/lbrycrdd.pid +chown -R 1000:1000 /etc/lbrycrd +chmod -R 755 /etc/lbrycrd +rm -f /var/run/lbrycrd.pid mkdir -p ~/.lbrycrd ## Set config params From 83ef420db94d967414df9513779089430080bdf4 Mon Sep 17 00:00:00 2001 From: Leopere Date: Tue, 6 Nov 2018 18:32:25 -0500 Subject: [PATCH 17/26] Adding more comments --- lbrycrd/start.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lbrycrd/start.sh b/lbrycrd/start.sh index 52ff3cf..50c22ce 100755 --- a/lbrycrd/start.sh +++ b/lbrycrd/start.sh @@ -10,12 +10,15 @@ ## Ensure perms are correct prior to running main binary chown -R 1000:1000 /data chmod -R 755 /data -chown -R 1000:1000 /etc/lbrycrd -chmod -R 755 /etc/lbrycrd + +## TODO: Consider a config directory for future magic. +# chown -R 1000:1000 /etc/lbrycrd +# chmod -R 755 /etc/lbrycrd rm -f /var/run/lbrycrd.pid mkdir -p ~/.lbrycrd ## Set config params +## TODO: Make this more automagic in the future. echo -e "rpcuser=lbryrpc\nrpcpassword=${RPC_PASSWORD:-changeme}" > $HOME/.lbrycrd/lbrycrd.conf echo -e "rpcallowip=${RPC_ALLOW_IP:-10.5.1.3}" >> $HOME/.lbrycrd/lbrycrd.conf echo -e "rpcuser=${RPC_USER:-lbryrpc}" >> $HOME/.lbrycrd/lbrycrd.conf @@ -45,7 +48,7 @@ case ${RUN_MODE:-default} in ;; esac - +## TODO: Look into what we can do with these launch params ## We were unsure if these function as intended so they were disabled for the time being. # -port=${PORT:-9246} \ # -data=${DATA_DIR:-/data/} \ From a924e1d221c8f33d2e212d46d9e63f58c20e08d8 Mon Sep 17 00:00:00 2001 From: Leopere Date: Tue, 6 Nov 2018 18:34:58 -0500 Subject: [PATCH 18/26] Adjusting data path --- lbrycrd/docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lbrycrd/docker-compose.yml b/lbrycrd/docker-compose.yml index ccc3f5b..b8e51bd 100644 --- a/lbrycrd/docker-compose.yml +++ b/lbrycrd/docker-compose.yml @@ -24,4 +24,4 @@ services: - 9246 ## host volumes for persistent data such as wallet private keys. volumes: - - ./data/:/data + - ./data:/data From 3308978eef5ab9d6304f334ad6c50a03f667f8c4 Mon Sep 17 00:00:00 2001 From: Leopere Date: Tue, 6 Nov 2018 18:36:04 -0500 Subject: [PATCH 19/26] Cleanup ToDo --- lbrycrd/start.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lbrycrd/start.sh b/lbrycrd/start.sh index 50c22ce..af0c89a 100755 --- a/lbrycrd/start.sh +++ b/lbrycrd/start.sh @@ -1,7 +1,6 @@ #!/usr/bin/env bash -# ## ToDo: -# ## Get a test case to see if this is the first run or a repeat run +# ## ToDo: Get a test case to see if this is the first run or a repeat run. # ## If it's a first run you need to do a full index including all transactions # ## tx index creates an index of every single transaction in the block history if # ## not specified it will only create an index for transactions that are related to the wallet or have unspent outputs. From f431dc9f9c4fb0624546089aa7d5715a53495560 Mon Sep 17 00:00:00 2001 From: Leopere Date: Tue, 6 Nov 2018 19:13:22 -0500 Subject: [PATCH 20/26] Add preliminary for healthcheck --- lbrycrd/healthcheck.sh | 4 ++++ 1 file changed, 4 insertions(+) create mode 100755 lbrycrd/healthcheck.sh diff --git a/lbrycrd/healthcheck.sh b/lbrycrd/healthcheck.sh new file mode 100755 index 0000000..ac4948f --- /dev/null +++ b/lbrycrd/healthcheck.sh @@ -0,0 +1,4 @@ +## TODO: Implement a healthcheck for lbrycrd. +curl --data-binary '{"jsonrpc":"1.0","id":"curltext","method":"getinfo","params":[]}' -H 'content-type:text/plain;' http://$RPC_USER:$RPC_PASSWORD@127.0.0.1:9246 +## OR +lbrycrd-cli getinfo From 1cfba4fd6950850484cb1b038d0c01cd80a81be1 Mon Sep 17 00:00:00 2001 From: Leopere Date: Tue, 6 Nov 2018 19:37:55 -0500 Subject: [PATCH 21/26] Baseline tutorial for getting chainquery up asap --- chainquery/README.md | 52 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 chainquery/README.md diff --git a/chainquery/README.md b/chainquery/README.md new file mode 100644 index 0000000..292428e --- /dev/null +++ b/chainquery/README.md @@ -0,0 +1,52 @@ +## Get the lbry-docker repository + +git clone https://github.com/lbryio/lbry-docker.git + +## Setup networking + +You only need external networking if you plan on keeping your docker-compose files separate. +For the sake of modularity in the design of this git repository the plan is to give you examples to try and then you're supposed to move towards your own custom docker-compose configuration. We're going to create +a docker bridge network that is going to be managed externally to your usual docker-compose networks which are compose internal. + +`docker network create -d bridge --subnet=10.5.1.0/16 lbrynet` + +## Make directories and set permissions + +This is only required on host mounted volumes. (the default settings) + +`mkdir -p ./lbry-docker/lbrycrd/data` + +`chmod -R 755 ./lbry-docker/lbrycrd/data` + +## Setup lbrycrd + +`cd lbry-docker/lbrycrd` + +`docker-compose up -d && docker-compose logs -f` + +Wait for lbrycrd to reach the top of the blockchain (console output should noticeably slow down) + +Once you've reached the top of the blockchain you can press `CTRL+C` to exit back to the linux shell. + +## Setup chainquery + +Now that you're done syncing your own copy of the lbry blockchain into the `lbrycrd` instance you can start spinning up Chainquery and it's dependencies. Since Chainquery is parsing copious amounts of unstructured data stored in the `lbry` blockchain you have two routes to go. + +1. Route number one [Recommended]: You use some variant of this README.md's instructions to start your chainquery instance using a LBRY.io provided database checkpoint snapshot. This should be basically copy paste-able series of commands to get your own staging instance up asap if you want Route number one, follow along with the rest of this README.md +2. Route number two: You can your own fresh copy of the chainquery database indexing times may vary from hours to days depending on your hardware. + +`cd ../chainquery/` + +`./quick-bootstrap.sh getdata` + +`./quick-bootstrap.sh extract` + +## docker-compose.override.yml + +Add a PORTS directive for binding chainquery to the host and then run. + +`./quick-bootstrap.sh start` + +*OR* + +`docker-compose up -d mysql && sleep 30 && docker-compose up -d chainquery` From 1c98af491dfe489670550cab02de96a4d17c45ab Mon Sep 17 00:00:00 2001 From: Leopere Date: Tue, 6 Nov 2018 19:39:12 -0500 Subject: [PATCH 22/26] added curl and a few things for healthcheck preparation --- lbrycrd/Dockerfile | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lbrycrd/Dockerfile b/lbrycrd/Dockerfile index 1ac4995..11955b1 100644 --- a/lbrycrd/Dockerfile +++ b/lbrycrd/Dockerfile @@ -5,14 +5,15 @@ LABEL MAINTAINER="leopere [at] nixc [dot] us" RUN adduser lbrycrdd --gecos GECOS --shell /bin/bash --disabled-password --home /data/ && \ apt-get update && \ - apt-get -y install unzip wget && \ + apt-get -y install unzip wget curl && \ apt-get autoclean -y && \ rm -rf /var/lib/apt/lists/* && \ mkdir -p /etc/lbrycrdd && \ chown -R 1000:1000 /etc/lbrycrdd -RUN wget -O /usr/bin/debugpaste https://github.com/nixc-us/debugpaste-it/raw/master/bin/debugpaste_64 && \ - chmod +x /usr/bin/debugpaste +## TODO: Consider adding debugpaste or variant +# RUN wget -O /usr/bin/debugpaste https://github.com/nixc-us/debugpaste-it/raw/master/bin/debugpaste_64 && \ +# chmod +x /usr/bin/debugpaste RUN wget -O /usr/bin/lbrycrd-linux.zip https://github.com/lbryio/lbrycrd/releases/download/v0.12.2.2/lbrycrd-linux.zip && \ cd /usr/bin/ && \ @@ -23,6 +24,7 @@ RUN wget -O /usr/bin/lbrycrd-linux.zip https://github.com/lbryio/lbrycrd/release COPY debugpaste-it.sh /usr/local/bin/debugpaste-it COPY start.sh /usr/local/bin/start COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint +COPY healthcheck.sh /usr/local/bin/healthcheck USER lbrycrdd @@ -31,6 +33,9 @@ RUN mkdir -p /data/ VOLUME /data/ VOLUME /etc/lbrycrdd/ +## TODO: Implement healthcheck. +# HEALTHCHECK ["healthcheck"] + ## Exposing daemon port and RPC port EXPOSE 9245 9246 From cdc67fb95ae720c4846ba65e31eee33910e2a62d Mon Sep 17 00:00:00 2001 From: Leopere Date: Tue, 6 Nov 2018 20:58:09 -0500 Subject: [PATCH 23/26] Expose mysql to the internet --- chainquery/docker-compose.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/chainquery/docker-compose.yml b/chainquery/docker-compose.yml index 2f42780..3c76f2c 100644 --- a/chainquery/docker-compose.yml +++ b/chainquery/docker-compose.yml @@ -22,6 +22,8 @@ services: - .env expose: - 3306 + ports: + - 3306:3306 volumes: - ./data/db:/var/lib/mysql - ./my.cnf:/etc/mysql/conf.d/chainquery-optimizations.cnf From 68cf9f524744046469d0520510eb26bc9c7c06a4 Mon Sep 17 00:00:00 2001 From: Leopere Date: Tue, 6 Nov 2018 20:58:33 -0500 Subject: [PATCH 24/26] Add todo item for reset switch --- chainquery/quick-bootstrap.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/chainquery/quick-bootstrap.sh b/chainquery/quick-bootstrap.sh index 8a850c4..b4a4338 100755 --- a/chainquery/quick-bootstrap.sh +++ b/chainquery/quick-bootstrap.sh @@ -61,6 +61,7 @@ case $1 in ;; reset ) ## Give up on everything and try again. + ## TODO: Make it very obvious with a nice little Y/N prompt that you're about to trash your settings and start over. docker-compose kill docker-compose rm -f rm -Rf ./data From e86e6b685213769b808dbe03f8d6b3d576b1662e Mon Sep 17 00:00:00 2001 From: Leopere Date: Tue, 6 Nov 2018 21:08:06 -0500 Subject: [PATCH 25/26] Just make this clickier --- chainquery/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chainquery/README.md b/chainquery/README.md index 292428e..676d979 100644 --- a/chainquery/README.md +++ b/chainquery/README.md @@ -1,6 +1,6 @@ ## Get the lbry-docker repository -git clone https://github.com/lbryio/lbry-docker.git +`git clone https://github.com/lbryio/lbry-docker.git` ## Setup networking From 161575626112e9bd40ca622fb22326635da71f55 Mon Sep 17 00:00:00 2001 From: Leopere Date: Tue, 6 Nov 2018 23:21:25 -0500 Subject: [PATCH 26/26] Disabling feature that isn't ready yet. --- chainquery/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chainquery/Dockerfile b/chainquery/Dockerfile index adb37c6..b5689f1 100644 --- a/chainquery/Dockerfile +++ b/chainquery/Dockerfile @@ -34,7 +34,7 @@ COPY chainqueryconfig.toml /etc/chainquery/ ## Get latest chainqueryconfig.toml from master on github as template. # TODO: add magic which pattern matches for chainqueryconfig.toml DEFAULT strings and replaces them with configured settings on container start. -ADD --chown=1000:1000 https://raw.githubusercontent.com/lbryio/chainquery/master/config/default/chainqueryconfig.toml /etc/chainquery/chainqueryconfig.toml.orig +# ADD --chown=1000:1000 https://raw.githubusercontent.com/lbryio/chainquery/master/config/default/chainqueryconfig.toml /etc/chainquery/chainqueryconfig.toml.orig ## Install start.sh as executable script in container $PATH COPY start.sh /usr/local/bin/start