diff --git a/.gitignore b/.gitignore index 8391883..5678acf 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,3 @@ monero-lws docker-monero-node -.env -data -node_modules \ No newline at end of file +.env \ No newline at end of file diff --git a/docker-compose.yaml b/docker-compose.yaml index 97dbc20..dbfd669 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -8,26 +8,22 @@ x-log-config: &log-config volumes: lws: services: - # lws-web: - # container_name: lws-web - # build: - # context: lws-web - # dockerfile: Dockerfile - # restart: unless-stopped - # depends_on: - # - monero-lws - # environment: - # NUXT_LWS_API_KEY: ayoo - # NUXT_LWS_ADMIN_URL: http://127.0.0.1:8080 - # ports: - # - 127.0.0.1:5000:5000 - # <<: *log-config - redis: - image: redis:latest - container_name: monero-lws-cache - restart: always + lws-web: + container_name: lws-web + build: + context: lws-web + dockerfile: Dockerfile + restart: unless-stopped + depends_on: + - monero-lws + environment: + LWS_URL: http://127.0.0.1:8080 + LWS_ADMIN_URL: http://127.0.0.1:8081 ports: - - 127.0.0.1:6379:6379 + - 127.0.0.1:5000:5000 + command: + ./.venv/bin/poetry run start + <<: *log-config monero-lws: container_name: monero-lws build: diff --git a/env.example b/env.example new file mode 100644 index 0000000..2d9972f --- /dev/null +++ b/env.example @@ -0,0 +1,5 @@ +# move me to .env + +SECRET_KEY=xxxxxxxxxxxx +DEBUG=0 +QUART_ENV=production \ No newline at end of file diff --git a/lws-web/.dockerignore b/lws-web/.dockerignore index 003a45d..5c23e72 100644 --- a/lws-web/.dockerignore +++ b/lws-web/.dockerignore @@ -1,2 +1,3 @@ .venv -*.db* \ No newline at end of file +*.db* +.env \ No newline at end of file diff --git a/lws-web/Dockerfile b/lws-web/Dockerfile index 9ffa369..828c633 100644 --- a/lws-web/Dockerfile +++ b/lws-web/Dockerfile @@ -3,7 +3,19 @@ FROM ubuntu:22.04 RUN apt-get update RUN apt-get install -y python3 python3-venv WORKDIR /srv/lws-web +RUN adduser \ + --system \ + --shell /bin/bash \ + --gecos 'lws-web' \ + --group \ + --disabled-password \ + --home /srv/lws-web \ + --uid 1000 \ + lws-web COPY . . +RUN chown -R lws-web:lws-web . RUN python3 -m venv .venv RUN .venv/bin/pip install poetry RUN .venv/bin/poetry install + +CMD ".venv/bin/poetry run start" \ No newline at end of file diff --git a/lws-web/data/.gitignore b/lws-web/data/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/lws-web/lws/config.py b/lws-web/lws/config.py index 84bb3f0..fa5776e 100644 --- a/lws-web/lws/config.py +++ b/lws-web/lws/config.py @@ -8,9 +8,6 @@ TEMPLATES_AUTO_RELOAD = True DEBUG = 1 == env.get("DEBUG", 1) QUART_ENV = env.get("QUART_ENV", "development") SECRET_KEY = env.get("SECRET_KEY", token_urlsafe(12)) -SESSION_URI = env.get("SESSION_URI", "redis://127.0.0.1:6379") -SESSION_TYPE = "redis" -SESSION_PROTECTION = True QUART_AUTH_DURATION = 60 * 60 # 1 hour # LWS diff --git a/lws-web/lws/factory.py b/lws-web/lws/factory.py index ea110af..4bd62a8 100644 --- a/lws-web/lws/factory.py +++ b/lws-web/lws/factory.py @@ -3,22 +3,17 @@ from quart_auth import ( AuthManager, Unauthorized ) from quart_bcrypt import Bcrypt -from quart_session import Session from lws import config def create_app(): app = Quart(__name__) - app.config["TEMPLATES_AUTO_RELOAD"] = config.TEMPLATES_AUTO_RELOAD + app.config["SECRET_KEY"] = config.SECRET_KEY app.config["DEBUG"] = config.DEBUG + app.config["TEMPLATES_AUTO_RELOAD"] = config.TEMPLATES_AUTO_RELOAD app.config["QUART_ENV"] = config.QUART_ENV - app.config["SECRET_KEY"] = config.SECRET_KEY - app.config["SESSION_URI"] = config.SESSION_URI - app.config["SESSION_TYPE"] = config.SESSION_TYPE - app.config["SESSION_PROTECTION"] = config.SESSION_PROTECTION app.config["QUART_AUTH_DURATION"] = config.QUART_AUTH_DURATION - Session(app) AuthManager(app) bcrypt = Bcrypt(app) diff --git a/lws-web/poetry.lock b/lws-web/poetry.lock index 67bc6dc..ab6efe4 100644 --- a/lws-web/poetry.lock +++ b/lws-web/poetry.lock @@ -12,18 +12,6 @@ files = [ {file = "aiofiles-23.1.0.tar.gz", hash = "sha256:edd247df9a19e0db16534d4baaf536d6609a43e1de5401d7a4c1c148753a1635"}, ] -[[package]] -name = "async-timeout" -version = "4.0.2" -description = "Timeout context manager for asyncio programs" -category = "main" -optional = false -python-versions = ">=3.6" -files = [ - {file = "async-timeout-4.0.2.tar.gz", hash = "sha256:2163e1640ddb52b7a8c80d0a67a08587e5d245cc9c553a74a847056bc2976b15"}, - {file = "async_timeout-4.0.2-py3-none-any.whl", hash = "sha256:8ca1e4fcf50d07413d66d1a5e416e42cfdf5851c981d679a09851a6853383b3c"}, -] - [[package]] name = "bcrypt" version = "3.2.2" @@ -668,44 +656,6 @@ files = [ bcrypt = ">=3.2.2,<4.0.0" quart = ">=0.18.0,<0.19.0" -[[package]] -name = "quart-session" -version = "2.0.0" -description = "Adds server-side session support to your Quart application" -category = "main" -optional = false -python-versions = "*" -files = [ - {file = "Quart-Session-2.0.0.tar.gz", hash = "sha256:2bbc197855f7307938c4fe451585240fa0cf06afee00c826685a55641ec91f45"}, -] - -[package.dependencies] -Quart = ">=0.10.0" - -[package.extras] -dotenv = ["python-dotenv"] -mongodb = ["motor (>=2.5.1)"] -redis = ["redis (>=4.4.0)"] - -[[package]] -name = "redis" -version = "4.5.4" -description = "Python client for Redis database and key-value store" -category = "main" -optional = false -python-versions = ">=3.7" -files = [ - {file = "redis-4.5.4-py3-none-any.whl", hash = "sha256:2c19e6767c474f2e85167909061d525ed65bea9301c0770bb151e041b7ac89a2"}, - {file = "redis-4.5.4.tar.gz", hash = "sha256:73ec35da4da267d6847e47f68730fdd5f62e2ca69e3ef5885c6a78a9374c3893"}, -] - -[package.dependencies] -async-timeout = {version = ">=4.0.2", markers = "python_version <= \"3.11.2\""} - -[package.extras] -hiredis = ["hiredis (>=1.0.0)"] -ocsp = ["cryptography (>=36.0.1)", "pyopenssl (==20.0.1)", "requests (>=2.26.0)"] - [[package]] name = "requests" version = "2.30.0" @@ -805,4 +755,4 @@ h11 = ">=0.9.0,<1" [metadata] lock-version = "2.0" python-versions = "^3.10" -content-hash = "5465cc294e32dd3f725c0cd72f6d6b404688e7508ac6f95783d0f9d71a8e55dc" +content-hash = "5300fb61562523b1601e989618fadac9f121d6531a43208ecf56b6e4dc02a62c" diff --git a/lws-web/pyproject.toml b/lws-web/pyproject.toml index f7862e3..9d192b8 100644 --- a/lws-web/pyproject.toml +++ b/lws-web/pyproject.toml @@ -1,5 +1,5 @@ [tool.poetry] -name = "lws" +name = "lws-web" version = "0.1.0" description = "" authors = ["lza_menace "] @@ -12,9 +12,7 @@ quart = "^0.18.3" peewee = "^3.15.3" quart-auth = "^0.8.0" quart-bcrypt = "^0.0.6" -quart-session = "^2.0.0" requests = "^2.29.0" -redis = "^4.4.0" monero = "^1.1.1" python-dotenv = "^1.0.0"