From 40755ad179dbb3b19238dfc2347f2c43e01c230c Mon Sep 17 00:00:00 2001 From: Mark Beamer Jr Date: Thu, 27 Dec 2018 23:11:34 -0500 Subject: [PATCH 1/2] added regtest setup for lbrycrd. --- .gitignore | 1 - lbrycrd/.gitignore | 1 + lbrycrd/regtest/Dockerfile | 41 ++++++++++++++++++++++++++++ lbrycrd/regtest/advance_blocks.sh | 6 ++++ lbrycrd/regtest/docker-compose.yml | 17 ++++++++++++ lbrycrd/regtest/docker-entrypoint.sh | 13 +++++++++ lbrycrd/regtest/start.sh | 36 ++++++++++++++++++++++++ 7 files changed, 114 insertions(+), 1 deletion(-) create mode 100644 lbrycrd/regtest/Dockerfile create mode 100755 lbrycrd/regtest/advance_blocks.sh create mode 100644 lbrycrd/regtest/docker-compose.yml create mode 100755 lbrycrd/regtest/docker-entrypoint.sh create mode 100755 lbrycrd/regtest/start.sh diff --git a/.gitignore b/.gitignore index f8f1aa3..ece9c18 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,6 @@ .gitlab-ci.yml .DS_Store */docker-compose.override.yml -docker-compose.yml */data/ ./docker-compose.yml *.zip \ No newline at end of file diff --git a/lbrycrd/.gitignore b/lbrycrd/.gitignore index b2840a0..5e9dc0e 100644 --- a/lbrycrd/.gitignore +++ b/lbrycrd/.gitignore @@ -1 +1,2 @@ data/.lbrycrd +regtest/data diff --git a/lbrycrd/regtest/Dockerfile b/lbrycrd/regtest/Dockerfile new file mode 100644 index 0000000..38fa0cf --- /dev/null +++ b/lbrycrd/regtest/Dockerfile @@ -0,0 +1,41 @@ +## This base image is for running latest lbrycrdd +# For some reason I may switch this image over to Alpine when I can RCA why it won't start. +FROM ubuntu:18.04 +LABEL MAINTAINER="leopere [at] nixc [dot] us" + +RUN addgroup --gid 1000 lbrycrd && \ + adduser lbrycrd --uid 1000 --gid 1000 --gecos GECOS --shell /bin/bash --disabled-password --home /data && \ + apt-get update && \ + apt-get -y install unzip wget curl && \ + apt-get autoclean -y && \ + rm -rf /var/lib/apt/lists/* + +## 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/ && \ + unzip lbrycrd-linux.zip && \ + rm lbrycrd-linux.zip && \ + chmod +x lbrycrdd lbrycrd-cli lbrycrd-tx + +COPY start.sh /usr/local/bin/start +COPY advance_blocks.sh /usr/local/bin/advance +COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint + +# USER lbrycrd +# RUN mkdir /data +VOLUME ["/data"] +WORKDIR /data + +## Exposing daemon port and RPC port +EXPOSE 9245 9246 + +## TODO: Decide what's important for lbrycrd and possibly add an entrypoint. +## Maybe catch things that might match things that can be easily executed in the +## lbrycrd cli and if nothing is entered just default to the containers shell. +## For now this is a placeholder that executes /bin/bash on `docker exec` +# ENTRYPOINT ["docker-entrypoint"] + +CMD ["start"] diff --git a/lbrycrd/regtest/advance_blocks.sh b/lbrycrd/regtest/advance_blocks.sh new file mode 100755 index 0000000..85728c4 --- /dev/null +++ b/lbrycrd/regtest/advance_blocks.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +sleep 2 +while true; do + lbrycrd-cli -conf=/data/.lbrycrd/lbrycrd.conf generate 1 >> /tmp/output.log + sleep 10 +done \ No newline at end of file diff --git a/lbrycrd/regtest/docker-compose.yml b/lbrycrd/regtest/docker-compose.yml new file mode 100644 index 0000000..e540308 --- /dev/null +++ b/lbrycrd/regtest/docker-compose.yml @@ -0,0 +1,17 @@ +version: '3.4' + +services: +############# +## Lbrycrd ## +############# + lbrycrd: + image: tiger5226/lbrycrd_reg_test + restart: always + labels: + - "traefik.expose=true" + ports: + - "11336:9246" + - "11337:11337" + ## host volumes for persistent data such as wallet private keys. + volumes: + - "./data:/data" diff --git a/lbrycrd/regtest/docker-entrypoint.sh b/lbrycrd/regtest/docker-entrypoint.sh new file mode 100755 index 0000000..77e798a --- /dev/null +++ b/lbrycrd/regtest/docker-entrypoint.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +# default to run whatever the user wanted like "/bin/bash" +## If user runs no need to run any more of the entrypoint script. +if [[ -z "$@" ]]; then + echo "User did not attempt input. Now executing docker-entrypoint." +else + echo "Running $@." + exec "$@" + exit 1 +fi + +/bin/bash diff --git a/lbrycrd/regtest/start.sh b/lbrycrd/regtest/start.sh new file mode 100755 index 0000000..f184cfb --- /dev/null +++ b/lbrycrd/regtest/start.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash + +# ## 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. +# ## This is specific to chainquery. + +## Ensure perms are correct prior to running main binary +mkdir -p /data/.lbrycrd +chown -R lbrycrd:lbrycrd /data +chmod -R 755 /data/ + +## 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 + + +## Set config params +## TODO: Make this more automagic in the future. +echo "rpcuser=lbry" > /data/.lbrycrd/lbrycrd.conf +echo "rpcpassword=lbry" >> /data/.lbrycrd/lbrycrd.conf +echo "rpcport=11337" >> /data/.lbrycrd/lbrycrd.conf +echo "rpcbind=0.0.0.0" >> /data/.lbrycrd/lbrycrd.conf +echo "rpcallowip=0.0.0.0/0" >> /data/.lbrycrd/lbrycrd.conf +echo "regtest=1" >> /data/.lbrycrd/lbrycrd.conf +echo "txindex=1" >> /data/.lbrycrd/lbrycrd.conf +echo "server=1" >> /data/.lbrycrd/lbrycrd.conf +echo "printtoconsole=1" >> /data/.lbrycrd/lbrycrd.conf +#echo "bind=0.0.0.0" >> /data/.lbrycrd/lbrycrd.conf + +#advance nohup & +nohup advance &>/dev/null & +su -c "lbrycrdd -conf=/data/.lbrycrd/lbrycrd.conf" lbrycrd + From 6c9d71e750cd1efd84e9d8b53a9906c22e4490ff Mon Sep 17 00:00:00 2001 From: Mark Beamer Jr Date: Thu, 27 Dec 2018 23:57:17 -0500 Subject: [PATCH 2/2] added regtest setup for lbrycrd. --- lbrycrd/regtest/advance_blocks.sh | 5 ++--- lbrycrd/regtest/docker-compose.yml | 2 +- lbrycrd/regtest/upload.sh | 4 ++++ 3 files changed, 7 insertions(+), 4 deletions(-) create mode 100755 lbrycrd/regtest/upload.sh diff --git a/lbrycrd/regtest/advance_blocks.sh b/lbrycrd/regtest/advance_blocks.sh index 85728c4..21eebc8 100755 --- a/lbrycrd/regtest/advance_blocks.sh +++ b/lbrycrd/regtest/advance_blocks.sh @@ -1,6 +1,5 @@ #!/usr/bin/env bash -sleep 2 while true; do - lbrycrd-cli -conf=/data/.lbrycrd/lbrycrd.conf generate 1 >> /tmp/output.log - sleep 10 + lbrycrd-cli -conf=/data/.lbrycrd/lbrycrd.conf generate 50 >> /tmp/output.log + sleep 1 done \ No newline at end of file diff --git a/lbrycrd/regtest/docker-compose.yml b/lbrycrd/regtest/docker-compose.yml index e540308..08efe1c 100644 --- a/lbrycrd/regtest/docker-compose.yml +++ b/lbrycrd/regtest/docker-compose.yml @@ -5,7 +5,7 @@ services: ## Lbrycrd ## ############# lbrycrd: - image: tiger5226/lbrycrd_reg_test + image: tiger5226/regtest restart: always labels: - "traefik.expose=true" diff --git a/lbrycrd/regtest/upload.sh b/lbrycrd/regtest/upload.sh new file mode 100755 index 0000000..45ccd9d --- /dev/null +++ b/lbrycrd/regtest/upload.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +docker build -t tiger5226/regtest:latest . +docker push tiger5226/regtest:latest \ No newline at end of file