From bd1b5e5b00dd61840f378cfe916c5729c87781fb Mon Sep 17 00:00:00 2001 From: Cédric Bonhomme Date: Tue, 17 Mar 2020 22:11:38 +0100 Subject: added files for docker --- Dockerfile | 42 +++++++++++++++++++++++++++++++++++++++++ README.md | 5 +++++ docker-compose.yml | 18 ++++++++++++++++++ instance/sqlite.py | 3 ++- newspipe/bootstrap.py | 6 +++--- poetry.lock | 52 ++++++++++++++++++++++++++++++++++++++++++++++----- pyproject.toml | 2 +- 7 files changed, 118 insertions(+), 10 deletions(-) create mode 100644 Dockerfile create mode 100644 docker-compose.yml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..5d11830c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,42 @@ +FROM python:3.8-alpine + +RUN apk update && \ + apk add \ + build-base \ + curl \ + git \ + libffi-dev \ + openssl-dev \ + libxml2-dev \ + libxslt-dev \ + libpq \ + postgresql-dev \ + sqlite-dev \ + sqlite \ + sqlite-libs \ + npm +RUN pip install poetry + +WORKDIR newspipe + +COPY newspipe newspipe/ +COPY instance instance/ +COPY manager.py . +COPY runserver.py . +COPY package.json . +COPY package-lock.json . +COPY pyproject.toml . +COPY poetry.lock . +COPY instance/sqlite.py . +COPY instance/sqlite.py instance/ +COPY instance/sqlite.py newspipe/ + +RUN npm install +COPY node_modules newspipe/static/npm_components + +ENV Newspipe_CONFIG sqlite.py + +RUN poetry install +RUN poetry run pybabel compile -d newspipe/translations +RUN poetry run ./manager.py db_create +RUN poetry run ./manager.py create_admin admin password diff --git a/README.md b/README.md index af6ac275..9c042237 100644 --- a/README.md +++ b/README.md @@ -65,6 +65,11 @@ $ export Newspipe_CONFIG=postgresql.py For production you can use [Gunicorn](https://gunicorn.org) or ``mod_wsgi``. +For development, you can use Docker: + +```bash +$ docker-compose up +``` ## License diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..eee5ef32 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,18 @@ +version: '3' +services: + + newspipe: + build: . + tty: true + environment: + - Newspipe_CONFIG=/newspipe/instance/sqlite.py + command: + - /bin/sh + - -c + - | + poetry run pybabel compile -d newspipe/translations + poetry run ./runserver.py + volumes: + - .:/newspipe + ports: + - "5000:5000" diff --git a/instance/sqlite.py b/instance/sqlite.py index ad802865..e6065ed3 100644 --- a/instance/sqlite.py +++ b/instance/sqlite.py @@ -5,7 +5,7 @@ import os # # Webserver -HOST = "127.0.0.1" +HOST = "0.0.0.0" PORT = 5000 DEBUG = False API_ROOT = "/api/v2.0" @@ -47,3 +47,4 @@ ADMIN_EMAIL = "admin@admin.localhost" LOG_LEVEL = "info" LOG_PATH = "./var/newspipe.log" SELF_REGISTRATION = True +SQLALCHEMY_TRACK_MODIFICATIONS = False diff --git a/newspipe/bootstrap.py b/newspipe/bootstrap.py index aa80173b..320fa261 100644 --- a/newspipe/bootstrap.py +++ b/newspipe/bootstrap.py @@ -23,8 +23,8 @@ def set_logging( "root", "bootstrap", "runserver", - "web", - "crawler.default_crawler", + "newspipe", + "newspipe.crawler.default_crawler", "manager", "plugins", ) @@ -59,7 +59,7 @@ else: try: application.config.from_pyfile("development.py", silent=False) except Exception: - application.config.from_pyfile("production.py", silent=False) + application.config.from_pyfile("sqlite.py", silent=False) set_logging(application.config["LOG_PATH"]) diff --git a/poetry.lock b/poetry.lock index a01c0418..b01792b3 100644 --- a/poetry.lock +++ b/poetry.lock @@ -13,6 +13,14 @@ chardet = ">=2.0,<4.0" multidict = ">=4.5,<5.0" yarl = ">=1.0,<2.0" +[package.dependencies.idna-ssl] +python = "<3.7" +version = ">=1.0" + +[package.dependencies.typing-extensions] +python = "<3.7" +version = ">=3.6.5" + [package.extras] speedups = ["aiodns", "brotlipy", "cchardet"] @@ -198,7 +206,7 @@ description = "SQLAlchemy database migrations for Flask applications using Alemb name = "flask-migrate" optional = false python-versions = "*" -version = "2.5.2" +version = "2.5.3" [package.dependencies] Flask = ">=0.9" @@ -289,6 +297,18 @@ optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" version = "2.9" +[[package]] +category = "main" +description = "Patch ssl.match_hostname for Unicode(idna) domains support" +marker = "python_version < \"3.7\"" +name = "idna-ssl" +optional = false +python-versions = "*" +version = "1.1.0" + +[package.dependencies] +idna = ">=2.0" + [[package]] category = "main" description = "Various helpers to pass data to untrusted environments and back." @@ -523,6 +543,15 @@ version = "1.3" pydot = "*" setuptools = "*" +[[package]] +category = "main" +description = "Backported and Experimental Type Hints for Python 3.5+" +marker = "python_version < \"3.7\"" +name = "typing-extensions" +optional = false +python-versions = "*" +version = "3.7.4.1" + [[package]] category = "main" description = "HTTP library with thread-safe connection pooling, file post, and more." @@ -572,8 +601,8 @@ idna = ">=2.0" multidict = ">=4.0" [metadata] -content-hash = "a76c1fbed09fe6be2b0351add63dc5b8e218761204f65f1e60d25ef202e2a9e1" -python-versions = "^3.8" +content-hash = "d46822111f91a807481ce3e7e941c2b7f0c87255fc95ef8b4745a2257f2c7be5" +python-versions = "^3.6" [metadata.files] aiohttp = [ @@ -655,8 +684,8 @@ flask-login = [ {file = "Flask_Login-0.5.0-py2.py3-none-any.whl", hash = "sha256:7451b5001e17837ba58945aead261ba425fdf7b4f0448777e597ddab39f4fba0"}, ] flask-migrate = [ - {file = "Flask-Migrate-2.5.2.tar.gz", hash = "sha256:a96ff1875a49a40bd3e8ac04fce73fdb0870b9211e6168608cbafa4eb839d502"}, - {file = "Flask_Migrate-2.5.2-py2.py3-none-any.whl", hash = "sha256:6fb038be63d4c60727d5dfa5f581a6189af5b4e2925bc378697b4f0a40cfb4e1"}, + {file = "Flask-Migrate-2.5.3.tar.gz", hash = "sha256:a69d508c2e09d289f6e55a417b3b8c7bfe70e640f53d2d9deb0d056a384f37ee"}, + {file = "Flask_Migrate-2.5.3-py2.py3-none-any.whl", hash = "sha256:4dc4a5cce8cbbb06b8dc963fd86cf8136bd7d875aabe2d840302ea739b243732"}, ] flask-paginate = [ {file = "flask_paginate-0.5.5-py2.py3-none-any.whl", hash = "sha256:d2aa07b4ef27f56f973482aaa06a0d93dc769a3e4d3e9c382a305ab72ac38ad9"}, @@ -683,6 +712,9 @@ idna = [ {file = "idna-2.9-py2.py3-none-any.whl", hash = "sha256:a068a21ceac8a4d63dbfd964670474107f541babbd2250d61922f029858365fa"}, {file = "idna-2.9.tar.gz", hash = "sha256:7588d1c14ae4c77d74036e8c22ff447b26d0fde8f007354fd48a7814db15b7cb"}, ] +idna-ssl = [ + {file = "idna-ssl-1.1.0.tar.gz", hash = "sha256:a933e3bb13da54383f9e8f35dc4f9cb9eb9b3b78c6b36f311254d6d0d92c6c7c"}, +] itsdangerous = [ {file = "itsdangerous-1.1.0-py2.py3-none-any.whl", hash = "sha256:b12271b2047cb23eeb98c8b5622e2e5c5e9abd9784a153e9d8ef9cb4dd09d749"}, {file = "itsdangerous-1.1.0.tar.gz", hash = "sha256:321b033d07f2a4136d3ec762eac9f16a10ccd60f53c0c91af90217ace7ba1f19"}, @@ -752,6 +784,11 @@ markupsafe = [ {file = "MarkupSafe-1.1.1-cp37-cp37m-manylinux1_x86_64.whl", hash = "sha256:ba59edeaa2fc6114428f1637ffff42da1e311e29382d81b339c1817d37ec93c6"}, {file = "MarkupSafe-1.1.1-cp37-cp37m-win32.whl", hash = "sha256:b00c1de48212e4cc9603895652c5c410df699856a2853135b3967591e4beebc2"}, {file = "MarkupSafe-1.1.1-cp37-cp37m-win_amd64.whl", hash = "sha256:9bf40443012702a1d2070043cb6291650a0841ece432556f784f004937f0f32c"}, + {file = "MarkupSafe-1.1.1-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:6788b695d50a51edb699cb55e35487e430fa21f1ed838122d722e0ff0ac5ba15"}, + {file = "MarkupSafe-1.1.1-cp38-cp38-manylinux1_i686.whl", hash = "sha256:cdb132fc825c38e1aeec2c8aa9338310d29d337bebbd7baa06889d09a60a1fa2"}, + {file = "MarkupSafe-1.1.1-cp38-cp38-manylinux1_x86_64.whl", hash = "sha256:13d3144e1e340870b25e7b10b98d779608c02016d5184cfb9927a9f10c689f42"}, + {file = "MarkupSafe-1.1.1-cp38-cp38-win32.whl", hash = "sha256:596510de112c685489095da617b5bcbbac7dd6384aeebeda4df6025d0256a81b"}, + {file = "MarkupSafe-1.1.1-cp38-cp38-win_amd64.whl", hash = "sha256:e8313f01ba26fbbe36c7be1966a7b7424942f670f38e666995b88d012765b9be"}, {file = "MarkupSafe-1.1.1.tar.gz", hash = "sha256:29872e92839765e546828bb7754a68c418d927cd064fd4708fab9fe9c8bb116b"}, ] mccabe = [ @@ -868,6 +905,11 @@ sqlalchemy-schemadisplay = [ {file = "sqlalchemy_schemadisplay-1.3.tar.gz", hash = "sha256:0a9f26d77be9d92c9564d87cc17668fe141a816036c5f5d7c8cb053b253957e0"}, {file = "sqlalchemy_schemadisplay-1.3.zip", hash = "sha256:b38f0d5947bd3ed9e2b180b4d8c9cd44c9d09edc0ce26722d89be4cc264903b5"}, ] +typing-extensions = [ + {file = "typing_extensions-3.7.4.1-py2-none-any.whl", hash = "sha256:910f4656f54de5993ad9304959ce9bb903f90aadc7c67a0bef07e678014e892d"}, + {file = "typing_extensions-3.7.4.1-py3-none-any.whl", hash = "sha256:cf8b63fedea4d89bab840ecbb93e75578af28f76f66c35889bd7065f5af88575"}, + {file = "typing_extensions-3.7.4.1.tar.gz", hash = "sha256:091ecc894d5e908ac75209f10d5b4f118fbdb2eb1ede6a63544054bb1edb41f2"}, +] urllib3 = [ {file = "urllib3-1.25.8-py2.py3-none-any.whl", hash = "sha256:2f3db8b19923a873b3e5256dc9c2dedfa883e33d87c690d9c7913e1f40673cdc"}, {file = "urllib3-1.25.8.tar.gz", hash = "sha256:87716c2d2a7121198ebcb7ce7cccf6ce5e9ba539041cfbaeecfb641dc0bf6acc"}, diff --git a/pyproject.toml b/pyproject.toml index c3ca7692..f75c791b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,7 +6,7 @@ authors = ["Cédric Bonhomme "] license = "AGPL-3.0-or-later" [tool.poetry.dependencies] -python = "^3.8" +python = "^3.6" aiohttp = "^3.6.2" requests = "^2.23.0" chardet = "^3.0.4" -- cgit