Skip to content

Commit

Permalink
split tunnel and admin, rewrite admin in py
Browse files Browse the repository at this point in the history
  • Loading branch information
amalshaji committed Feb 25, 2024
1 parent 27f5427 commit 7e0e194
Show file tree
Hide file tree
Showing 280 changed files with 5,024 additions and 4,599 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ portr
!**/portr/
postgres-data
node_modules
.mypy_cache
data/
30 changes: 30 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
repos:
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: "v0.2.2"
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
exclude: "(^.*/migrations/|^client/)"
- id: ruff-format
exclude: "(^.*/migrations/|^client/)"

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: trailing-whitespace
exclude: "(^.*/migrations/|^client/)"
- id: check-merge-conflict
- id: debug-statements
- id: check-added-large-files

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.8.0
hooks:
- id: mypy
args:
- --follow-imports=skip
- --ignore-missing-imports
- --show-column-numbers
- --no-pretty
- --check-untyped-defs
exclude: '(^.*/migrations/|^client/|_tests\.py$)'
7 changes: 7 additions & 0 deletions admin/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.mypy_cache
.pytest_cache
.venv
tmp
.env
**/__pycache__
**/node_modules
4 changes: 4 additions & 0 deletions admin/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.venv
.mypy_cache
.pytest_cache
__pycache__
1 change: 1 addition & 0 deletions admin/.python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.12.1
36 changes: 36 additions & 0 deletions admin/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
FROM node:20-slim as frontend-builder

WORKDIR /app

COPY src/web/package.json src/web/pnpm-lock.yaml ./

RUN npm i -g pnpm && pnpm install --frozen-lockfile

COPY src/web .

RUN pnpm build

FROM python:3.12 as builder

ENV PATH="/app/.venv/bin:$PATH"

WORKDIR /app

COPY requirements.lock .

RUN python3 -m venv .venv

RUN sed '/-e/d' requirements.lock > requirements.txt && pip install --no-cache-dir -r requirements.txt

FROM python:3.12-slim as final

ENV PATH="/app/.venv/bin:$PATH" \
PYTHONPATH="/app/src:$PYTHONPATH"

WORKDIR /app

COPY --from=builder /app/.venv/ /app/.venv/
COPY --from=frontend-builder /app/dist /app/src/web/dist
COPY . .

ENTRYPOINT ["sh", "scripts/start.sh"]
3 changes: 3 additions & 0 deletions admin/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# portr-admin

Describe your project here.
46 changes: 46 additions & 0 deletions admin/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
[project]
name = "portr-admin"
version = "0.1.0"
description = "Add your description here"
authors = [{ name = "amalshaji", email = "[email protected]" }]
dependencies = [
"nanoid>=2.0.0",
"fastapi>=0.109.2",
"uvicorn>=0.27.1",
"tortoise-orm[asyncpg]>=0.20.0",
"pydantic-settings>=2.2.0",
"httpx>=0.26.0",
"jinja2>=3.1.3",
"python-slugify[unidecode]>=8.0.4",
"python-ulid>=2.2.0",
"apscheduler>=3.10.4",
"pydantic>=2.6.1",
"email-validator>=2.1.0.post1",
]
readme = "README.md"
requires-python = ">= 3.8"

[project.scripts]
hello = "portr_admin:hello"

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.rye]
managed = true
dev-dependencies = [
"pre-commit>=3.5.0",
"pytest>=8.0.1",
"factory-boy>=3.3.0",
"pytest-asyncio>=0.23.5",
"asgi-lifespan>=2.1.0",
"async-factory-boy>=1.0.1",
"mimesis>=14.0.0",
]

[tool.hatch.metadata]
allow-direct-references = true

[tool.hatch.build.targets.wheel]
packages = ["src/portr_admin"]
131 changes: 131 additions & 0 deletions admin/requirements-dev.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
# generated by rye
# use `rye lock` or `rye sync` to update this lockfile
#
# last locked with the following flags:
# pre: false
# features: []
# all-features: false
# with-sources: false

-e file:.
aiosqlite==0.17.0
# via tortoise-orm
annotated-types==0.6.0
# via pydantic
anyio==4.3.0
# via httpx
# via starlette
apscheduler==3.10.4
# via portr-admin
asgi-lifespan==2.1.0
async-factory-boy==1.0.1
asyncpg==0.29.0
# via tortoise-orm
certifi==2024.2.2
# via httpcore
# via httpx
cfgv==3.4.0
# via pre-commit
click==8.1.7
# via uvicorn
distlib==0.3.8
# via virtualenv
dnspython==2.6.1
# via email-validator
email-validator==2.1.0.post1
# via portr-admin
factory-boy==3.3.0
# via async-factory-boy
faker==23.2.1
# via factory-boy
fastapi==0.109.2
# via portr-admin
filelock==3.13.1
# via virtualenv
h11==0.14.0
# via httpcore
# via uvicorn
httpcore==1.0.3
# via httpx
httpx==0.26.0
# via portr-admin
identify==2.5.35
# via pre-commit
idna==3.6
# via anyio
# via email-validator
# via httpx
iniconfig==2.0.0
# via pytest
iso8601==1.1.0
# via tortoise-orm
jinja2==3.1.3
# via portr-admin
markupsafe==2.1.5
# via jinja2
mimesis==14.0.0
nanoid==2.0.0
# via portr-admin
nodeenv==1.8.0
# via pre-commit
packaging==23.2
# via pytest
platformdirs==4.2.0
# via virtualenv
pluggy==1.4.0
# via pytest
pre-commit==3.6.2
pydantic==2.6.1
# via fastapi
# via portr-admin
# via pydantic-settings
pydantic-core==2.16.2
# via pydantic
pydantic-settings==2.2.1
# via portr-admin
pypika-tortoise==0.1.6
# via tortoise-orm
pytest==8.0.1
# via pytest-asyncio
pytest-asyncio==0.23.5
python-dateutil==2.8.2
# via faker
python-dotenv==1.0.1
# via pydantic-settings
python-slugify==8.0.4
# via portr-admin
python-ulid==2.2.0
# via portr-admin
pytz==2024.1
# via apscheduler
# via tortoise-orm
pyyaml==6.0.1
# via pre-commit
setuptools==69.1.0
# via nodeenv
six==1.16.0
# via apscheduler
# via python-dateutil
sniffio==1.3.0
# via anyio
# via asgi-lifespan
# via httpx
starlette==0.36.3
# via fastapi
text-unidecode==1.3
# via python-slugify
tortoise-orm==0.20.0
# via portr-admin
typing-extensions==4.9.0
# via aiosqlite
# via fastapi
# via pydantic
# via pydantic-core
tzlocal==5.2
# via apscheduler
unidecode==1.3.8
# via python-slugify
uvicorn==0.27.1
# via portr-admin
virtualenv==20.25.0
# via pre-commit
92 changes: 92 additions & 0 deletions admin/requirements.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# generated by rye
# use `rye lock` or `rye sync` to update this lockfile
#
# last locked with the following flags:
# pre: false
# features: []
# all-features: false
# with-sources: false

-e file:.
aiosqlite==0.17.0
# via tortoise-orm
annotated-types==0.6.0
# via pydantic
anyio==4.3.0
# via httpx
# via starlette
apscheduler==3.10.4
# via portr-admin
asyncpg==0.29.0
# via tortoise-orm
certifi==2024.2.2
# via httpcore
# via httpx
click==8.1.7
# via uvicorn
dnspython==2.6.1
# via email-validator
email-validator==2.1.0.post1
# via portr-admin
fastapi==0.109.2
# via portr-admin
h11==0.14.0
# via httpcore
# via uvicorn
httpcore==1.0.3
# via httpx
httpx==0.26.0
# via portr-admin
idna==3.6
# via anyio
# via email-validator
# via httpx
iso8601==1.1.0
# via tortoise-orm
jinja2==3.1.3
# via portr-admin
markupsafe==2.1.5
# via jinja2
nanoid==2.0.0
# via portr-admin
pydantic==2.6.1
# via fastapi
# via portr-admin
# via pydantic-settings
pydantic-core==2.16.2
# via pydantic
pydantic-settings==2.2.1
# via portr-admin
pypika-tortoise==0.1.6
# via tortoise-orm
python-dotenv==1.0.1
# via pydantic-settings
python-slugify==8.0.4
# via portr-admin
python-ulid==2.2.0
# via portr-admin
pytz==2024.1
# via apscheduler
# via tortoise-orm
six==1.16.0
# via apscheduler
sniffio==1.3.0
# via anyio
# via httpx
starlette==0.36.3
# via fastapi
text-unidecode==1.3
# via python-slugify
tortoise-orm==0.20.0
# via portr-admin
typing-extensions==4.9.0
# via aiosqlite
# via fastapi
# via pydantic
# via pydantic-core
tzlocal==5.2
# via apscheduler
unidecode==1.3.8
# via python-slugify
uvicorn==0.27.1
# via portr-admin
Loading

0 comments on commit 7e0e194

Please sign in to comment.