From 99e551fcb59a0edbfbbad418e21f57766719f1d5 Mon Sep 17 00:00:00 2001 From: Andrey Date: Wed, 3 May 2023 21:36:53 +0300 Subject: [PATCH] =?UTF-8?q?=D0=92=D1=81=D0=B5=3F=20=D0=B7=D0=B0=D1=80?= =?UTF-8?q?=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=D0=B5=D1=88=D1=8C=3F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/Dockerfile | 14 ++-- backend/app/config.py | 4 +- backend/app/routes.py | 15 ++-- backend/app/utils.py | 15 ---- backend/poetry.lock | 108 +-------------------------- backend/pyproject.toml | 6 +- docker-compose.yml | 13 ++-- frontend/.env | 3 + frontend/Dockerfile | 2 +- frontend/package.json | 1 + frontend/src/App.vue | 1 - frontend/src/components/About.vue | 4 +- frontend/src/components/Projects.vue | 4 +- frontend/vite.config.ts | 20 ++++- frontend/yarn.lock | 5 ++ 15 files changed, 62 insertions(+), 153 deletions(-) create mode 100644 frontend/.env diff --git a/backend/Dockerfile b/backend/Dockerfile index 5ff89fc..73943e9 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -1,12 +1,12 @@ FROM python:3.10-alpine -RUN mkdir /app COPY /app /app -COPY pyproject.toml /app - -WORKDIR /app - RUN pip install poetry -RUN poetry config virtualenvs.create false -RUN poetry install --no-dev + +WORKDIR . +COPY . . + +RUN poetry config virtualenvs.create false \ + && poetry install $(test "$YOUR_ENV" == production && echo "--no-dev") --no-interaction --no-ansi + CMD ["poetry", "run", "python", "app/__main__.py"] diff --git a/backend/app/config.py b/backend/app/config.py index c3e66e3..f0d8e5a 100644 --- a/backend/app/config.py +++ b/backend/app/config.py @@ -1,11 +1,11 @@ -from datetime import datetime +from datetime import date from pydantic import BaseSettings class Config(BaseSettings): host: str = '127.0.0.1' port: int = 8888 - birthdate: datetime = datetime(2007, 10, 13) + birthdate: date = date(2007, 10, 13) config = Config(_env_file='.env') diff --git a/backend/app/routes.py b/backend/app/routes.py index bbfd623..0dd7eb7 100644 --- a/backend/app/routes.py +++ b/backend/app/routes.py @@ -6,28 +6,31 @@ from fastapi_utils.tasks import repeat_every from app.config import config from app.data_getter import DataGetter -router = APIRouter() +router = APIRouter( + prefix='/api/v1' +) data = DataGetter() -@router.on_event('startup') + +@router.on_event("startup") @repeat_every(seconds=7200) def start(): data.fetch() -@router.get("/api/get_repos") + +@router.get("/repos") def get_repos(): return data.repos -@router.get("/api/get_code_stats") +@router.get("/code_stats") def get_code_stats(): return data.code_stats -@router.get("/api/get_age") +@router.get("/age") def get_age(): today = datetime.today() age = today.year - config.birthdate.year - ( (today.month, today.day) < (config.birthdate.month, config.birthdate.day)) return declension(age, 'год', 'года', 'лет') - diff --git a/backend/app/utils.py b/backend/app/utils.py index b9bdc5f..da09311 100644 --- a/backend/app/utils.py +++ b/backend/app/utils.py @@ -12,19 +12,4 @@ def declension(num: int, one: str, two: str, five: str): return f'{str(num)} {five}' -def load_repos() -> list: - while True: - try: - resp = requests.get("https://git.mootfrost.dev/api/v1/repos/search", - params={'limit': 64, - 'sort': 'updated', - 'order': 'desc'}).json() - except RequestException as e: - logging.error(f'{datetime.now()}: Error while updating projects: {e}') - return - repos = [] - for repo in resp['data']: - repos.append(Project(repo["name"], repo["description"], repo["html_url"])) - return repos - __all__ = ['declension'] diff --git a/backend/poetry.lock b/backend/poetry.lock index 265d65f..082a1bc 100644 --- a/backend/poetry.lock +++ b/backend/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.4.2 and should not be changed by hand. +# This file is automatically @generated by Poetry and should not be changed by hand. [[package]] name = "anyio" @@ -21,36 +21,6 @@ doc = ["packaging", "sphinx-autodoc-typehints (>=1.2.0)", "sphinx-rtd-theme"] test = ["contextlib2", "coverage[toml] (>=4.5)", "hypothesis (>=4.0)", "mock (>=4)", "pytest (>=7.0)", "pytest-mock (>=3.6.1)", "trustme", "uvloop (<0.15)", "uvloop (>=0.15)"] trio = ["trio (>=0.16,<0.22)"] -[[package]] -name = "apscheduler" -version = "3.10.1" -description = "In-process task scheduler with Cron-like capabilities" -category = "main" -optional = false -python-versions = ">=3.6" -files = [ - {file = "APScheduler-3.10.1-py3-none-any.whl", hash = "sha256:e813ad5ada7aff36fb08cdda746b520531eaac7757832abc204868ba78e0c8f6"}, - {file = "APScheduler-3.10.1.tar.gz", hash = "sha256:0293937d8f6051a0f493359440c1a1b93e882c57daf0197afeff0e727777b96e"}, -] - -[package.dependencies] -pytz = "*" -setuptools = ">=0.7" -six = ">=1.4.0" -tzlocal = ">=2.0,<3.0.0 || >=4.0.0" - -[package.extras] -doc = ["sphinx", "sphinx-rtd-theme"] -gevent = ["gevent"] -mongodb = ["pymongo (>=3.0)"] -redis = ["redis (>=3.0)"] -rethinkdb = ["rethinkdb (>=2.4.0)"] -sqlalchemy = ["sqlalchemy (>=1.4)"] -testing = ["pytest", "pytest-asyncio", "pytest-cov", "pytest-tornado5"] -tornado = ["tornado (>=4.3)"] -twisted = ["twisted"] -zookeeper = ["kazoo"] - [[package]] name = "certifi" version = "2022.12.7" @@ -365,33 +335,6 @@ typing-extensions = ">=4.2.0" dotenv = ["python-dotenv (>=0.10.4)"] email = ["email-validator (>=1.0.3)"] -[[package]] -name = "pytz" -version = "2023.3" -description = "World timezone definitions, modern and historical" -category = "main" -optional = false -python-versions = "*" -files = [ - {file = "pytz-2023.3-py2.py3-none-any.whl", hash = "sha256:a151b3abb88eda1d4e34a9814df37de2a80e301e68ba0fd856fb9b46bfbbbffb"}, - {file = "pytz-2023.3.tar.gz", hash = "sha256:1d8ce29db189191fb55338ee6d0387d82ab59f3d00eac103412d64e0ebd0c588"}, -] - -[[package]] -name = "pytz-deprecation-shim" -version = "0.1.0.post0" -description = "Shims to make deprecation of pytz easier" -category = "main" -optional = false -python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,>=2.7" -files = [ - {file = "pytz_deprecation_shim-0.1.0.post0-py2.py3-none-any.whl", hash = "sha256:8314c9692a636c8eb3bda879b9f119e350e93223ae83e70e80c31675a0fdc1a6"}, - {file = "pytz_deprecation_shim-0.1.0.post0.tar.gz", hash = "sha256:af097bae1b616dde5c5744441e2ddc69e74dfdcb0c263129610d85b87445a59d"}, -] - -[package.dependencies] -tzdata = {version = "*", markers = "python_version >= \"3.6\""} - [[package]] name = "requests" version = "2.29.0" @@ -418,7 +361,7 @@ use-chardet-on-py3 = ["chardet (>=3.0.2,<6)"] name = "setuptools" version = "67.7.2" description = "Easily download, build, install, upgrade, and uninstall Python packages" -category = "main" +category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -431,18 +374,6 @@ docs = ["furo", "jaraco.packaging (>=9)", "jaraco.tidelift (>=1.4)", "pygments-g testing = ["build[virtualenv]", "filelock (>=3.4.0)", "flake8 (<5)", "flake8-2020", "ini2toml[lite] (>=0.9)", "jaraco.envs (>=2.2)", "jaraco.path (>=3.2.0)", "pip (>=19.1)", "pip-run (>=8.8)", "pytest (>=6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=1.3)", "pytest-flake8", "pytest-mypy (>=0.9.1)", "pytest-perf", "pytest-timeout", "pytest-xdist", "tomli-w (>=1.0.0)", "virtualenv (>=13.0.0)", "wheel"] testing-integration = ["build[virtualenv]", "filelock (>=3.4.0)", "jaraco.envs (>=2.2)", "jaraco.path (>=3.2.0)", "pytest", "pytest-enabler", "pytest-xdist", "tomli", "virtualenv (>=13.0.0)", "wheel"] -[[package]] -name = "six" -version = "1.16.0" -description = "Python 2 and 3 compatibility utilities" -category = "main" -optional = false -python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*" -files = [ - {file = "six-1.16.0-py2.py3-none-any.whl", hash = "sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254"}, - {file = "six-1.16.0.tar.gz", hash = "sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926"}, -] - [[package]] name = "sniffio" version = "1.3.0" @@ -507,7 +438,7 @@ files = [ ] [package.dependencies] -greenlet = {version = "!=0.4.17", markers = "python_version >= \"3\" and platform_machine == \"aarch64\" or python_version >= \"3\" and platform_machine == \"ppc64le\" or python_version >= \"3\" and platform_machine == \"x86_64\" or python_version >= \"3\" and platform_machine == \"amd64\" or python_version >= \"3\" and platform_machine == \"AMD64\" or python_version >= \"3\" and platform_machine == \"win32\" or python_version >= \"3\" and platform_machine == \"WIN32\""} +greenlet = {version = "!=0.4.17", markers = "python_version >= \"3\" and (platform_machine == \"aarch64\" or platform_machine == \"ppc64le\" or platform_machine == \"x86_64\" or platform_machine == \"amd64\" or platform_machine == \"AMD64\" or platform_machine == \"win32\" or platform_machine == \"WIN32\")"} [package.extras] aiomysql = ["aiomysql", "greenlet (!=0.4.17)"] @@ -560,37 +491,6 @@ files = [ {file = "typing_extensions-4.5.0.tar.gz", hash = "sha256:5cb5f4a79139d699607b3ef622a1dedafa84e115ab0024e0d9c044a9479ca7cb"}, ] -[[package]] -name = "tzdata" -version = "2023.3" -description = "Provider of IANA time zone data" -category = "main" -optional = false -python-versions = ">=2" -files = [ - {file = "tzdata-2023.3-py2.py3-none-any.whl", hash = "sha256:7e65763eef3120314099b6939b5546db7adce1e7d6f2e179e3df563c70511eda"}, - {file = "tzdata-2023.3.tar.gz", hash = "sha256:11ef1e08e54acb0d4f95bdb1be05da659673de4acbd21bf9c69e94cc5e907a3a"}, -] - -[[package]] -name = "tzlocal" -version = "4.3" -description = "tzinfo object for the local timezone" -category = "main" -optional = false -python-versions = ">=3.7" -files = [ - {file = "tzlocal-4.3-py3-none-any.whl", hash = "sha256:b44c4388f3d34f25862cfbb387578a4d70fec417649da694a132f628a23367e2"}, - {file = "tzlocal-4.3.tar.gz", hash = "sha256:3f21d09e1b2aa9f2dacca12da240ca37de3ba5237a93addfd6d593afe9073355"}, -] - -[package.dependencies] -pytz-deprecation-shim = "*" -tzdata = {version = "*", markers = "platform_system == \"Windows\""} - -[package.extras] -devenv = ["black", "check-manifest", "flake8", "pyroma", "pytest (>=4.3)", "pytest-cov", "pytest-mock (>=3.3)", "zest.releaser"] - [[package]] name = "urllib3" version = "1.26.15" @@ -630,4 +530,4 @@ standard = ["colorama (>=0.4)", "httptools (>=0.5.0)", "python-dotenv (>=0.13)", [metadata] lock-version = "2.0" python-versions = "^3.10" -content-hash = "5940b34c9293403d35f3b4df118768a86f04874bdbebba0ad30570428876cf78" +content-hash = "28f1aa3c3c4cb73bfd792180aaa8f7638002301e1391b5cdc2856acdcdeb6eb2" diff --git a/backend/pyproject.toml b/backend/pyproject.toml index f3c2535..430af58 100644 --- a/backend/pyproject.toml +++ b/backend/pyproject.toml @@ -10,12 +10,10 @@ python = "^3.10" uvicorn = "^0.22.0" fastapi = "^0.95.1" requests = "^2.29.0" -apscheduler = "^3.10.1" fastapi-utils = "^0.2.1" -[tool.poetry.scripts] -dev = "app.__main__:__main__" - +[tool.poetry.group.dev.dependencies] +setuptools = "^67.7.2" [build-system] requires = ["poetry-core"] diff --git a/docker-compose.yml b/docker-compose.yml index 5fc9a27..b1a0fef 100755 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,4 +1,4 @@ -version: "3.9" +version: "3.8" services: backend: @@ -6,16 +6,19 @@ services: container_name: mootfrost-dev_backend restart: always build: backend/ + environment: + - BIRTHDATE=2007-10-13 + - HOST=0.0.0.0 frontend: image: git.mootfrost.dev/mootfrost777/mootfrost-dev_frontend:latest container_name: mootfrost-dev_frontend restart: always build: frontend/ - depends_on: backend - environment: - - + depends_on: + - backend labels: - traefik.enable=true - traefik.http.routers.mootfrost_dev.rule=Host(`mootfrost.dev`) + # Website port ports: - - "7632:7632" \ No newline at end of file + - "7632:3000" diff --git a/frontend/.env b/frontend/.env new file mode 100644 index 0000000..8261e94 --- /dev/null +++ b/frontend/.env @@ -0,0 +1,3 @@ +VITE_BACKEND=http://backend:8888 +VITE +VITE_PORT=3000 \ No newline at end of file diff --git a/frontend/Dockerfile b/frontend/Dockerfile index 7ddd4aa..53f4ebd 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -7,6 +7,6 @@ RUN yarn install --production=true EXPOSE 3000 COPY . . -CMD ["yarn", "dev", "--port", "3000"] +CMD ["yarn", "dev", "--port", "3000", "--host", "0.0.0.0"] diff --git a/frontend/package.json b/frontend/package.json index f710df1..e563636 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -12,6 +12,7 @@ "@popperjs/core": "^2.11.7", "axios": "^1.4.0", "bootstrap": "^5.2.3", + "dotenv": "^16.0.3", "tsparticles": "^2.9.3", "vue": "^3.2.47", "vue-inline-svg": "^3.1.2", diff --git a/frontend/src/App.vue b/frontend/src/App.vue index a99824e..d820bc9 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -1,7 +1,6 @@