{"id":21206192,"url":"https://github.com/rtmigo/lambdarado_py","last_synced_at":"2025-07-10T08:32:55.167Z","repository":{"id":41039900,"uuid":"365874393","full_name":"rtmigo/lambdarado_py","owner":"rtmigo","description":"Universal entry point for Docker images with Flask apps for the AWS Lambda + AWS Gateway serverless hosting","archived":false,"fork":false,"pushed_at":"2022-03-10T02:42:32.000Z","size":148,"stargazers_count":4,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-16T03:15:49.861Z","etag":null,"topics":["amazon","api","aws","container","docker","dockerfile","entrypoint","flask","gateway","http","image","lambda","package","python","serverless","wsgi"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/lambdarado/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rtmigo.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-05-10T00:17:42.000Z","updated_at":"2022-06-28T02:44:59.000Z","dependencies_parsed_at":"2022-08-29T02:01:17.120Z","dependency_job_id":null,"html_url":"https://github.com/rtmigo/lambdarado_py","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rtmigo%2Flambdarado_py","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rtmigo%2Flambdarado_py/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rtmigo%2Flambdarado_py/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rtmigo%2Flambdarado_py/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rtmigo","download_url":"https://codeload.github.com/rtmigo/lambdarado_py/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225629877,"owners_count":17499294,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["amazon","api","aws","container","docker","dockerfile","entrypoint","flask","gateway","http","image","lambda","package","python","serverless","wsgi"],"created_at":"2024-11-20T20:54:44.884Z","updated_at":"2024-11-20T20:54:45.520Z","avatar_url":"https://github.com/rtmigo.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"Lambdarado puts together:\n\n- A [Flask](https://pypi.org/project/Flask/) app written in Python\n\n- A [Docker image](https://docs.aws.amazon.com/lambda/latest/dg/images-create.html)\nthat contains the app code and dependencies\n\n- AWS Lambda + AWS Gateway to run the app in the AWS\n\n- [Werkzeug](https://pypi.org/project/Werkzeug/) to test app locally \n\n---\n\nIt runs the relevant code depending on where it runs.\n\nOn the local computer, it runs\nthe a debug server, serving requests to\n`127.0.0.1` with your `app`. You can start it directly (`python3 main.py`) or from a\ncontainer (`docker run ...`) to test the app.\n\nIn the AWS Cloud the requests are handled with the same `app`, but in a\ndifferent way. Lambdarado creates\na [handler](https://docs.aws.amazon.com/lambda/latest/dg/python-handler.html),\nthat is compatible with the combination of API Gateway + Lambda.\n\n---\n\n\n\n\n# Install\n\n``` bash\n$ pip3 install lambdarado \n```\n\n# Configure\n\n#### Dockerfile:\n\n``` Dockerfile\nFROM public.ecr.aws/lambda/python:3.8\n\n# ... here should be the code that creates the image ...\n\nENTRYPOINT [\"python\", \"main.py\"]\n```\n\nYou build the image [as usual](https://docs.aws.amazon.com/lambda/latest/dg/images-create.html),\nbut the `ENTRYPOINT` is just a call to a `.py` file in the project root.\nAnd there is no `CMD`.\n\n#### main.py\n\n``` python3\nfrom lambdarado import start\n\ndef get_app():\n  # this function must return WSGI app, e.g. Flask\n  from my_app_module import app\n  return app \n  \nstart(get_app)\n```\n\nWhen starting the Lambda function instance, the `get_app` method will run *once*,\nbut the `main.py` module will be imported *twice*. Make sure that the app is only created\nwhen `get_app` is called, not when `main.py` is imported.\n\nIn other words, simply running `python3 main.py` without calling `start` should \nNOT do anything heavy and probably should not even declare or import the `app`.\n\n# Run\n\nLocal debug server\n------------------\n\nRunning shell command on development machine:\n\n```\n$ python3 main.py\n```\n\nThis will start Werkzeug server listening to http://127.0.0.1:5000.\n\n\nLocal debug server in Docker\n----------------------------\n\nCommand-line:\n\n``` bash\n$ docker run -p 5005:5000 docker-image-name\n```\n\nThis will start Werkzeug server listening to http://0.0.0.0:5000\n(inside the docker). The server is accessible as http://127.0.0.1:5005\nfrom the development (host) machine.\n\n\nProduction server on AWS Lambda\n-------------------------------\n\nAfter deploying the same image as a Lambda function, it will serve the requests\nto the AWS Gateway with your `app`.\n\n- You should connect the AWS Gateway to your Lambda function. For the function\n  to receive all HTTP requests, you may need to redirect the `/{proxy+}` route\n  to the function and make `lambda:InvokeFunction` policy less restrictive\n\nUnder the hood:\n\n- The [awslambdaric](https://pypi.org/project/awslambdaric/) will receive\n  requests from and send requests to the Lambda service\n- The [apig_wsgi](https://pypi.org/project/apig-wsgi/) will translate requests\n  received by `awslambdaric` from the AWS Gateway. So your application doesn't\n  have to handle calls from the gateway directly. For the application, requests\n  will look like normal HTTP\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frtmigo%2Flambdarado_py","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frtmigo%2Flambdarado_py","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frtmigo%2Flambdarado_py/lists"}