Lbrynet containers for compiling and running armhf and x86_64 #53
40 changed files with 913 additions and 110 deletions
2
.dockerignore
Normal file
2
.dockerignore
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
data/
|
||||||
|
*/data/
|
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -1,4 +1,7 @@
|
||||||
.gitlab-ci.yml
|
.gitlab-ci.yml
|
||||||
.DS_Store
|
.DS_Store
|
||||||
*/docker-compose.override.yml
|
*/docker-compose.override.yml
|
||||||
|
*/*/data
|
||||||
|
|
||||||
./docker-compose.yml
|
./docker-compose.yml
|
||||||
|
*.zip
|
|
@ -1,3 +1,5 @@
|
||||||
data/
|
data/
|
||||||
data.z*
|
data.z*
|
||||||
chainquery.z*
|
chainquery.z*
|
||||||
|
*.zip
|
||||||
|
compile/
|
||||||
|
|
1
chainquery/.gitignore
vendored
1
chainquery/.gitignore
vendored
|
@ -1,3 +1,4 @@
|
||||||
data/
|
data/
|
||||||
data.z*
|
data.z*
|
||||||
chainquery.z*
|
chainquery.z*
|
||||||
|
*.zip
|
||||||
|
|
|
@ -30,11 +30,11 @@ RUN adduser chainquery --gecos GECOS --shell /bin/bash --disabled-password --hom
|
||||||
COPY --from=0 /download/chainquery /usr/bin
|
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
|
# ADD --chown=1000:1000 https://github.com/lbryio/chainquery/releases/download/latest/chainquery_latest_Linux_x86_64.zip /usr/bin
|
||||||
COPY stuff/chainqueryconfig.toml /etc/chainquery/
|
# COPY stuff/chainqueryconfig.toml /etc/chainquery/
|
||||||
|
|
||||||
## Get latest chainqueryconfig.toml from master on github as template.
|
## 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.
|
# 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 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
|
## Install start.sh as executable script in container $PATH
|
||||||
COPY stuff/start.sh /usr/local/bin/start
|
COPY stuff/start.sh /usr/local/bin/start
|
||||||
|
@ -42,8 +42,8 @@ COPY stuff/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.
|
# 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
|
# COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint
|
||||||
|
|
||||||
## From here onward we're doing this with no root.
|
# ## From here onward we're doing this with no root.
|
||||||
USER chainquery
|
# USER chainquery
|
||||||
|
|
||||||
## Expose Chainquery API port
|
## Expose Chainquery API port
|
||||||
EXPOSE 6300
|
EXPOSE 6300
|
||||||
|
|
4
chainquery/compile/.dockerignore
Normal file
4
chainquery/compile/.dockerignore
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
data/
|
||||||
|
data.z*
|
||||||
|
chainquery.z*
|
||||||
|
compile/
|
16
chainquery/compile/.env
Normal file
16
chainquery/compile/.env
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
COMPOSE_PROJECT_NAME=chainquery
|
||||||
|
|
||||||
|
#########################
|
||||||
|
## Chainquery Settings ##
|
||||||
|
#########################
|
||||||
|
RPC_ALLOW_IP=10.5.1.3
|
||||||
|
DEBUGMODE=false
|
||||||
|
|
||||||
|
#################
|
||||||
|
## Mysql Creds ##
|
||||||
|
#################
|
||||||
|
MYSQL_SERVER=10.5.1.10
|
||||||
|
MYSQL_USER=changeme
|
||||||
|
MYSQL_PASSWORD=changeme
|
||||||
|
MYSQL_DATABASE=chainquery
|
||||||
|
MYSQL_ROOT_PASSWORD=changeme
|
4
chainquery/compile/.gitignore
vendored
Normal file
4
chainquery/compile/.gitignore
vendored
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
data/
|
||||||
|
data.z*
|
||||||
|
chainquery.z*
|
||||||
|
compile/
|
52
chainquery/compile/Dockerfile
Normal file
52
chainquery/compile/Dockerfile
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
## This base image is for running latest chainquery
|
||||||
|
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
|
||||||
|
|
||||||
|
## 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
|
||||||
|
|
||||||
|
|
||||||
|
# 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 stuff/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 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 stuff/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"]
|
57
chainquery/compile/docker-compose.yml
Normal file
57
chainquery/compile/docker-compose.yml
Normal file
|
@ -0,0 +1,57 @@
|
||||||
|
version: '3.4'
|
||||||
|
|
||||||
|
networks:
|
||||||
|
lbrynet:
|
||||||
|
external: true
|
||||||
|
|
||||||
|
services:
|
||||||
|
###########
|
||||||
|
## MYSQL ##
|
||||||
|
###########
|
||||||
|
## MariaDB is currently not supported and neither is later versions of MySQL this may change.
|
||||||
|
## https://hub.docker.com/r/_/mariadb/
|
||||||
|
mysql:
|
||||||
|
image: mysql:5.7.23
|
||||||
|
restart: always
|
||||||
|
networks:
|
||||||
|
lbrynet:
|
||||||
|
ipv4_address: 10.5.1.10
|
||||||
|
aliases:
|
||||||
|
- mysql
|
||||||
|
env_file:
|
||||||
|
- .env
|
||||||
|
expose:
|
||||||
|
- 3306
|
||||||
|
## TODO: I want to find a way that is acceptable to everyone to lock this up
|
||||||
|
## and not share it with everyone at least eventually.
|
||||||
|
ports:
|
||||||
|
- 3306:3306
|
||||||
|
volumes:
|
||||||
|
- ./data/db:/var/lib/mysql
|
||||||
|
- ./stuff/my.cnf:/etc/mysql/conf.d/chainquery-optimizations.cnf
|
||||||
|
|
||||||
|
################
|
||||||
|
## Chainquery ##
|
||||||
|
################
|
||||||
|
chainquery:
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
target: app
|
||||||
|
restart: always
|
||||||
|
networks:
|
||||||
|
lbrynet:
|
||||||
|
ipv4_address: 10.5.1.3
|
||||||
|
env_file:
|
||||||
|
- .env
|
||||||
|
- ../lbrycrd/.env
|
||||||
|
labels:
|
||||||
|
- "traefik.expose=false"
|
||||||
|
expose:
|
||||||
|
- 6300
|
||||||
|
ports:
|
||||||
|
- 6300:6300
|
||||||
|
depends_on:
|
||||||
|
- mysql
|
||||||
|
## TODO: Uncomment this in a docker-compose.override.yml to allow for external configurations.
|
||||||
|
# volumes:
|
||||||
|
# - ./data/config/chainqueryconfig.toml:/etc/chainquery/chainqueryconfig.toml
|
148
chainquery/compile/quick-bootstrap.sh
Normal file
148
chainquery/compile/quick-bootstrap.sh
Normal file
|
@ -0,0 +1,148 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
## TODO: Be Polite and ask for confirmation.
|
||||||
|
function QandA() {
|
||||||
|
read -r -p "Continue with $1 [y/N] " response
|
||||||
|
response=${response,,} # tolower
|
||||||
|
if [[ "$response" =~ ^(yes|y)$ ]]; then
|
||||||
|
echo "Continuing with this."
|
||||||
|
eval $1
|
||||||
|
else
|
||||||
|
echo "Skipping the $1."
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
## 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
|
||||||
|
echo "Error: $1 is not installed." >&2
|
||||||
|
echo "You must have $1 installed."
|
||||||
|
else
|
||||||
|
echo "Info: $1 is installed."
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
## Declare Linux app dependencies to check for.
|
||||||
|
DEPENDENCIES=(
|
||||||
|
docker
|
||||||
|
docker-compose
|
||||||
|
)
|
||||||
|
|
||||||
|
## TODO: Check for docker and docker-compose
|
||||||
|
function check_deps() {
|
||||||
|
for i in "${!DEPENDENCIES[@]}"; do
|
||||||
|
echo ${DEPENDENCIES[$i]}"_KEY"
|
||||||
|
## Indirect references http://tldp.org/LDP/abs/html/ivr.html
|
||||||
|
eval TESTDEP=\$"${DEPENDENCIES[$i]}"
|
||||||
|
test_for_deps $TESTDEP
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_checkpoint() {
|
||||||
|
## Get DB Checkpoint data.
|
||||||
|
echo Asked to get the latest checkpoint data, downloading latest checkpoint.
|
||||||
|
echo This data is fairly large so this saves you a few days of parsing the LBRY blockchain.
|
||||||
|
docker run -v $(pwd)/:/download --rm leopere/axel-docker http://chainquery-data.s3.amazonaws.com/chainquery-data.zip -o ./chainquery.zip
|
||||||
|
}
|
||||||
|
|
||||||
|
#################################
|
||||||
|
## The real action begins here ##
|
||||||
|
#################################
|
||||||
|
## TODO: Add ways to get into and out of a bind here.
|
||||||
|
case $1 in
|
||||||
|
getdata )
|
||||||
|
if [[ -f ./chainquery.zip ]]; then
|
||||||
|
echo "Found a copy of ./chainquery.zip already in your system."
|
||||||
|
echo "We recommend that you delete this data before proceeding and grab a fresh copy."
|
||||||
|
QandA "rm -f ./chainquery.zip"
|
||||||
|
get_checkpoint
|
||||||
|
else
|
||||||
|
get_checkpoint
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
extract )
|
||||||
|
## Unpack the data again if need be.
|
||||||
|
echo Asked to unpack chainquery.zip if downloaded.
|
||||||
|
if [[ -f ./chainquery.zip ]]; then
|
||||||
|
docker run -v $(pwd)/:/data --rm leopere/unzip-docker ./chainquery.zip
|
||||||
|
else
|
||||||
|
echo "Could not extractas chainquery.zip did not exist."
|
||||||
|
echo "Feel free to execute './quick-bootstrap.sh getdata' first next time."
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
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.
|
||||||
|
## TODO: Make it very obvious with a nice little Y/N prompt that you're about to trash your settings and start over.
|
||||||
|
echo "Agressively Killing all chainquery and dependency containers."
|
||||||
|
echo "executing: docker-compose kill"
|
||||||
|
docker-compose kill
|
||||||
|
echo "Cleaning up stopped containers."
|
||||||
|
echo "executing: docker-compose rm -f"
|
||||||
|
docker-compose rm -f
|
||||||
|
rm -Rf ./data
|
||||||
|
rm -f ./chainquery.zip
|
||||||
|
;;
|
||||||
|
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."
|
||||||
|
echo "executing: docker-compose up -d mysql"
|
||||||
|
docker-compose up -d mysql
|
||||||
|
echo "giving mysql some time to establish schema, crypto, users, permissions, and tables"
|
||||||
|
sleep 30
|
||||||
|
echo "Starting Chainquery"
|
||||||
|
echo "executing: docker-compose up -d chainquery"
|
||||||
|
docker-compose up -d chainquery
|
||||||
|
## TODO: verify chainquery instance is up and healthy, this requires a functional HEALTHCHECK
|
||||||
|
echo "This should have chainquery up and running, currently theres no checks in this function to verify this however."
|
||||||
|
echo "Do feel free to execute 'docker-compose ps' to verify if its running and not restarting or exited."
|
||||||
|
echo "Final Note: You should try to use the docker-compose commands in the tutorial at https://github.com/lbryio/lbry-docker/blob/master/chainquery/README.md"
|
||||||
|
;;
|
||||||
|
compress-latest-checkpoint-data )
|
||||||
|
## This is not intended for public use.
|
||||||
|
docker-compose stop chainquery
|
||||||
|
docker-compose stop mysql
|
||||||
|
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
|
||||||
|
;;
|
||||||
|
* )
|
||||||
|
echo "=================================================="
|
||||||
|
echo "You look like you need usage examples let me help."
|
||||||
|
echo "=================================================="
|
||||||
|
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
|
|
@ -4,13 +4,13 @@
|
||||||
debugmode=false
|
debugmode=false
|
||||||
|
|
||||||
#LBRYcrd URL is required for chainquery to query the blockchain
|
#LBRYcrd URL is required for chainquery to query the blockchain
|
||||||
lbrycrdurl="rpc://lbryrpc:changeme@10.6.1.2:9245"
|
lbrycrdurl="rpc://lbryrpc:changeme@10.5.1.2:9245"
|
||||||
|
|
||||||
#MySQL DSN is required for chainquery to store information.
|
#MySQL DSN is required for chainquery to store information.
|
||||||
mysqldsn="changeme:changeme@tcp(10.6.1.10:3306)/chainquery"
|
mysqldsn="changeme:changeme@tcp(10.5.1.10:3306)/chainquery"
|
||||||
|
|
||||||
#API MySQL DSN is required for chainquery to expose a SQL query service
|
#API MySQL DSN is required for chainquery to expose a SQL query service
|
||||||
apimysqldsn="changeme:changeme@tcp(10.6.1.10:3306)/chainquery"
|
apimysqldsn="changeme:changeme@tcp(10.5.1.10:3306)/chainquery"
|
||||||
|
|
||||||
#The command that should be executed to trigger a self update of the software. For linux, for example, `<yourscript>.sh`
|
#The command that should be executed to trigger a self update of the software. For linux, for example, `<yourscript>.sh`
|
||||||
#DEFAULT-autoupdatecommand=[unset]
|
#DEFAULT-autoupdatecommand=[unset]
|
1
chainquery/compile/stuff/debugpaste-it.sh
Normal file
1
chainquery/compile/stuff/debugpaste-it.sh
Normal file
|
@ -0,0 +1 @@
|
||||||
|
#!/usr/bin/env bash
|
13
chainquery/compile/stuff/docker-entrypoint.sh
Normal file
13
chainquery/compile/stuff/docker-entrypoint.sh
Normal file
|
@ -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
|
3
chainquery/compile/stuff/healthcheck.sh
Normal file
3
chainquery/compile/stuff/healthcheck.sh
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
## TODO: Implement this at some point it requires CURL in the container.
|
||||||
|
curl http://localhost:6300/api/status
|
9
chainquery/compile/stuff/my.cnf
Normal file
9
chainquery/compile/stuff/my.cnf
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
# Default Homebrew MySQL server config
|
||||||
|
[mysqld]
|
||||||
|
# Only allow connections from localhost
|
||||||
|
innodb_log_file_size=5G
|
||||||
|
key_buffer_size=1G
|
||||||
|
innodb_flush_log_at_trx_commit = 0
|
||||||
|
innodb_autoinc_lock_mode=2
|
||||||
|
innodb_buffer_pool_size=1G
|
||||||
|
innodb_log_buffer_size=1G
|
54
chainquery/compile/stuff/start.sh
Normal file
54
chainquery/compile/stuff/start.sh
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
## Config setup
|
||||||
|
|
||||||
|
## Setup Values
|
||||||
|
DEBUGMODE=$(echo "debugmode=$DEBUGMODE")
|
||||||
|
LBRYCRDURL=$(echo "lbrycrdurl=\"rpc://$RPC_USER:$RPC_PASSWORD@10.5.1.2:9245\"")
|
||||||
|
MYSQLDSN=$(echo "mysqldsn=\"$MYSQL_USER:$MYSQL_PASSWORD@tcp($MYSQL_SERVER:3306)/$MYSQL_DATABASE\"")
|
||||||
|
APIMYSQLDSN=$(echo "apimysqldsn=\"$MYSQL_USER:$MYSQL_PASSWORD@tcp($MYSQL_SERVER:3306)/$MYSQL_DATABASE\"")
|
||||||
|
|
||||||
|
## Setup Defaults
|
||||||
|
DEBUGMODE_DEFAULT='#DEFAULT-debugmode=false'
|
||||||
|
LBRYCRDURL_DEFAULT='#DEFAULT-lbrycrdurl="rpc://lbry:lbry@localhost:9245"'
|
||||||
|
MYSQLDSN_DEFAULT='#DEFAULT-mysqldsn="lbry:lbry@tcp(localhost:3306)/chainquery"'
|
||||||
|
APIMYSQLDSN_DEFAULT='#DEFAULT-apimysqldsn="lbry:lbry@tcp(localhost:3306)/chainquery"'
|
||||||
|
|
||||||
|
## Add setup value variable name to this list to get processed on container start
|
||||||
|
CONFIG_SETTINGS=(
|
||||||
|
DEBUGMODE
|
||||||
|
LBRYCRDURL
|
||||||
|
MYSQLDSN
|
||||||
|
APIMYSQLDSN
|
||||||
|
)
|
||||||
|
|
||||||
|
function set_configs() {
|
||||||
|
## Set configs on container start if not already set.
|
||||||
|
for i in "${!CONFIG_SETTINGS[@]}"; do
|
||||||
|
## Indirect references http://tldp.org/LDP/abs/html/ivr.html
|
||||||
|
eval FROM_STRING=\$"${CONFIG_SETTINGS[$i]}_DEFAULT"
|
||||||
|
eval TO_STRING=\$${CONFIG_SETTINGS[$i]}
|
||||||
|
## TODO: Add a bit more magic to make sure that you're only configuring things if not set by config mounts.
|
||||||
|
sed -i "s~$FROM_STRING~"$TO_STRING"~g" /etc/chainquery/chainqueryconfig.toml
|
||||||
|
done
|
||||||
|
echo "Reading config for debugging."
|
||||||
|
cat /etc/chainquery/chainqueryconfig.toml
|
||||||
|
}
|
||||||
|
|
||||||
|
if [[ ! -f /etc/chainquery/chainqueryconfig.toml ]]; then
|
||||||
|
echo "[INFO]: Did not find chainqueryconfig.toml"
|
||||||
|
echo " Installing default and configuring with provided environment variables if any."
|
||||||
|
## Install fresh copy of config file.
|
||||||
|
echo "cp -v /etc/chainquery/chainqueryconfig.toml.orig /etc/chainquery/chainqueryconfig.toml"
|
||||||
|
cp -v /etc/chainquery/chainqueryconfig.toml.orig /etc/chainquery/chainqueryconfig.toml
|
||||||
|
chmod 755 /etc/chainquery/chainqueryconfig.toml
|
||||||
|
ls -lAh /etc/chainquery/
|
||||||
|
set_configs
|
||||||
|
else
|
||||||
|
echo "[INFO]: Found a copy of chainqueryconfig.toml in /etc/chainquery"
|
||||||
|
echo " Attempting to non destructively install any new environment configurations."
|
||||||
|
set_configs
|
||||||
|
fi
|
||||||
|
|
||||||
|
## 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
|
||||||
|
su -c "chainquery serve -c "/etc/chainquery/"" chainquery
|
|
@ -19,7 +19,7 @@ services:
|
||||||
aliases:
|
aliases:
|
||||||
- mysql
|
- mysql
|
||||||
env_file:
|
env_file:
|
||||||
- .env
|
- env
|
||||||
expose:
|
expose:
|
||||||
- 3306
|
- 3306
|
||||||
## TODO: I want to find a way that is acceptable to everyone to lock this up
|
## TODO: I want to find a way that is acceptable to everyone to lock this up
|
||||||
|
@ -42,8 +42,8 @@ services:
|
||||||
lbry-network:
|
lbry-network:
|
||||||
ipv4_address: 10.6.1.3
|
ipv4_address: 10.6.1.3
|
||||||
env_file:
|
env_file:
|
||||||
- .env
|
- env
|
||||||
- ../lbrycrd/.env
|
- ../lbrycrd/env
|
||||||
labels:
|
labels:
|
||||||
- "traefik.expose=false"
|
- "traefik.expose=false"
|
||||||
expose:
|
expose:
|
||||||
|
@ -52,3 +52,6 @@ services:
|
||||||
- 6300:6300
|
- 6300:6300
|
||||||
depends_on:
|
depends_on:
|
||||||
- mysql
|
- mysql
|
||||||
|
## TODO: Uncomment this in a docker-compose.override.yml to allow for external configurations.
|
||||||
|
# volumes:
|
||||||
|
# - ./data/config/chainqueryconfig.toml:/etc/chainquery/chainqueryconfig.toml
|
||||||
|
|
16
chainquery/env
Normal file
16
chainquery/env
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
COMPOSE_PROJECT_NAME=chainquery
|
||||||
|
|
||||||
|
#########################
|
||||||
|
## Chainquery Settings ##
|
||||||
|
#########################
|
||||||
|
RPC_ALLOW_IP=10.5.1.3
|
||||||
|
DEBUGMODE=false
|
||||||
|
|
||||||
|
#################
|
||||||
|
## Mysql Creds ##
|
||||||
|
#################
|
||||||
|
MYSQL_SERVER=10.5.1.10
|
||||||
|
MYSQL_USER=chainquery
|
||||||
|
MYSQL_PASSWORD=changeme
|
||||||
|
MYSQL_DATABASE=chainquery
|
||||||
|
MYSQL_ROOT_PASSWORD=changeme
|
|
@ -1,31 +1,54 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
# TODO: Remove this notes section.
|
## Config setup
|
||||||
## 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.6.1.3 ## You're better off not changing this.
|
|
||||||
#
|
|
||||||
# #################
|
|
||||||
# ## Mysql Creds ##
|
|
||||||
# #################
|
|
||||||
# MYSQL_SERVER=10.6.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.
|
|
||||||
|
|
||||||
# TODO: Add chainquery startup magic for configuration.
|
## Setup Values
|
||||||
# sed -i ''
|
DEBUGMODE=$(echo "debugmode=$DEBUGMODE")
|
||||||
#
|
LBRYCRDURL=$(echo "lbrycrdurl=\"rpc://$RPC_USER:$RPC_PASSWORD@10.5.1.2:9245\"")
|
||||||
#
|
MYSQLDSN=$(echo "mysqldsn=\"$MYSQL_USER:$MYSQL_PASSWORD@tcp($MYSQL_SERVER:3306)/$MYSQL_DATABASE\"")
|
||||||
# debugmode=${DEBUGMODE:-false}
|
APIMYSQLDSN=$(echo "apimysqldsn=\"$MYSQL_USER:$MYSQL_PASSWORD@tcp($MYSQL_SERVER:3306)/$MYSQL_DATABASE\"")
|
||||||
# lbrycrdurl="rpc://${RPC_USER:-lbryrpc}:${RPC_PASSWORD:-changeme}@10.6.1.2:9245"
|
|
||||||
# mysqldsn="${MYSQL_USER:-changeme}:${MYSQL_PASSWORD:-changeme}@tcp(${MYSQL_SERVER:-10.6.1.10}:3306)/${MYSQL_DATABASE:-chainquery}"
|
## Setup Defaults
|
||||||
# apimysqldsn="${MYSQL_USER:-changeme}:${MYSQL_PASSWORD:-changeme}@tcp(${MYSQL_SERVER:-10.6.1.10}:3306)/${MYSQL_DATABASE:-chainquery}"
|
DEBUGMODE_DEFAULT='#DEFAULT-debugmode=false'
|
||||||
|
LBRYCRDURL_DEFAULT='#DEFAULT-lbrycrdurl="rpc://lbry:lbry@localhost:9245"'
|
||||||
|
MYSQLDSN_DEFAULT='#DEFAULT-mysqldsn="lbry:lbry@tcp(localhost:3306)/chainquery"'
|
||||||
|
APIMYSQLDSN_DEFAULT='#DEFAULT-apimysqldsn="lbry:lbry@tcp(localhost:3306)/chainquery"'
|
||||||
|
|
||||||
|
## Add setup value variable name to this list to get processed on container start
|
||||||
|
CONFIG_SETTINGS=(
|
||||||
|
DEBUGMODE
|
||||||
|
LBRYCRDURL
|
||||||
|
MYSQLDSN
|
||||||
|
APIMYSQLDSN
|
||||||
|
)
|
||||||
|
|
||||||
|
function set_configs() {
|
||||||
|
## Set configs on container start if not already set.
|
||||||
|
for i in "${!CONFIG_SETTINGS[@]}"; do
|
||||||
|
## Indirect references http://tldp.org/LDP/abs/html/ivr.html
|
||||||
|
eval FROM_STRING=\$"${CONFIG_SETTINGS[$i]}_DEFAULT"
|
||||||
|
eval TO_STRING=\$${CONFIG_SETTINGS[$i]}
|
||||||
|
## TODO: Add a bit more magic to make sure that you're only configuring things if not set by config mounts.
|
||||||
|
sed -i "s~$FROM_STRING~"$TO_STRING"~g" /etc/chainquery/chainqueryconfig.toml
|
||||||
|
done
|
||||||
|
echo "Reading config for debugging."
|
||||||
|
cat /etc/chainquery/chainqueryconfig.toml
|
||||||
|
}
|
||||||
|
|
||||||
|
if [[ ! -f /etc/chainquery/chainqueryconfig.toml ]]; then
|
||||||
|
echo "[INFO]: Did not find chainqueryconfig.toml"
|
||||||
|
echo " Installing default and configuring with provided environment variables if any."
|
||||||
|
## Install fresh copy of config file.
|
||||||
|
echo "cp -v /etc/chainquery/chainqueryconfig.toml.orig /etc/chainquery/chainqueryconfig.toml"
|
||||||
|
cp -v /etc/chainquery/chainqueryconfig.toml.orig /etc/chainquery/chainqueryconfig.toml
|
||||||
|
chmod 755 /etc/chainquery/chainqueryconfig.toml
|
||||||
|
ls -lAh /etc/chainquery/
|
||||||
|
set_configs
|
||||||
|
else
|
||||||
|
echo "[INFO]: Found a copy of chainqueryconfig.toml in /etc/chainquery"
|
||||||
|
echo " Attempting to non destructively install any new environment configurations."
|
||||||
|
set_configs
|
||||||
|
fi
|
||||||
|
|
||||||
## 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
|
## 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/"
|
su -c "chainquery serve -c "/etc/chainquery/"" chainquery
|
||||||
|
|
173
contrib/lbrycrd-cloud-init.md
Normal file
173
contrib/lbrycrd-cloud-init.md
Normal file
|
@ -0,0 +1,173 @@
|
||||||
|
# lbrycrd cloud-init with systemd
|
||||||
|
|
||||||
|
Contributing Author: [EnigmaCurry](https://www.enigmacurry.com)
|
||||||
|
|
||||||
|
Last Update: April 17 2019
|
||||||
|
|
||||||
|
This is meant to be the easiest instructions possible for running a full lbrycrd
|
||||||
|
node on DigitalOcean. It's pretty much just cut-and-paste.
|
||||||
|
|
||||||
|
This should also work on any host that supports
|
||||||
|
[cloud-init](https://cloud-init.io/), but I've not tested it anywhere except for
|
||||||
|
DigitalOcean.
|
||||||
|
|
||||||
|
If you wish to use docker-compose, there is an [alternative
|
||||||
|
configuration](https://github.com/lbryio/lbry-docker/tree/master/lbrycrd)
|
||||||
|
for that. This tutorial will use cloud-init and systemd to control docker.
|
||||||
|
|
||||||
|
## It's easy to run your own full lbrycrd node
|
||||||
|
|
||||||
|
[![Video of creating lbrycrd droplet on DigitalOcean](https://spee.ch/@EnigmaCurry:d/lbrycrd-video-thumb.jpg)](https://spee.ch/@EnigmaCurry:d/lbrycrd-docker-cloud-init.mp4)
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
* Login to your DigitalOcean account and create a new droplet.
|
||||||
|
* Choose Ubuntu 18.04. (This will likely NOT work on other versions without tweaks.)
|
||||||
|
* Select a Standard droplet with 8GB of memory ($40 per month in 2019.)
|
||||||
|
* You may be able to get away with only 4GB.
|
||||||
|
* Select whatever datacenter you want.
|
||||||
|
* Mark the checkbox called `User data`, and paste the following into the box:
|
||||||
|
|
||||||
|
```
|
||||||
|
#cloud-config
|
||||||
|
|
||||||
|
## DigitalOcean user-data for Ubuntu 18.04 droplet
|
||||||
|
## Installs docker
|
||||||
|
## Setup systemd service for lbrycrd
|
||||||
|
## (This config just runs docker on vanilla Ubuntu,
|
||||||
|
## it uses systemd inplace of docker-compose or kubernetes.)
|
||||||
|
|
||||||
|
write_files:
|
||||||
|
- path: "/etc/lbry/lbrycrd.conf"
|
||||||
|
content: |
|
||||||
|
datadir=/data
|
||||||
|
port=9246
|
||||||
|
rpcuser=test
|
||||||
|
rpcpassword=test
|
||||||
|
rpcport=9245
|
||||||
|
regtest=0
|
||||||
|
server=1
|
||||||
|
txindex=1
|
||||||
|
daemon=0
|
||||||
|
listen=1
|
||||||
|
|
||||||
|
- path: "/etc/systemd/system/lbrycrd.service"
|
||||||
|
content: |
|
||||||
|
[Unit]
|
||||||
|
Description=lbrycrd docker container
|
||||||
|
After=snap.docker.dockerd.service
|
||||||
|
Requires=snap.docker.dockerd.service
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
TimeoutStartSec=0
|
||||||
|
ExecStartPre=-/snap/bin/docker stop lbrycrd
|
||||||
|
ExecStart=/snap/bin/docker run \
|
||||||
|
--rm \
|
||||||
|
--name lbrycrd \
|
||||||
|
-p 9246:9246 \
|
||||||
|
-p 127.0.0.1:9245:9245 \
|
||||||
|
--mount type=volume,source=lbrycrd-data,target=/data \
|
||||||
|
--mount type=bind,source=/etc/lbry/lbrycrd.conf,target=/etc/lbry/lbrycrd.conf \
|
||||||
|
--hostname lbrycrd \
|
||||||
|
-e RUN_MODE=default \
|
||||||
|
lbry/lbry-docker:lbrycrd-production
|
||||||
|
ExecStop=/snap/bin/docker stop lbrycrd
|
||||||
|
Restart=always
|
||||||
|
RestartSec=120
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
|
|
||||||
|
- path: "/root/.bash_aliases"
|
||||||
|
content: |
|
||||||
|
alias lbrycrd-cli="docker exec lbrycrd lbrycrd-cli -conf=/etc/lbry/lbrycrd.conf"
|
||||||
|
|
||||||
|
runcmd:
|
||||||
|
- apt-get update
|
||||||
|
- DEBIAN_FRONTEND=noninteractive apt-get -y upgrade
|
||||||
|
- snap install docker
|
||||||
|
- until /snap/bin/docker ps; do echo "Waiting for docker startup..."; sleep 1; done; echo "Docker is up."
|
||||||
|
- /snap/bin/docker volume create lbrycrd-data
|
||||||
|
- systemctl enable --now lbrycrd
|
||||||
|
- echo "Good to go."
|
||||||
|
```
|
||||||
|
* Select your SSH key so you can login.
|
||||||
|
* Give it a good hostname.
|
||||||
|
* Click Create.
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
### How to administer the system
|
||||||
|
|
||||||
|
Copy the IP address from the droplet status page, SSH into the droplet as root
|
||||||
|
using the same SSH key you configured for the droplet.
|
||||||
|
|
||||||
|
The config file is in `/etc/lbry/lbrycrd.conf` on the host.
|
||||||
|
|
||||||
|
The systemd service is called `lbrycrd`, in
|
||||||
|
`/etc/systemd/system/lbrycrd.service`. It is preconfigured to start on system
|
||||||
|
startup.
|
||||||
|
|
||||||
|
#### Monitor the installer log
|
||||||
|
|
||||||
|
You can tail the log to monitor the install progress:
|
||||||
|
|
||||||
|
```
|
||||||
|
tail -f /var/log/cloud-init-output.log
|
||||||
|
```
|
||||||
|
|
||||||
|
Wait for the final `Good to go` message to know that the installer has finished.
|
||||||
|
|
||||||
|
#### Check the status of the systemd service
|
||||||
|
|
||||||
|
You can interact with systemd using `systemctl` (status, start, stop, restart,
|
||||||
|
etc.) and `journalctl` (logging) tools.
|
||||||
|
|
||||||
|
```
|
||||||
|
systemctl status lbrycrd
|
||||||
|
```
|
||||||
|
|
||||||
|
```
|
||||||
|
journalctl --unit lbrycrd
|
||||||
|
```
|
||||||
|
|
||||||
|
[Here is a tutorial to get you familiarized with
|
||||||
|
systemd](https://www.digitalocean.com/community/tutorials/systemd-essentials-working-with-services-units-and-the-journal)
|
||||||
|
|
||||||
|
#### Check the container
|
||||||
|
|
||||||
|
You can get the same information directly from docker:
|
||||||
|
|
||||||
|
```
|
||||||
|
docker ps
|
||||||
|
```
|
||||||
|
|
||||||
|
```
|
||||||
|
docker logs lbrycrd
|
||||||
|
```
|
||||||
|
|
||||||
|
### Utilize lbrycrd-cli
|
||||||
|
|
||||||
|
You can use lbrycrd-cli from the host console. A bash alias has been added to
|
||||||
|
/root/.bash_aliases that invokes the lbrycrd-cli inside the running container.
|
||||||
|
|
||||||
|
```
|
||||||
|
$ lbrycrd-cli getinfo
|
||||||
|
{
|
||||||
|
"version": 120400,
|
||||||
|
"protocolversion": 70013,
|
||||||
|
"walletversion": 60000,
|
||||||
|
"balance": 0.00000000,
|
||||||
|
"blocks": 551965,
|
||||||
|
"timeoffset": 0,
|
||||||
|
"connections": 12,
|
||||||
|
"proxy": "",
|
||||||
|
"difficulty": 739465688254.7942,
|
||||||
|
"testnet": false,
|
||||||
|
"keypoololdest": 1555360604,
|
||||||
|
"keypoolsize": 101,
|
||||||
|
"paytxfee": 0.00000000,
|
||||||
|
"relayfee": 0.00001000,
|
||||||
|
"errors": ""
|
||||||
|
}
|
||||||
|
```
|
1
lbrycrd/.gitignore
vendored
1
lbrycrd/.gitignore
vendored
|
@ -1 +1,2 @@
|
||||||
data/.lbrycrd
|
data/.lbrycrd
|
||||||
|
regtest/data
|
||||||
|
|
|
@ -1,45 +1,30 @@
|
||||||
## This base image is for running latest lbrycrdd
|
FROM ubuntu:18.04 as prep
|
||||||
# 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"
|
LABEL MAINTAINER="leopere [at] nixc [dot] us"
|
||||||
|
## TODO: Implement version pinning. `apt-get install curl=<version>`
|
||||||
|
RUN apt-get update && \
|
||||||
|
apt-get -y install unzip curl build-essential && \
|
||||||
|
apt-get autoclean -y && \
|
||||||
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
WORKDIR /
|
||||||
|
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
|
||||||
|
COPY stuff/start.sh start
|
||||||
|
COPY stuff/healthcheck.sh healthcheck
|
||||||
|
COPY stuff/fix-permissions.c fix-permissions.c
|
||||||
|
RUN curl -L -o ./lbrycrd-linux.zip $(curl -s https://api.github.com/repos/lbryio/lbrycrd/releases | grep -F 'lbrycrd-linux.zip' | grep download | head -n 1 | cut -d'"' -f4) && \
|
||||||
|
unzip ./lbrycrd-linux.zip && \
|
||||||
|
gcc fix-permissions.c -o fix-permissions && \
|
||||||
|
chmod +x ./lbrycrdd ./lbrycrd-cli ./lbrycrd-tx ./start ./healthcheck ./fix-permissions
|
||||||
|
|
||||||
|
FROM ubuntu:18.04 as app
|
||||||
|
COPY --from=prep /lbrycrdd /lbrycrd-cli /lbrycrd-tx /start /healthcheck /fix-permissions /usr/bin/
|
||||||
RUN addgroup --gid 1000 lbrycrd && \
|
RUN addgroup --gid 1000 lbrycrd && \
|
||||||
adduser lbrycrd --uid 1000 --gid 1000 --gecos GECOS --shell /bin/bash --disabled-password --home /data && \
|
adduser lbrycrd --uid 1000 --gid 1000 --gecos GECOS --shell /bin/bash --disabled-password --home /data && \
|
||||||
apt-get update && \
|
chmod a+s /usr/bin/fix-permissions
|
||||||
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 stuff/debugpaste-it.sh /usr/local/bin/debugpaste-it
|
|
||||||
COPY stuff/start.sh /usr/local/bin/start
|
|
||||||
COPY stuff/docker-entrypoint.sh /usr/local/bin/docker-entrypoint
|
|
||||||
COPY stuff/healthcheck.sh /usr/local/bin/healthcheck
|
|
||||||
|
|
||||||
# USER lbrycrd
|
|
||||||
# RUN mkdir /data
|
|
||||||
VOLUME ["/data"]
|
VOLUME ["/data"]
|
||||||
WORKDIR /data
|
WORKDIR /data
|
||||||
|
|
||||||
## TODO: Implement healthcheck.
|
## TODO: Implement healthcheck.
|
||||||
# HEALTHCHECK ["healthcheck"]
|
# HEALTHCHECK ["healthcheck"]
|
||||||
|
EXPOSE 9246 9245
|
||||||
|
|
||||||
## Exposing daemon port and RPC port
|
USER lbrycrd
|
||||||
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"]
|
CMD ["start"]
|
||||||
|
|
|
@ -18,6 +18,8 @@ services:
|
||||||
- "traefik.expose=false"
|
- "traefik.expose=false"
|
||||||
environment:
|
environment:
|
||||||
RUN_MODE: chainquery
|
RUN_MODE: chainquery
|
||||||
|
env_file:
|
||||||
|
- env
|
||||||
expose:
|
expose:
|
||||||
- 9245
|
- 9245
|
||||||
- 9246
|
- 9246
|
||||||
|
|
|
@ -4,11 +4,11 @@ COMPOSE_PROJECT_NAME=lbrycrd
|
||||||
## Lbrycrd ##
|
## Lbrycrd ##
|
||||||
#############
|
#############
|
||||||
## TODO: The credentials are a formality but we should randomize these with magic.
|
## TODO: The credentials are a formality but we should randomize these with magic.
|
||||||
RPC_USER=${RPC_USER=lbryrpc}
|
RPC_USER=lbryrpc
|
||||||
RPC_PASSWORD=${RPC_PASSWORD:-changeme}
|
RPC_PASSWORD=changeme
|
||||||
UID=$UID
|
UID=$UID
|
||||||
GID=$UID
|
GID=$UID
|
||||||
|
|
||||||
## This should be the internal container IP from which you'll be calling the RPC for Lbrycrdd from.
|
## This should be the internal container IP from which you'll be calling the RPC for Lbrycrdd from.
|
||||||
## TODO: make this more dynamic before we move to scalability
|
## TODO: make this more dynamic before we move to scalability
|
||||||
RPC_ALLOW_IP=${RPC_ALLOW_IP:-10.5.1.3}
|
RPC_ALLOW_IP=10.5.1.3
|
41
lbrycrd/regtest/Dockerfile
Normal file
41
lbrycrd/regtest/Dockerfile
Normal file
|
@ -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.4.0/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"]
|
5
lbrycrd/regtest/advance_blocks.sh
Executable file
5
lbrycrd/regtest/advance_blocks.sh
Executable file
|
@ -0,0 +1,5 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
while true; do
|
||||||
|
lbrycrd-cli -conf=/data/.lbrycrd/lbrycrd.conf generate 1 >> /tmp/output.log
|
||||||
|
sleep 2
|
||||||
|
done
|
17
lbrycrd/regtest/docker-compose.yml
Normal file
17
lbrycrd/regtest/docker-compose.yml
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
version: '3.4'
|
||||||
|
|
||||||
|
services:
|
||||||
|
#############
|
||||||
|
## Lbrycrd ##
|
||||||
|
#############
|
||||||
|
lbrycrd:
|
||||||
|
image: tiger5226/regtest
|
||||||
|
restart: always
|
||||||
|
labels:
|
||||||
|
- "traefik.expose=true"
|
||||||
|
ports:
|
||||||
|
- "11336:9246"
|
||||||
|
- "11337:11337"
|
||||||
|
## host volumes for persistent data such as wallet private keys.
|
||||||
|
volumes:
|
||||||
|
- "./data:/data"
|
13
lbrycrd/regtest/docker-entrypoint.sh
Executable file
13
lbrycrd/regtest/docker-entrypoint.sh
Executable file
|
@ -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
|
34
lbrycrd/regtest/start.sh
Executable file
34
lbrycrd/regtest/start.sh
Executable file
|
@ -0,0 +1,34 @@
|
||||||
|
#!/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
|
||||||
|
|
||||||
|
#nohup advance &>/dev/null &
|
||||||
|
su -c "lbrycrdd -conf=/data/.lbrycrd/lbrycrd.conf" lbrycrd
|
||||||
|
|
4
lbrycrd/regtest/upload.sh
Executable file
4
lbrycrd/regtest/upload.sh
Executable file
|
@ -0,0 +1,4 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
docker build -t tiger5226/regtest:latest .
|
||||||
|
docker push tiger5226/regtest:latest
|
9
lbrycrd/stuff/fix-permissions.c
Normal file
9
lbrycrd/stuff/fix-permissions.c
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
#include <unistd.h>
|
||||||
|
int main() {
|
||||||
|
// This program needs to run with setuid == root
|
||||||
|
// This needs to be in a compiled language because you cannot setuid bash scripts
|
||||||
|
setuid(0);
|
||||||
|
execle("/bin/bash", "bash", "-c",
|
||||||
|
"/bin/chown -R lbrycrd:lbrycrd /data && /bin/chmod -R 755 /data/",
|
||||||
|
(char*) NULL, (char*) NULL);
|
||||||
|
}
|
|
@ -1,47 +1,40 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
# ## ToDo: Get a test case to see if this is the first run or a repeat run.
|
CONFIG_PATH=/etc/lbry/lbrycrd.conf
|
||||||
# ## If it's a first run you need to do a full index including all transactions
|
if [ -f "$CONFIG_PATH" ]
|
||||||
# ## tx index creates an index of every single transaction in the block history if
|
then
|
||||||
# ## not specified it will only create an index for transactions that are related to the wallet or have unspent outputs.
|
echo "Using the config file that was mounted into the container."
|
||||||
# ## This is specific to chainquery.
|
else
|
||||||
|
echo "Creating a fresh config file from environment variables."
|
||||||
|
## Set config params
|
||||||
|
mkdir -p `dirname $CONFIG_PATH`
|
||||||
|
echo "rpcuser=$RPC_USER" > $CONFIG_PATH
|
||||||
|
echo "rpcpassword=$RPC_PASSWORD" >> $CONFIG_PATH
|
||||||
|
echo "rpcallowip=$RPC_ALLOW_IP" >> $CONFIG_PATH
|
||||||
|
echo "rpcport=9245" >> $CONFIG_PATH
|
||||||
|
echo "rpcbind=0.0.0.0" >> $CONFIG_PATH
|
||||||
|
#echo "bind=0.0.0.0" >> $CONFIG_PATH
|
||||||
|
fi
|
||||||
|
|
||||||
## Ensure perms are correct prior to running main binary
|
## Ensure perms are correct prior to running main binary
|
||||||
mkdir -p /data/.lbrycrd
|
/usr/bin/fix-permissions
|
||||||
chown -R lbrycrd:lbrycrd /data
|
|
||||||
chmod -R 755 /data/
|
|
||||||
|
|
||||||
## TODO: Consider a config directory for future magic.
|
## You can optionally specify a run mode if you want to use lbry defined presets for compatibility.
|
||||||
# chown -R 1000:1000 /etc/lbrycrd
|
case $RUN_MODE in
|
||||||
# chmod -R 755 /etc/lbrycrd
|
|
||||||
rm -f /var/run/lbrycrd.pid
|
|
||||||
|
|
||||||
|
|
||||||
## Set config params
|
|
||||||
## TODO: Make this more automagic in the future.
|
|
||||||
echo "rpcuser=lbryrpc\nrpcpassword=${RPC_PASSWORD:-changeme}" > /data/.lbrycrd/lbrycrd.conf
|
|
||||||
echo "rpcallowip=${RPC_ALLOW_IP:-10.6.1.3}" >> /data/.lbrycrd/lbrycrd.conf
|
|
||||||
echo "rpcuser=${RPC_USER:-lbryrpc}" >> /data/.lbrycrd/lbrycrd.conf
|
|
||||||
|
|
||||||
## Control this invocation through envvar.
|
|
||||||
case ${RUN_MODE:-default} in
|
|
||||||
default )
|
default )
|
||||||
su -c "lbrycrdd -server -conf=/data/.lbrycrd/ -printtoconsole" lbrycrd
|
lbrycrdd -server -conf=$CONFIG_PATH -printtoconsole
|
||||||
;;
|
;;
|
||||||
|
## 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 generally specific to chainquery.
|
||||||
reindex )
|
reindex )
|
||||||
su -c "lbrycrdd -server -txindex -reindex -conf=/data/.lbrycrd/ -printtoconsole" lbrycrd
|
## Apply this RUN_MODE in the case you need to update a dataset. NOTE: you do not need to use `RUN_MODE reindex` for more than one complete run.
|
||||||
|
lbrycrdd -server -txindex -reindex -conf=$CONFIG_PATH -printtoconsole
|
||||||
;;
|
;;
|
||||||
chainquery )
|
chainquery )
|
||||||
su -c "lbrycrdd -server -txindex -conf=/data/.lbrycrd/ -printtoconsole" lbrycrd
|
## If your only goal is to run Chainquery against this instance of lbrycrd and you're starting a
|
||||||
|
## fresh local dataset use this run mode.
|
||||||
|
lbrycrdd -server -txindex -conf=$CONFIG_PATH -printtoconsole
|
||||||
;;
|
;;
|
||||||
esac
|
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/} \
|
|
||||||
# -pid=${PID_FILE:/var/run/lbrycrdd.pid} \
|
|
||||||
# -rpcport=${RPC_PORT:-9245} \
|
|
||||||
# -rpcpassword=${RPC_PASSWORD:-changeme} \
|
|
||||||
# -rpcuser=${RPC_USER:-lbryrpc} \
|
|
||||||
# -rpcallowip=${RPC_ALLOW_IP:-10.6.1.3}
|
|
||||||
|
|
40
lbrycrd/testnet/Dockerfile
Normal file
40
lbrycrd/testnet/Dockerfile
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
## 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.3.1/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 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"]
|
7
lbrycrd/testnet/README.md
Normal file
7
lbrycrd/testnet/README.md
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
To run a local instance of testnet via docker:
|
||||||
|
|
||||||
|
1) clone this repository
|
||||||
|
|
||||||
|
2) Run `cd ./lbrycrd/testnet`
|
||||||
|
|
||||||
|
3) Run `docker-compose up -d`
|
17
lbrycrd/testnet/docker-compose.yml
Normal file
17
lbrycrd/testnet/docker-compose.yml
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
version: '3.4'
|
||||||
|
|
||||||
|
services:
|
||||||
|
#############
|
||||||
|
## Lbrycrd ##
|
||||||
|
#############
|
||||||
|
lbrycrd:
|
||||||
|
image: tiger5226/testnet
|
||||||
|
restart: always
|
||||||
|
labels:
|
||||||
|
- "traefik.expose=true"
|
||||||
|
ports:
|
||||||
|
- "11336:9246"
|
||||||
|
- "11337:11337"
|
||||||
|
## host volumes for persistent data such as wallet private keys.
|
||||||
|
volumes:
|
||||||
|
- "./data:/data"
|
13
lbrycrd/testnet/docker-entrypoint.sh
Executable file
13
lbrycrd/testnet/docker-entrypoint.sh
Executable file
|
@ -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
|
34
lbrycrd/testnet/start.sh
Executable file
34
lbrycrd/testnet/start.sh
Executable file
|
@ -0,0 +1,34 @@
|
||||||
|
#!/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 "testnet=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
|
||||||
|
|
||||||
|
#nohup advance &>/dev/null &
|
||||||
|
su -c "lbrycrdd -conf=/data/.lbrycrd/lbrycrd.conf" lbrycrd
|
||||||
|
|
4
lbrycrd/testnet/upload.sh
Executable file
4
lbrycrd/testnet/upload.sh
Executable file
|
@ -0,0 +1,4 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
docker build -t tiger5226/testnet:latest .
|
||||||
|
docker push tiger5226/testnet:latest
|
Loading…
Reference in a new issue