From dda0f2d9d66270ac2a272c7be222259a0c5600c3 Mon Sep 17 00:00:00 2001 From: Alexandre Teles Date: Wed, 7 Sep 2022 18:55:52 -0300 Subject: [PATCH] change deployment method --- .gitignore | 3 +++ config.toml | 5 ++++- docker-compose.yml | 3 ++- poetry.lock | 36 +++++++++++++++++++++++++++++++++++- portainer-stack.yml | 3 ++- pyproject.toml | 2 ++ requirements.txt | 2 ++ run.sh | 12 ++++++++++++ 8 files changed, 62 insertions(+), 4 deletions(-) create mode 100755 run.sh diff --git a/.gitignore b/.gitignore index d9005f2..494802c 100644 --- a/.gitignore +++ b/.gitignore @@ -150,3 +150,6 @@ cython_debug/ # and can be added to the global gitignore or merged into this file. For a more nuclear # option (not recommended) you can uncomment the following to ignore the entire idea folder. #.idea/ + +# PROJECT SPECIFIC +setup_env.sh \ No newline at end of file diff --git a/config.toml b/config.toml index e45a1fb..3d5b631 100644 --- a/config.toml +++ b/config.toml @@ -54,4 +54,7 @@ database = 1 [app] -repositories = ["TeamVanced/VancedMicroG", "revanced/revanced-cli", "revanced/revanced-patches", "revanced/revanced-integrations", "revanced/revanced-manager"] \ No newline at end of file +repositories = ["TeamVanced/VancedMicroG", "revanced/revanced-cli", "revanced/revanced-patches", "revanced/revanced-integrations", "revanced/revanced-manager"] + +[logging] + diff --git a/docker-compose.yml b/docker-compose.yml index 123a9a3..692bf82 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -18,7 +18,8 @@ services: environment: - REDIS_URL=revanced-releases-api-redis - REDIS_PORT=6379 - - GITHUB_TOKEN=YOUR_GITHUB_TOKEN + env_file: + - .env ports: - 127.0.0.1:7934:8000 networks: diff --git a/poetry.lock b/poetry.lock index 2c76ceb..be5326e 100644 --- a/poetry.lock +++ b/poetry.lock @@ -276,6 +276,21 @@ python-versions = "*" [package.dependencies] six = ">=1.4.1" +[[package]] +name = "loguru" +version = "0.6.0" +description = "Python logging made (stupidly) simple" +category = "main" +optional = false +python-versions = ">=3.5" + +[package.dependencies] +colorama = {version = ">=0.3.4", markers = "sys_platform == \"win32\""} +win32-setctime = {version = ">=1.0.0", markers = "sys_platform == \"win32\""} + +[package.extras] +dev = ["Sphinx (>=4.1.1)", "black (>=19.10b0)", "colorama (>=0.3.4)", "docutils (==0.16)", "flake8 (>=3.7.7)", "isort (>=5.1.1)", "pytest (>=4.6.2)", "pytest-cov (>=2.7.1)", "sphinx-autobuild (>=0.7.1)", "sphinx-rtd-theme (>=0.4.3)", "tox (>=3.9.0)"] + [[package]] name = "msgpack" version = "1.0.4" @@ -563,6 +578,17 @@ category = "main" optional = false python-versions = ">=3.7" +[[package]] +name = "win32-setctime" +version = "1.1.0" +description = "A small Python utility to set file creation time on Windows" +category = "main" +optional = false +python-versions = ">=3.5" + +[package.extras] +dev = ["black (>=19.3b0)", "pytest (>=4.6.2)"] + [[package]] name = "wrapt" version = "1.14.1" @@ -574,7 +600,7 @@ python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,>=2.7" [metadata] lock-version = "1.1" python-versions = "^3.10" -content-hash = "b6bc93886458708baeea4c07ad92f0613d6aeac113875d9ff2e9a3afb71d000d" +content-hash = "a2d02dd2c5903e3654434982ce86d728c2b9c63d6c6520a4bd295c362ac88bb0" [metadata.files] aioredis = [ @@ -740,6 +766,10 @@ limits = [ {file = "limits-1.6-py3-none-any.whl", hash = "sha256:12ae4449cf7daadee43edf4096acd9cb9f4bfdec3a995aa9fbd0f72b0b9af762"}, {file = "limits-1.6.tar.gz", hash = "sha256:6c0a57b42647f1141f5a7a0a8479b49e4367c24937a01bd9d4063a595c2dd48a"}, ] +loguru = [ + {file = "loguru-0.6.0-py3-none-any.whl", hash = "sha256:4e2414d534a2ab57573365b3e6d0234dfb1d84b68b7f3b948e6fb743860a77c3"}, + {file = "loguru-0.6.0.tar.gz", hash = "sha256:066bd06758d0a513e9836fd9c6b5a75bfb3fd36841f4b996bc60b547a309d41c"}, +] msgpack = [ {file = "msgpack-1.0.4-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:4ab251d229d10498e9a2f3b1e68ef64cb393394ec477e3370c457f9430ce9250"}, {file = "msgpack-1.0.4-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:112b0f93202d7c0fef0b7810d465fde23c746a2d482e1e2de2aafd2ce1492c88"}, @@ -1115,6 +1145,10 @@ websockets = [ {file = "websockets-10.3-pp37-pypy37_pp73-win_amd64.whl", hash = "sha256:3eda1cb7e9da1b22588cefff09f0951771d6ee9fa8dbe66f5ae04cc5f26b2b55"}, {file = "websockets-10.3.tar.gz", hash = "sha256:fc06cc8073c8e87072138ba1e431300e2d408f054b27047d047b549455066ff4"}, ] +win32-setctime = [ + {file = "win32_setctime-1.1.0-py3-none-any.whl", hash = "sha256:231db239e959c2fe7eb1d7dc129f11172354f98361c4fa2d6d2d7e278baa8aad"}, + {file = "win32_setctime-1.1.0.tar.gz", hash = "sha256:15cf5750465118d6929ae4de4eb46e8edae9a5634350c01ba582df868e932cb2"}, +] wrapt = [ {file = "wrapt-1.14.1-cp27-cp27m-macosx_10_9_x86_64.whl", hash = "sha256:1b376b3f4896e7930f1f772ac4b064ac12598d1c38d04907e696cc4d794b43d3"}, {file = "wrapt-1.14.1-cp27-cp27m-manylinux1_i686.whl", hash = "sha256:903500616422a40a98a5a3c4ff4ed9d0066f3b4c951fa286018ecdf0750194ef"}, diff --git a/portainer-stack.yml b/portainer-stack.yml index 27d5472..1e8dea4 100644 --- a/portainer-stack.yml +++ b/portainer-stack.yml @@ -20,7 +20,8 @@ services: environment: - REDIS_URL=revanced-releases-api-redis - REDIS_PORT=6379 - - GITHUB_TOKEN=YOUR_GITHUB_TOKEN + env_file: + - stack.env ports: - 127.0.0.1:7934:8000 networks: diff --git a/pyproject.toml b/pyproject.toml index aeeb2c8..083527a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -18,6 +18,7 @@ fastapi-cache2 = ">=0.1.9" aioredis = {version = ">=2.0.1", extras = ["hiredis"]} redis = ">=4.3.4" msgpack = ">=1.0.4" +loguru = ">=0.6.0" [tool.poetry.dev-dependencies] fastapi = ">=0.82.0" @@ -33,6 +34,7 @@ redis = ">=4.3.4" msgpack = ">=1.0.4" mypy = ">=0.971" types-toml = ">=0.10.8" +loguru = ">=0.6.0" [build-system] requires = ["poetry-core>=1.0.0"] diff --git a/requirements.txt b/requirements.txt index 31cf0ed..6bef85b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -21,6 +21,7 @@ httpx==0.23.0; python_version >= "3.7" hyperframe==6.0.1; python_version >= "3.7" and python_full_version >= "3.6.1" and python_version < "4.0" idna==3.3 limits==1.6; python_version >= "3.7" and python_version < "4.0" +loguru==0.6.0; python_version >= "3.5" msgpack==1.0.4 orjson==3.8.0; python_version >= "3.7" packaging==21.3; python_version >= "3.6" @@ -43,4 +44,5 @@ uvicorn==0.18.3; python_version >= "3.7" uvloop==0.16.0; sys_platform != "win32" and sys_platform != "cygwin" and platform_python_implementation != "PyPy" and python_version >= "3.7" and python_version < "4.0" watchfiles==0.16.1; python_version >= "3.7" and python_version < "4.0" websockets==10.3; python_version >= "3.7" and python_version < "4.0" +win32-setctime==1.1.0; sys_platform == "win32" and python_version >= "3.5" wrapt==1.14.1; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.6" diff --git a/run.sh b/run.sh new file mode 100755 index 0000000..0e983be --- /dev/null +++ b/run.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +# This script is used to run the application +# It is used by the Dockerfile + +# get number of cores +CORES=$(grep -c ^processor /proc/cpuinfo) + +# Start the application +uvicorn main:app --host="$UVICORN_HOST" --port="$UVICORN_PORT" \ +--workers="$CORES" --log-level="$UVICORN_LOG_LEVEL" --server-header \ +--proxy-headers --forwarded-allow-ips="*" \ No newline at end of file