Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Dockerfile and Lambda handler #18

Merged
merged 4 commits into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
scripts
tests
1 change: 0 additions & 1 deletion .gitattributes

This file was deleted.

3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
__pycache__
*.sqlite
/.coverage
/.pytest_cache
Expand All @@ -9,3 +8,5 @@ __pycache__
.venv
__pycache__
.env

.idea
14 changes: 14 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM python:3.12-slim

ENV PYTHONUNBUFFERED 1

RUN pip install --no-cache-dir --no-cache poetry

COPY poetry.lock pyproject.toml /

RUN poetry install --no-cache --sync --no-interaction --with lambda && \
rm poetry.lock pyproject.toml && \
pip uninstall --yes poetry

COPY . /app
WORKDIR /app
16 changes: 15 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,17 @@ geoalchemy2 = "^0.14.6"
shapely = "^2.0.3"
pre-commit = "^3.7.0"

[tool.poetry.group.lambda.dependencies]
mangum = "^0.17.0"

[tool.poetry.scripts]
dev = "stat_fastapi.__dev__:cli"

[tool.ruff]
extend-ignore = ["E501", "UP007", "UP034"]
line-length = 88

[tool.ruff.lint]
extend-ignore = ["E501", "UP007", "UP034"]
select = [
"C9",
"E",
Expand All @@ -42,7 +47,7 @@ select = [
"UP"
]

[tool.ruff.mccabe]
[tool.ruff.lint.mccabe]
max-complexity = 8

[tool.coverage.report]
Expand Down
10 changes: 10 additions & 0 deletions stat_fastapi/lambda_handler.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from fastapi import FastAPI
from mangum import Mangum

from stat_fastapi.api import StatApiRouter
from stat_fastapi_test_backend import TestBackend

app = FastAPI()
app.include_router(StatApiRouter(backend=TestBackend()).router)

handler = Mangum(app, lifespan="off")
2 changes: 1 addition & 1 deletion stat_fastapi_test_backend/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ async def create_order(self, payload: OpportunitySearch, request: Request) -> Or
return order
raise ConstraintsException("not allowed")

async def get_order(self, order_id: str, request: Request):
async def get_order(self, order_id: str, request: Request) -> Order:
"""
Show details for order with `order_id`.
"""
Expand Down