Skip to content

Commit

Permalink
Adding Dockerfile and Lambda handler.
Browse files Browse the repository at this point in the history
  • Loading branch information
mindflayer committed Apr 17, 2024
1 parent 3c65d87 commit 61d3dfb
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 3 deletions.
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: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ __pycache__
/.coverage
/.pytest_cache
/.ruff_cache
.idea
15 changes: 15 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM python:3.12-slim

ENV PYTHONUNBUFFERED 1
ENV DEBIAN_FRONTEND=noninteractive

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
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: OrderPayload, request: Request) -> Order:
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

0 comments on commit 61d3dfb

Please sign in to comment.