AWS Lambda - Container #166
-
Trying out building a quick and simple app to use with the HTTP API and AWS Lambda with a container. I can set up the app locally and hit it locally, however I am not sure if I am missing something but I cannot get it working in Lambda with a container. Super simple main.py file that looks like the following:
With my Dockerfile it looks like the following:
I created a HTTP API and basically just have a single proxy route that points to my Lambda.
I am not sure if the handler part is correct for the container or does it need to be a uvicorn command to run the app.main:app file? The error I was seeing in Cloudwatch looks like this.
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
@stephenbawks
And, I fixed your Dockerfile. # Define function directory
FROM public.ecr.aws/lambda/python:3.8
RUN pip install poetry
COPY ./app /var/task/app
COPY ./poetry.lock ./pyproject.toml ./
RUN poetry config virtualenvs.create false && poetry install --no-dev
CMD [ "app.main.handler" ]
You should think about how to use poetry. this example may not best practice on poetry. |
Beta Was this translation helpful? Give feedback.
-
Thanks @koxudaxi. @stephenbawks closing this because it doesn't seem related to Mangum itself, but feel free to continue discussion if the previous comment did not clear thing things up. |
Beta Was this translation helpful? Give feedback.
@stephenbawks
Did you create
__init__.py
in theapp
directory?And, I fixed your Dockerfile.
You should think about how to use poetry. this example may not best practice on poetry.
Thank you.