Compare commits

...

28 commits

Author SHA1 Message Date
Alex Grintsvayg
64405257a5
moved lbrycrd files into lbrycrd repo 2019-11-27 09:32:36 -05:00
Alex Grintsvayg
1eddbd86a3
simplify tags and Dockerfile name 2019-11-06 10:14:04 -05:00
Alex Grintsvayg
cf68868bf8
add snapshot download, fix binary name, drop chainquery runmode, small refactors 2019-11-04 15:16:00 -05:00
Dan Garthwaite
fced928089 Make healthcheck script executable 2019-10-10 11:14:28 -04:00
Dan Garthwaite
84b39abeb1 Allow env variable to override RPC port 2019-10-10 11:14:28 -04:00
Dan Garthwaite
b837de83cc Don't rebuild container when data/ has new data in it 2019-10-10 11:14:28 -04:00
Dan Garthwaite
8ba6173232 Use busybox wget to ping :6300 2019-10-10 11:14:28 -04:00
Dan Garthwaite
6c322f9fbd Fix IP range to match docker-compose 2019-10-10 11:14:28 -04:00
Dan Garthwaite
fd9ef0ebef Fix up ports for chainquery to talk to lbrycrd 2019-10-10 11:14:28 -04:00
Dan Garthwaite
ec3e9457b3 Add busybox-static to /usr/local/bin 2019-10-10 11:14:28 -04:00
Dan Garthwaite
e6eb37aefa Rewrite chainquery start script merge env with defaults 2019-10-10 11:14:28 -04:00
Dan Garthwaite
5f402ebc7a Changes to allow RUN_MODE=regtest to stuff/auto_advance.sh 2019-10-10 11:14:28 -04:00
Dan Garthwaite
f8ae8792e9 Working healthcheck in lbrycrd 2019-10-10 11:14:28 -04:00
Ryan McGuire
499e0f62da lbrynet: Follow redirects in curl to github API
Follow redirects
2019-07-28 20:31:22 -04:00
Leopere
734e06f704
Updated release URL reference 2019-07-28 14:37:05 -04:00
Leopere
f16039dc37
Set defaults and allowed for envvars from compose files. 2019-07-28 13:58:12 -04:00
Mark
ca8a827ca7
Update start.sh 2019-07-28 13:32:30 -04:00
Ryan McGuire
b5328aa0dc Adds dockerfile_image_tag.sh tool to tag docker image ids in git. 2019-07-12 13:31:26 -04:00
Mark
b1a2e9706e
Update the right port field 2019-07-11 20:52:12 -04:00
Leopere
782ffb3483
Changed RPC port. 2019-07-11 10:01:48 -04:00
Leopere
fd7c1b6bc2
Adding alternate port exposures. 2019-07-11 09:57:32 -04:00
Leopere
1befeb34d3
Cleared off example wallet ID 2019-07-10 22:53:37 -04:00
Leopere
56dbf8ba3a
Checklist cleanup in ISSUE_TEMPLATE 2019-07-10 22:50:21 -04:00
Ryan McGuire
baba45bf00 lbrynet: Add sample daemon_settings.yml 2019-06-27 14:17:25 -04:00
Ryan McGuire
33f3eeb8df lbrynet-multiarch-compiler: Add notes that a config file must be mounted. 2019-06-27 14:17:25 -04:00
Ryan McGuire
4f4a9c9aab k8s-lbry: Refactors package script to use github releases. 2019-06-27 14:14:47 -04:00
Ryan McGuire
dd1a889e52 Change repository links from EnigmaCurry to lbryio. 2019-06-27 14:14:47 -04:00
Ryan McGuire
410936047c LbryNet: removes external torba dependency 2019-06-27 14:09:12 -04:00
29 changed files with 258 additions and 415 deletions

View file

@ -36,12 +36,12 @@ Make sure that you're including the specific container your issue is in regards
<!-- Post your Unique LBC wallet RECEIVING address so that we can tip you ASAP -->
## This is my LBC wallet address for tips
bQmvEEfu3TsfcVEPy3SCY1L38gcvXHBiEs
{REPLACE ME WITH YOUR LBC RECIEVING ADDRESS}
**Checklist**:
<!-- Make sure you have completed the following steps (put an "X" between of brackets): -->
~~- [] I included a `debugpaste` link debugpastes only last 90 days from last time they were loaded in a browser.[Inclusion of debugpaste is WIP]~~
- [] I made sure there are no duplicates of this report [(Use Search)](https://github.com/lbryio/lbry-docker/issues?utf8=%E2%9C%93&q=is%3Aissue)
- [] I made sure I am using an up-to-date version of the container.
- [] I Made sure the bug/error is not caused by any other application.
- [] I have updated the wallet address in this issue from the one included to my own as I like getting paid for doing good and fun things in this world such as contributing to LBRY.
- [ ] I made sure there are no duplicates of this report [(Use Search)](https://github.com/lbryio/lbry-docker/issues?utf8=%E2%9C%93&q=is%3Aissue)
- [ ] I made sure I am using an up-to-date version of the container.
- [ ] I Made sure the bug/error is not caused by any other application.
- [ ] I have updated the wallet address in this issue from the one included to my own as I like getting paid for doing good and fun things in this world such as contributing to LBRY.

2
chainquery/.dockerignore Normal file
View file

@ -0,0 +1,2 @@
chainquery.z*
data/*

View file

@ -3,22 +3,21 @@
FROM ubuntu:18.04 as prep
LABEL MAINTAINER="leopere [at] nixc [dot] us"
RUN apt-get update && \
apt-get -y install unzip curl && \
apt-get -y install unzip curl busybox-static && \
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
RUN curl -L -o /chainquery.zip $(curl -s https://api.github.com/repos/lbryio/chainquery/releases | grep -F 'Linux_x86_64.zip' | grep download | head -n 1 | cut -d'"' -f4) && \
unzip /chainquery.zip && \
rm /chainquery.zip
RUN curl --progress-bar -L -o /chainquery https://build.lbry.io/chainquery/branch-master/chainquery && \
chmod +x /chainquery /start /healthcheck
FROM ubuntu:18.04 as app
ADD https://raw.githubusercontent.com/lbryio/chainquery/master/config/default/chainqueryconfig.toml /etc/lbry/chainqueryconfig.toml.orig
RUN adduser chainquery --gecos GECOS --shell /bin/bash --disabled-password --home /home/chainquery && \
chown -R chainquery:chainquery /etc/lbry
COPY --from=prep ./healthcheck /chainquery /start /usr/bin/
COPY --from=prep ./healthcheck /chainquery /start /bin/busybox /usr/bin/
HEALTHCHECK --interval=1m --timeout=30s \
CMD healthcheck
EXPOSE 6300

View file

@ -8,16 +8,13 @@ services:
###########
## MYSQL ##
###########
## MariaDB is currently not supported and neither is later versions of MySQL this may change.
## https://hub.docker.com/r/_/mariadb/
## Work is underway to support percona
mysql:
image: mysql:5.7.23
restart: always
networks:
lbry-network:
ipv4_address: 10.6.1.10
aliases:
- mysql
env_file:
- ../environment/chainquery.env
expose:
@ -26,6 +23,10 @@ services:
## and not share it with everyone at least eventually.
ports:
- 3306:3306
healthcheck:
test: ["CMD-SHELL", 'mysql --database=$$MYSQL_DATABASE --password=$$MYSQL_ROOT_PASSWORD --execute="SELECT count(table_name) > 0 FROM information_schema.tables;" --skip-column-names -B']
interval: 5s
retries: 12
volumes:
- ../persist/chainquery/db:/var/lib/mysql
## This one may need to be tweaked based on where you run this docker-compose from.
@ -35,14 +36,16 @@ services:
## Chainquery ##
################
chainquery:
image: lbryio/lbry-docker:linux-x86_64-production
build:
context: .
dockerfile: Dockerfile-linux-x86_64-production
restart: always
networks:
lbry-network:
ipv4_address: 10.6.1.3
env_file:
- env
- ../environment/lbrycrd.env
- ../environment/chainquery.env
labels:
- "traefik.expose=false"
expose:
@ -52,5 +55,5 @@ services:
depends_on:
- mysql
## TODO: Uncomment this in a docker-compose.override.yml to allow for external configurations.
volumes:
- ../persist/chainquery/config/chainqueryconfig.toml:/etc/chainquery/chainqueryconfig.toml
#volumes:
# - ../persist/chainquery/config/chainqueryconfig.toml:/etc/chainquery/chainqueryconfig.toml

View file

@ -1,2 +1,2 @@
#!/usr/bin/env bash
curl --fail http://localhost:6300/api/status || exit 1
#!/bin/sh
busybox wget -O- http://localhost:6300/api/status

View file

@ -1,51 +1,32 @@
#!/usr/bin/env bash
## Config setup
# Override defaults with environment variables
CONFIGFILE="${CONFIGFILE:-/etc/lbry/chainqueryconfig.toml}"
DEBUGMODE="${DEBUGMODE:-false}"
RPC_USER="${RPC_USER:-lbry}"
RPC_PASSWORD="${RPC_PASSWORD:-lbry}"
RPC_HOST="${RPC_HOST:-localhost}"
RPC_PORT="${RPC_PORT:-9245}"
MYSQL_SERVER="${MYSQL_SERVER:-localhost}"
MYSQL_PORT="${MYSQL_PORT:-3306}"
MYSQL_USER="${MYSQL_USER:-lbry}"
MYSQL_PASSWORD="${MYSQL_PASSWORD:-lbry}"
MYSQL_DATABASE="${MYSQL_DATABASE:-chainquery}"
## 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/lbry/chainqueryconfig.toml
done
echo "Reading config for debugging."
cat /etc/lbry/chainqueryconfig.toml
exec_chainquery() {
CONFIG_DIR=$(dirname "${CONFIGFILE}")
exec chainquery serve --configpath "$CONFIG_DIR"
}
if [[ ! -f /etc/lbry/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/lbry/chainqueryconfig.toml.orig /etc/lbry/chainqueryconfig.toml"
cp -v /etc/lbry/chainqueryconfig.toml.orig /etc/lbry/chainqueryconfig.toml
ls -lAh /etc/lbry/
set_configs
else
if [[ -f "$CONFIGFILE" ]]; then
echo "[INFO]: Found a copy of chainqueryconfig.toml in /etc/lbry"
exec_chainquery
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
chainquery serve --configpath "/etc/lbry/"
cat << EOF >> "${CONFIGFILE}"
DEBUGMODE="${DEBUGMODE}"
LBRYCRDURL="rpc://${RPC_USER}:${RPC_PASSWORD}@${RPC_HOST}:${RPC_PORT}"
MYSQLDSN="${MYSQL_USER}:${MYSQL_PASSWORD}@tcp(${MYSQL_SERVER}:${MYSQL_PORT})/$MYSQL_DATABASE"
APIMYSQLDSN="${MYSQL_USER}:${MYSQL_PASSWORD}@tcp(${MYSQL_SERVER}:${MYSQL_PORT})/$MYSQL_DATABASE"
EOF
exec_chainquery

View file

@ -1,4 +1,3 @@
index.yaml
*.tgz
values-dev.yaml
values-staging.yaml

View file

@ -0,0 +1,4 @@
index.yaml
kick-ascii
.gitignore
completion.bash.inc

View file

@ -146,7 +146,7 @@ cd $HOME/k8s-lbry-test
Download `run.sh` to this same directory:
```
curl -Lo run.sh https://raw.githubusercontent.com/EnigmaCurry/lbry-docker/k8s-lbry/contrib/k8s-lbry/run.sh
curl -Lo run.sh https://raw.githubusercontent.com/lbryio/lbry-docker/master/contrib/k8s-lbry/run.sh
chmod a+x run.sh
```

View file

@ -0,0 +1,44 @@
apiVersion: v1
entries:
k8s-lbry:
- apiVersion: v1
appVersion: "1.0"
created: "2019-06-16T20:45:37.131503885-04:00"
description: LBRY on Kubernetes with Helm
digest: 0e28fad6b25fcbf79ea30390a65340c50422e84408a86f6e366abdfb1c471cf0
home: https://github.com/lbryio/lbry-docker/tree/master/contrib/k8s-lbry
maintainers:
- email: ryan@enigmacurry.com
name: EnigmaCurry
- email: leopere [at] nixc [dot] us
name: Leopere
name: k8s-lbry
urls:
- https://github.com/lbryio/lbry-docker/releases/download/k8s-lbry-0.1.5/k8s-lbry-0.1.5.tgz
version: 0.1.5
mysql:
- appVersion: 5.7.14
created: "2019-06-16T20:45:37.133445969-04:00"
description: Fast, reliable, scalable, and easy to use open-source relational
database system.
digest: dacef52f53a395059131064cfdc7ae39ae2d7be2580440575d1532dfaa3fd2b8
engine: gotpl
home: https://www.mysql.com/
icon: https://www.mysql.com/common/logos/logo-mysql-170x115.png
keywords:
- mysql
- database
- sql
maintainers:
- email: o.with@sportradar.com
name: olemarkus
- email: viglesias@google.com
name: viglesiasce
name: mysql
sources:
- https://github.com/kubernetes/charts
- https://github.com/docker-library/mysql
urls:
- charts/mysql-0.19.0.tgz
version: 0.19.0
generated: "2019-06-16T20:45:36.911335647-04:00"

View file

@ -16,10 +16,10 @@ CHART=${CHART:-lbry/k8s-lbry}
## VALUES - The path to your configured helm values.yaml:
VALUES=${VALUES:-$BASEDIR/values-dev.yaml}
DEFAULT_VALUES_URL=${DEFAULT_VALUES_URL:-https://raw.githubusercontent.com/EnigmaCurry/lbry-docker/k8s-lbry/contrib/k8s-lbry/values.yaml}
DEFAULT_VALUES_URL=${DEFAULT_VALUES_URL:-https://raw.githubusercontent.com/lbryio/lbry-docker/master/contrib/k8s-lbry/values.yaml}
## HELM_REPO - The stable helm chart repository for this chart:
HELM_REPO=${HELM_REPO:-https://k8s-lbry.sfo2.digitaloceanspaces.com}
HELM_REPO=${HELM_REPO:-https://lbryio.github.io/lbry-docker/contrib/k8s-lbry/}
## TILLER_HOST - The host that runs tiller
TILLER_HOST=${TILLER_HOST:-localhost}
@ -32,9 +32,11 @@ CERTMANAGER_VERSION=v0.7.1
NGINX_ENABLE_HTTPS=${NGINX_ENABLE_HTTPS:-false}
## Mysql Database snapshot download url:
## TODO: Use lbry owned bucket for this:
CHAINQUERY_SNAPSHOT_URL=${CHAINQUERY_SNAPSHOT_URL:-https://lbry-chainquery-mysql-dump.sfo2.digitaloceanspaces.com/chainquery_height_560900.mysql-backup.tar.gz}
## lbrycrd snapshot download url:
## TODO: Use lbry owned bucket for this:
LBRYCRD_SNAPSHOT_URL=${LBRYCRD_SNAPSHOT_URL:-https://lbry-chainquery-mysql-dump.sfo2.digitaloceanspaces.com/lbrycrd-566588-snapshot.tar.gz}
LBRYCRD_RPC_USER=${LBRYCRD_RPC_USER:-lbry}
@ -44,9 +46,6 @@ LBRYCRD_RPC_PASSWORD=${LBRYCRD_RPC_PASSWORD:-lbry}
## defaults to $NAMESPACE (k8s-lbry)
RUN_ALIAS=${RUN_ALIAS:-$NAMESPACE}
## Package bucket (ignore this, only used by developer of this package)
PACKAGE_BUCKET=${PACKAGE_BUCKET:-"s3://k8s-lbry"}
exe() { ( echo "## $*"; $*; ) }
setup() {
@ -285,35 +284,16 @@ package() {
PACKAGE="k8s-lbry-$1.tgz"
## Build Helm package repository and upload to s3
if which s3cmd > /dev/null; then
if s3cmd info $PACKAGE_BUCKET > /dev/null; then
# Download all remote releases, to re-include in new index.yaml
exe s3cmd sync $PACKAGE_BUCKET .
# Check if release already exists
s3_url="$PACKAGE_BUCKET/$PACKAGE"
if s3cmd info "$s3_url"; then
echo "$s3_url already exists. Aborting."
exit 1
fi
# Package release and rebuild repository
exe helm dependency update
exe helm package .
exe helm repo index .
# Publish packages to s3
exe s3cmd put --acl-public index.yaml "$PACKAGE" $PACKAGE_BUCKET
exe s3cmd put --acl-public charts/*.tgz $PACKAGE_BUCKET/charts/
else
echo "s3cmd is not setup, run s3cmd --configure"
exit 1
fi
else
echo "s3cmd is not installed"
exit 1
fi
# Package release and rebuild repository
exe helm dependency update
exe helm package .
exe helm repo index --merge index.yaml .
## Replace URLs in index to point to github releases:
sed -i 's|- k8s-lbry-\(.*\).tgz$|- https://github.com/lbryio/lbry-docker/releases/download/k8s-lbry-\1/k8s-lbry-\1.tgz|g' index.yaml
echo "Created package: $PACKAGE"
echo "Next steps: "
echo " 1) Create new github release (https://github.com/lbryio/lbry-docker/releases) and upload $PACKAGE"
echo " 2) Commit index.yaml and push to github"
)
}

View file

@ -3,14 +3,14 @@
#########################
## Chainquery Settings ##
#########################
RPC_ALLOW_IP=10.5.1.3
RPC_ALLOW_IP=10.6.1.3
DEBUGMODE=false
#################
## Mysql Creds ##
#################
MYSQL_SERVER=10.5.1.10
MYSQL_USER=chainquery
MYSQL_PASSWORD=changeme
MYSQL_SERVER=10.6.1.10
MYSQL_USER=lbry
MYSQL_PASSWORD=lbry
MYSQL_DATABASE=chainquery
MYSQL_ROOT_PASSWORD=changeme
MYSQL_ROOT_PASSWORD=lbry

View file

@ -10,4 +10,4 @@ GID=$UID
## 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
RPC_ALLOW_IP=10.5.1.3
RPC_ALLOW_IP=10.6.1.3

View file

@ -1,33 +0,0 @@
FROM ubuntu:18.04 as prep
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/advance_blocks.sh advance
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 ./advance
FROM ubuntu:18.04 as app
COPY --from=prep /lbrycrdd /lbrycrd-cli /lbrycrd-tx /start /healthcheck /fix-permissions /advance /usr/bin/
RUN addgroup --gid 1000 lbrycrd && \
adduser lbrycrd --uid 1000 --gid 1000 --gecos GECOS --shell /bin/bash --disabled-password --home /data && \
mkdir /etc/lbry && \
chown lbrycrd /etc/lbry && \
chmod a+s /usr/bin/fix-permissions
VOLUME ["/data"]
WORKDIR /data
## TODO: Implement healthcheck.
# HEALTHCHECK ["healthcheck"]
EXPOSE 9246 9245
USER lbrycrd
CMD ["start"]

View file

@ -1,48 +1 @@
# lbrycrd
# Docker image tags
`lbry/lbrycrd`
`[linux-x86_64-production](https://github.com/lbryio/lbry-docker/blob/master/lbrycrd/Dockerfile-linux-x86_64-production)` (Latest release)
## Configuration
The lbrycrd container comes with a default configuration you can use for
production. Extra configuration is optional.
The container includes a `start` script that offers a flexible configuration
style. It allows you to mount your own `lbrycrd.conf` file, or use environment
variables, or a mix of both.
### Environment variables
The environment variables override the values in the mounted config file. If no
mounted config file exists, these variables are used to create a fresh config.
* `PORT` - The main lbrycrd port
* `RPC_USER` - The rpc user
* `RPC_PASSWORD` - The rpc user's password
* `RPC_ALLOW_IP` - the subnet that is allowed rpc access
* `RPC_PORT` - The port to bind the rpc service to
* `RPC_BIND` - The ip address to bind the rpc service to
### Example run commands
Running the default configuration:
```
docker run --rm -it -e RUN_MODE=default lbry/lbrycrd:linux-x86_64-production
```
Running with RPC password changed:
```
docker run --rm -it -e RUN_MODE=default -e RPC_PASSWORD=hunter2 lbry/lbrycrd:linux-x86_64-production
```
Running with a config file but with the RPC password still overridden:
```
docker run --rm -it -v /path/to/lbrycrd.conf:/etc/lbry/lbrycrd.conf -e RUN_MODE=default -e RPC_PASSWORD=hunter2 lbry/lbrycrd:linux-x86_64-production
```
# moved to https://github.com/lbryio/lbrycrd/tree/master/packaging/docker-for-binary

View file

@ -1,26 +0,0 @@
version: '3.4'
networks:
lbry-network:
external: true
services:
#############
## Lbrycrd ##
#############
lbrycrd:
build: .
restart: always
networks:
lbry-network:
ipv4_address: 10.6.1.2
environment:
RUN_MODE: default
env_file:
- env
expose:
- 9245
- 9246
## host volumes for persistent data such as wallet private keys.
volumes:
- "../persist/data:/data"

View file

@ -1,17 +0,0 @@
version: '3.4'
services:
#############
## Lbrycrd ##
#############
lbrycrd:
image: lbry/lbrycrd:linux-x86_64-production
restart: always
ports:
- "11336:9246"
- "11337:11337"
## host volumes for persistent data such as wallet private keys.
volumes:
- "../persist/data:/data"
environment:
- RUN_MODE=regtest

View file

@ -1,17 +0,0 @@
version: '3.4'
services:
#############
## Lbrycrd ##
#############
lbrycrd:
image: lbry/lbrycrd:linux-x86_64-production
restart: always
ports:
- "11336:9246"
- "11337:11337"
## host volumes for persistent data such as wallet private keys.
volumes:
- "../persist/data:/data"
environment:
- RUN_MODE=testnet

View file

@ -1,5 +0,0 @@
#!/usr/bin/env bash
while true; do
lbrycrd-cli -conf=/data/.lbrycrd/lbrycrd.conf generate 1 >> /tmp/output.log
sleep 2
done

View file

@ -1,12 +0,0 @@
COMPOSE_PROJECT_NAME=lbrycrd
#############
## Lbrycrd ##
#############
## TODO: The credentials are a formality but we should randomize these with magic.
RPC_USER=${RPC_USER=lbryrpc}
RPC_PASSWORD=${RPC_PASSWORD:-changeme}
## 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
RPC_ALLOW_IP=${RPC_ALLOW_IP:-10.6.1.3}

View file

@ -1,9 +0,0 @@
#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);
}

View file

@ -1,4 +0,0 @@
## 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

View file

@ -1,114 +0,0 @@
#!/usr/bin/env bash
CONFIG_PATH=/etc/lbry/lbrycrd.conf
function override_config_option() {
# Remove existing config line from a config file
# and replace with environment fed value.
# Does nothing if the variable does not exist.
# var Name of ENV variable
# option Name of config option
# config Path of config file
local var=$1 option=$2 config=$3
if [[ -v $var ]]; then
# Remove the existing config option:
sed -i "/^$option\W*=/d" $config
# Add the value from the environment:
echo "$option=${!var}" >> $config
fi
}
function set_config() {
if [ -d "$CONFIG_PATH" ]; then
echo "$CONFIG_PATH is a directory when it should be a file."
exit 1
elif [ -f "$CONFIG_PATH" ]; then
echo "Merging the mounted config file with environment variables."
local MERGED_CONFIG=/tmp/lbrycrd_merged.conf
cat $CONFIG_PATH > $MERGED_CONFIG
echo "" >> $MERGED_CONFIG
override_config_option PORT port $MERGED_CONFIG
override_config_option RPC_USER rpcuser $MERGED_CONFIG
override_config_option RPC_PASSWORD rpcpassword $MERGED_CONFIG
override_config_option RPC_ALLOW_IP rpcallowip $MERGED_CONFIG
override_config_option RPC_PORT rpcport $MERGED_CONFIG
override_config_option RPC_BIND rpcbind $MERGED_CONFIG
# Make the new merged config file the new CONFIG_PATH
# This ensures that the original file the user mounted remains unmodified
CONFIG_PATH=$MERGED_CONFIG
else
echo "Creating a fresh config file from environment variables."
## Set config params
echo "port=${PORT=9246}" > $CONFIG_PATH
echo "rpcuser=${RPC_USER=lbry}" >> $CONFIG_PATH
echo "rpcpassword=${RPC_PASSWORD=lbry}" >> $CONFIG_PATH
echo "rpcallowip=${RPC_ALLOW_IP=127.0.0.1/24}" >> $CONFIG_PATH
echo "rpcport=${RPC_PORT=9245}" >> $CONFIG_PATH
echo "rpcbind=${RPC_BIND=0.0.0.0}" >> $CONFIG_PATH
fi
echo "Config: "
cat $CONFIG_PATH
}
## Ensure perms are correct prior to running main binary
/usr/bin/fix-permissions
## You can optionally specify a run mode if you want to use lbry defined presets for compatibility.
case $RUN_MODE in
default )
set_config
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 )
## 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.
set_config
lbrycrdd -server -txindex -reindex -conf=$CONFIG_PATH -printtoconsole
;;
chainquery )
## 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.
set_config
lbrycrdd -server -txindex -conf=$CONFIG_PATH -printtoconsole
;;
regtest )
## Set config params
## TODO: Make this more automagic in the future.
mkdir -p `dirname $CONFIG_PATH`
echo "rpcuser=lbry" > $CONFIG_PATH
echo "rpcpassword=lbry" >> $CONFIG_PATH
echo "rpcport=11337" >> $CONFIG_PATH
echo "rpcbind=0.0.0.0" >> $CONFIG_PATH
echo "rpcallowip=0.0.0.0/0" >> $CONFIG_PATH
echo "regtest=1" >> $CONFIG_PATH
echo "txindex=1" >> $CONFIG_PATH
echo "server=1" >> $CONFIG_PATH
echo "printtoconsole=1" >> $CONFIG_PATH
#nohup advance &>/dev/null &
lbrycrdd -conf=$CONFIG_PATH $1
;;
testnet )
## Set config params
## TODO: Make this more automagic in the future.
mkdir -p `dirname $CONFIG_PATH`
echo "rpcuser=lbry" > $CONFIG_PATH
echo "rpcpassword=lbry" >> $CONFIG_PATH
echo "rpcport=11337" >> $CONFIG_PATH
echo "rpcbind=0.0.0.0" >> $CONFIG_PATH
echo "rpcallowip=0.0.0.0/0" >> $CONFIG_PATH
echo "testnet=1" >> $CONFIG_PATH
echo "txindex=1" >> $CONFIG_PATH
echo "server=1" >> $CONFIG_PATH
echo "printtoconsole=1" >> $CONFIG_PATH
#nohup advance &>/dev/null &
lbrycrdd -conf=$CONFIG_PATH $1
;;
* )
echo "Error, you must define a RUN_MODE environment variable."
echo "Available options are testnet, regtest, chainquery, default, and reindex"
;;
esac

View file

@ -41,29 +41,25 @@ FROM dependencies as compile
ARG REPO=https://github.com/lbryio/lbry.git
ARG VERSION=master
ARG RUN_FROM_SOURCE=false
RUN python3.7 -m pip install -U pyinstaller && \
git clone ${REPO} /lbry && \
git -C /lbry checkout ${VERSION}
WORKDIR /lbry
RUN git clone https://github.com/lbryio/torba.git --depth 1 /lbry/torba
WORKDIR /lbry/torba
RUN python3.7 -m pip install -e .
WORKDIR /lbry/
git clone ${REPO} /lbry-sdk && \
git -C /lbry-sdk checkout ${VERSION}
RUN python3.7 -m pip install -e /lbry-sdk/torba
WORKDIR /lbry-sdk/lbry
COPY stuff/start.sh /usr/local/bin/start
COPY stuff/checkmount.sh /usr/local/bin/checkmount
RUN export TRAVIS_COMMIT=`git rev-parse HEAD` && \
python3.7 scripts/set_build.py && \
python3.7 -m pip install -e . && \
pyinstaller -F -n lbrynet lbrynet/extras/cli.py && \
chmod +x /lbry/dist/lbrynet && \
zip -j /lbry/dist/lbrynet-armhf.zip /lbry/dist/lbrynet && \
pyinstaller -F -n lbrynet lbry/extras/cli.py && \
chmod +x /lbry-sdk/lbry/dist/lbrynet && \
chmod a+x /usr/local/bin/* && \
mkdir /target && \
/lbry/dist/lbrynet --version
/lbry-sdk/lbry/dist/lbrynet --version
FROM ${BASE_IMAGE} as app
RUN adduser lbrynet --gecos GECOS --shell /bin/bash --disabled-password --home /home/lbrynet
COPY --from=compile /usr/local/bin/start /usr/local/bin/checkmount /lbry/dist/lbrynet /usr/local/bin/
COPY --from=compile /usr/local/bin/start /usr/local/bin/checkmount /lbry-sdk/lbry/dist/lbrynet /usr/local/bin/
EXPOSE 5279
USER lbrynet
ENTRYPOINT ["/usr/local/bin/checkmount"]

View file

@ -5,7 +5,7 @@ RUN apt-get update && apt-get -y install unzip curl
## Add lbrynet
ARG VERSION=latest
RUN URL=$(curl -s https://api.github.com/repos/lbryio/lbry/releases/$(if [ "${VERSION}" = 'latest' ]; then echo "latest"; else echo "tags/${VERSION}"; fi) | grep browser_download_url | grep lbrynet-linux.zip | cut -d'"' -f4) && echo $URL && curl -L -o /lbrynet.linux.zip $URL
RUN URL=$(curl -Ls https://api.github.com/repos/lbryio/lbry-sdk/releases/$(if [ "${VERSION}" = 'latest' ]; then echo "latest"; else echo "tags/${VERSION}"; fi) | grep browser_download_url | grep lbrynet-linux.zip | cut -d'"' -f4) && echo $URL && curl -L -o /lbrynet.linux.zip $URL
COPY stuff/start.sh /usr/bin/start
COPY stuff/checkmount.sh /usr/bin/checkmount

View file

@ -64,11 +64,13 @@ is to ensure that the wallet is backed up to a real storage device. You must run
the container with the appropriate volume argument, or else lbrynet will refuse
to run.
If you compiled lbrynet as above, with the tag `lbrynet-x86:v0.37.2`, you could run
The config file must be mounted at `/etc/lbry/daemon_settings.yml`.
If you compiled lbrynet as above, with the tag `lbrynet:v0.37.2`, you could run
docker like so:
```
docker run --rm -it -v wallet:/home/lbrynet lbrynet-x86:v0.37.2 lbrynet start
docker run --rm -it -v wallet:/home/lbrynet -v $(pwd)/stuff/daemon_settings_test.yml:/etc/lbry/daemon_settings.yml lbrynet:v0.37.2
```
This automatically creates a docker volume called `wallet` and it will persist
@ -79,7 +81,7 @@ If you would rather not use a docker volume, you can mount a directory
from your host instead:
```
docker run --rm -it -v /path/on/your/host:/home/lbrynet lbrynet-x86:v0.37.2 lbrynet start
docker run --rm -it -v /path/on/your/host:/home/lbrynet -v $(pwd)/stuff/daemon_settings_test.yml:/etc/lbry/daemon_settings.yml lbrynet:v0.37.2
```
Either way, the container uses the configuration from `/home/lbrynet` inside the container.

View file

@ -0,0 +1,3 @@
api: 0.0.0.0:5279
streaming_server: 0.0.0.0:5280
use_upnp: false

View file

@ -1,8 +1,4 @@
#!/bin/bash
CONFIG_PATH=/etc/lbry/daemon_settings.yml
echo "Config: "
cat $CONFIG_PATH
lbrynet start --api 0.0.0.0:5279 --config $CONFIG_PATH
"lbrynet start \
--api "${API_BIND_IP:-0.0.0.0}":"${API_PORT:-5179}" \
--config ${CONFIG_PATH:-/etc/lbry/daemon_settings.yml}"

118
tools/dockerfile_image_tag.sh Executable file
View file

@ -0,0 +1,118 @@
#!/bin/bash
### Find the latest docker image id and tag it in git
### Usage:
### ./dockerfile_image_tag.sh DOCKER_ORG DOCKER_REPO DOCKER_TAG
### Example:
### ./dockerfile_image_tag.sh lbry lbrycrd linux-x86_64-production
exe() { ( echo "## $*"; $*; ) }
SCRIPT_NAME=$0
SCRIPT_PATH="$( cd "$(dirname "$0")" && pwd -P )"
GIT_PATH="$(dirname "$SCRIPT_PATH")"
GIT_REMOTE=${GIT_REMOTE:-origin}
if ! which jq > /dev/null; then
echo "You need to install jq - https://stedolan.github.io/jq/"
exit 1
fi
if ! which curl > /dev/null; then
echo "You need to install curl"
exit 1
fi
get_docker_tags() {
# Thank you minamijoyo - https://stackoverflow.com/a/41830007/56560
if [ "$#" -ne 3 ]; then
echo "Wrong args: get_docker_tags DOCKER_ORG DOCKER_REPO DOCKER_TAG"
fi
ORG=$1
REPOSITORY=$2
TARGET_TAG=$3
echo "Contacting docker hub ..." >&2
# get authorization token
TOKEN=$(curl -s "https://auth.docker.io/token?service=registry.docker.io&scope=repository:$ORG/$REPOSITORY:pull" | jq -r .token)
# find all tags
ALL_TAGS=$(curl -s -H "Authorization: Bearer $TOKEN" https://index.docker.io/v2/$ORG/$REPOSITORY/tags/list | jq -r .tags[])
# get image digest for target
TARGET_DIGEST=$(curl -s -D - -H "Authorization: Bearer $TOKEN" -H "Accept: application/vnd.docker.distribution.manifest.v2+json" https://index.docker.io/v2/$ORG/$REPOSITORY/manifests/$TARGET_TAG | grep Docker-Content-Digest | cut -d ' ' -f 2)
# for each tags
for tag in ${ALL_TAGS[@]}; do
# get image digest
digest=$( curl -s -D - -H "Authorization: Bearer $TOKEN" -H "Accept: application/vnd.docker.distribution.manifest.v2+json" https://index.docker.io/v2/$ORG/$REPOSITORY/manifests/$tag | grep Docker-Content-Digest | cut -d ' ' -f 2)
# check digest
if [[ $TARGET_DIGEST = $digest ]]; then
# Echo to stderr to be helpful to humans:
echo "$ORG/$REPOSITORY:$tag $digest" >&2
# Echo to stdout to use as a script:
echo $digest
fi
done
}
check_git_status(){
# Check if the git stage is clear, on master branch, and up to date with the remote.
(
set -e
echo "Checking git status ..."
cd $GIT_PATH
if [[ $(git branch --show-current) != "master" ]]; then
echo "You are not on the master branch."
echo "Please change to the master branch before running this."
exit 1
fi
if ! git remote show origin | grep -e "^\W*master .*\(up to date\)" > /dev/null; then
echo "Your local branch is behind in the history of the remote"
echo "Please do a git pull before running this."
exit 1
fi
if git status --porcelain | grep -e "^A " > /dev/null; then
git status
echo "You have staged files for commit in git: $GIT_PATH"
echo "Please stash or commit those changes before running this. "
exit 1
fi
)
}
main() {
if [ "$#" -ne 3 ]; then
echo "run: $SCRIPT_NAME DOCKER_ORG DOCKER_REPO DOCKER_TAG"
echo "eg : $SCRIPT_NAME lbry lbrycrd linux-x86_64-production"
exit 1
fi
DOCKER_ORG=$1 DOCKER_REPO=$2; DOCKER_TAG=$3
# Check if the git stage is clear, error if not:
check_git_status
# Get the current Docker tag id and sanity check:
CURRENT_IMAGE_ID=$(get_docker_tags $DOCKER_ORG $DOCKER_REPO $DOCKER_TAG | cut -d ':' -f 2 | sed 's/\r$//g')
echo "CURRENT_IMAGE_ID=$CURRENT_IMAGE_ID"
if ! (echo $CURRENT_IMAGE_ID | grep -e "^[A-Fa-f0-9]\{64\}$" > /dev/null); then
echo "Bad image id: $CURRENT_IMAGE_ID"
echo -n $CURRENT_IMAGE_ID | hexdump -C
exit 1
fi
# Tag the current git HEAD with the docker image id:
GIT_COMMIT=$(git -C $GIT_PATH rev-parse HEAD)
GIT_TAG=$DOCKER_ORG-$DOCKER_REPO-$DOCKER_TAG-$CURRENT_IMAGE_ID
echo "GIT_COMMIT=$GIT_COMMIT"
echo "GIT_TAG=$GIT_TAG"
git -C $GIT_PATH tag $GIT_TAG $GIT_COMMIT && \
echo "Pushing tags to $GIT_REMOTE ..." && \
(git push --tags --dry-run 2>&1 | grep "\[new tag\]") && \
git -C $GIT_PATH push --tags $GIT_REMOTE
}
main $*