This commit is contained in:
Lex Berezhny 2020-08-12 03:34:37 -04:00
parent 2000d75c7a
commit bf7ac1562f
7 changed files with 52 additions and 12 deletions

6
.dockerignore Normal file
View file

@ -0,0 +1,6 @@
*
!README.md
!setup.py
!lbry
!settings.yml
lbry/blockchain/bin

28
Dockerfile Normal file
View file

@ -0,0 +1,28 @@
FROM ubuntu:20.04
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update && \
apt-get -y --no-install-recommends install \
wget git \
tar unzip \
libpq-dev pkg-config \
build-essential \
python3 \
python3-dev \
python3-pip \
python3-wheel \
python3-setuptools && \
update-alternatives --install /usr/bin/pip pip /usr/bin/pip3 1 && \
rm -rf /var/lib/apt/lists/*
VOLUME /data
VOLUME /lbrycrd
RUN mkdir /src
COPY lbry /src/lbry
COPY setup.py /src/setup.py
COPY README.md /src/README.md
COPY settings.yml /data/settings.yml
WORKDIR /src
RUN pip install --no-cache-dir -e .[postgres]
ENTRYPOINT ["lbrynet", "start", "--full-node", "--data-dir=/data", "--lbrycrd-dir=/lbrycrd"]

View file

@ -1,7 +0,0 @@
.git
.tox
__pycache__
dist
lbry.egg-info
docs
tests

View file

@ -236,7 +236,11 @@ def main(argv=None):
parser = get_argument_parser() parser = get_argument_parser()
args, command_args = parser.parse_known_args(argv) args, command_args = parser.parse_known_args(argv)
conf = Config.create_from_arguments(args) conf = Config()
conf.set_arguments(args)
conf.set_environment()
conf.set_default_paths()
conf.set_persisted()
for directory in (conf.data_dir, conf.download_dir, conf.wallet_dir): for directory in (conf.data_dir, conf.download_dir, conf.wallet_dir):
ensure_directory_exists(directory) ensure_directory_exists(directory)

View file

@ -661,10 +661,6 @@ class Config(CLIConfig):
def streaming_port(self): def streaming_port(self):
return int(self.streaming_server.split(':')[1]) return int(self.streaming_server.split(':')[1])
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.set_default_paths()
@classmethod @classmethod
def with_null_dir(cls): def with_null_dir(cls):
return cls.with_same_dir('/dev/null') return cls.with_same_dir('/dev/null')

7
settings.yml Normal file
View file

@ -0,0 +1,7 @@
api: 0.0.0.0:5279
db_url: postgresql:///lbry
workers: 14
console: basic
no_spv_address_filters: true
lbrycrd_rpc_user: lbry
lbrycrd_rpc_pass: lbry

View file

@ -26,6 +26,7 @@ class ConfigurationTests(unittest.TestCase):
@unittest.skipIf("darwin" not in sys.platform, "skipping mac only test") @unittest.skipIf("darwin" not in sys.platform, "skipping mac only test")
def test_mac_defaults(self): def test_mac_defaults(self):
c = Config() c = Config()
c.set_default_paths()
prefix = os.path.expanduser("~/Library/Application Support/lbrynet") prefix = os.path.expanduser("~/Library/Application Support/lbrynet")
self.assertEqual(c.data_dir, prefix) self.assertEqual(c.data_dir, prefix)
self.assertEqual(c.blob_dir, os.path.join(prefix, "blobs")) self.assertEqual(c.blob_dir, os.path.join(prefix, "blobs"))
@ -37,6 +38,7 @@ class ConfigurationTests(unittest.TestCase):
@unittest.skipIf("win32" not in sys.platform, "skipping windows only test") @unittest.skipIf("win32" not in sys.platform, "skipping windows only test")
def test_windows_defaults(self): def test_windows_defaults(self):
c = Config() c = Config()
c.set_default_paths()
prefix = os.path.join(r"C:\Users", os.getlogin(), r"AppData\Local\LBRY\lbrynet") prefix = os.path.join(r"C:\Users", os.getlogin(), r"AppData\Local\LBRY\lbrynet")
self.assertEqual(c.data_dir, prefix) self.assertEqual(c.data_dir, prefix)
self.assertEqual(c.blob_dir, os.path.join(prefix, "blobs")) self.assertEqual(c.blob_dir, os.path.join(prefix, "blobs"))
@ -48,6 +50,7 @@ class ConfigurationTests(unittest.TestCase):
@unittest.skipIf("linux" not in sys.platform, "skipping linux only test") @unittest.skipIf("linux" not in sys.platform, "skipping linux only test")
def test_linux_defaults(self): def test_linux_defaults(self):
c = Config() c = Config()
c.set_default_paths()
self.assertEqual(c.data_dir, os.path.expanduser("~/.local/share/lbrynet")) self.assertEqual(c.data_dir, os.path.expanduser("~/.local/share/lbrynet"))
self.assertEqual(c.blob_dir, os.path.expanduser("~/.local/share/lbrynet/blobs")) self.assertEqual(c.blob_dir, os.path.expanduser("~/.local/share/lbrynet/blobs"))
self.assertEqual(c.wallet_dir, os.path.expanduser("~/.local/share/lbrynet/wallets")) self.assertEqual(c.wallet_dir, os.path.expanduser("~/.local/share/lbrynet/wallets"))
@ -58,6 +61,7 @@ class ConfigurationTests(unittest.TestCase):
# changes the root for all defaults # changes the root for all defaults
c = Config(data_dir='/foo/bar') c = Config(data_dir='/foo/bar')
c.set_default_paths()
self.assertEqual(c.data_dir, '/foo/bar') self.assertEqual(c.data_dir, '/foo/bar')
self.assertEqual(c.blob_dir, '/foo/bar/blobs') self.assertEqual(c.blob_dir, '/foo/bar/blobs')
self.assertEqual(c.wallet_dir, '/foo/bar/wallets') self.assertEqual(c.wallet_dir, '/foo/bar/wallets')
@ -66,11 +70,13 @@ class ConfigurationTests(unittest.TestCase):
# overwriting default blob_dir # overwriting default blob_dir
c = Config(data_dir='/foo/bar', blob_dir='/stuff') c = Config(data_dir='/foo/bar', blob_dir='/stuff')
c.set_default_paths()
self.assertEqual(c.blob_dir, '/stuff') self.assertEqual(c.blob_dir, '/stuff')
self.assertEqual(c.wallet_dir, '/foo/bar/wallets') self.assertEqual(c.wallet_dir, '/foo/bar/wallets')
# overwriting default wallet_dir # overwriting default wallet_dir
c = Config(data_dir='/foo/bar', wallet_dir='/secrets') c = Config(data_dir='/foo/bar', wallet_dir='/secrets')
c.set_default_paths()
self.assertEqual(c.blob_dir, '/foo/bar/blobs') self.assertEqual(c.blob_dir, '/foo/bar/blobs')
self.assertEqual(c.wallet_dir, '/secrets') self.assertEqual(c.wallet_dir, '/secrets')