From bf7ac1562f57b88eba77306e7827826c15ac9a22 Mon Sep 17 00:00:00 2001 From: Lex Berezhny Date: Wed, 12 Aug 2020 03:34:37 -0400 Subject: [PATCH] docker --- .dockerignore | 6 ++++++ Dockerfile | 28 ++++++++++++++++++++++++++++ lbry/.dockerignore | 7 ------- lbry/cli.py | 6 +++++- lbry/conf.py | 4 ---- settings.yml | 7 +++++++ tests/unit/test_conf.py | 6 ++++++ 7 files changed, 52 insertions(+), 12 deletions(-) create mode 100644 .dockerignore create mode 100644 Dockerfile delete mode 100644 lbry/.dockerignore create mode 100644 settings.yml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..d940ae7ad --- /dev/null +++ b/.dockerignore @@ -0,0 +1,6 @@ +* +!README.md +!setup.py +!lbry +!settings.yml +lbry/blockchain/bin diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..67139dd6a --- /dev/null +++ b/Dockerfile @@ -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"] diff --git a/lbry/.dockerignore b/lbry/.dockerignore deleted file mode 100644 index 4eef96cdf..000000000 --- a/lbry/.dockerignore +++ /dev/null @@ -1,7 +0,0 @@ -.git -.tox -__pycache__ -dist -lbry.egg-info -docs -tests diff --git a/lbry/cli.py b/lbry/cli.py index 113c57499..0aefeb7fe 100644 --- a/lbry/cli.py +++ b/lbry/cli.py @@ -236,7 +236,11 @@ def main(argv=None): parser = get_argument_parser() 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): ensure_directory_exists(directory) diff --git a/lbry/conf.py b/lbry/conf.py index 389ad1e10..b8a5a4c1a 100644 --- a/lbry/conf.py +++ b/lbry/conf.py @@ -661,10 +661,6 @@ class Config(CLIConfig): def streaming_port(self): return int(self.streaming_server.split(':')[1]) - def __init__(self, **kwargs): - super().__init__(**kwargs) - self.set_default_paths() - @classmethod def with_null_dir(cls): return cls.with_same_dir('/dev/null') diff --git a/settings.yml b/settings.yml new file mode 100644 index 000000000..996ced644 --- /dev/null +++ b/settings.yml @@ -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 diff --git a/tests/unit/test_conf.py b/tests/unit/test_conf.py index c890ea722..ff7728b64 100644 --- a/tests/unit/test_conf.py +++ b/tests/unit/test_conf.py @@ -26,6 +26,7 @@ class ConfigurationTests(unittest.TestCase): @unittest.skipIf("darwin" not in sys.platform, "skipping mac only test") def test_mac_defaults(self): c = Config() + c.set_default_paths() prefix = os.path.expanduser("~/Library/Application Support/lbrynet") self.assertEqual(c.data_dir, prefix) 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") def test_windows_defaults(self): c = Config() + c.set_default_paths() prefix = os.path.join(r"C:\Users", os.getlogin(), r"AppData\Local\LBRY\lbrynet") self.assertEqual(c.data_dir, prefix) 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") def test_linux_defaults(self): c = Config() + c.set_default_paths() 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.wallet_dir, os.path.expanduser("~/.local/share/lbrynet/wallets")) @@ -58,6 +61,7 @@ class ConfigurationTests(unittest.TestCase): # changes the root for all defaults c = Config(data_dir='/foo/bar') + c.set_default_paths() self.assertEqual(c.data_dir, '/foo/bar') self.assertEqual(c.blob_dir, '/foo/bar/blobs') self.assertEqual(c.wallet_dir, '/foo/bar/wallets') @@ -66,11 +70,13 @@ class ConfigurationTests(unittest.TestCase): # overwriting default blob_dir c = Config(data_dir='/foo/bar', blob_dir='/stuff') + c.set_default_paths() self.assertEqual(c.blob_dir, '/stuff') self.assertEqual(c.wallet_dir, '/foo/bar/wallets') # overwriting default wallet_dir c = Config(data_dir='/foo/bar', wallet_dir='/secrets') + c.set_default_paths() self.assertEqual(c.blob_dir, '/foo/bar/blobs') self.assertEqual(c.wallet_dir, '/secrets')