{"id":14069488,"url":"https://github.com/kilna/python-lambda-docker","last_synced_at":"2026-03-12T01:36:31.490Z","repository":{"id":68716492,"uuid":"102022669","full_name":"kilna/python-lambda-docker","owner":"kilna","description":"Lightweight docker image for running, testing, packaging and deploying python-based AWS lambda functions","archived":false,"fork":false,"pushed_at":"2019-07-12T18:59:08.000Z","size":28,"stargazers_count":6,"open_issues_count":5,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-16T19:10:15.806Z","etag":null,"topics":["amazon","aws","aws-lambda","aws-lambda-python","docker-image","dockerfile","lambda","python","python-lambda"],"latest_commit_sha":null,"homepage":"","language":"Shell","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/kilna.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2017-08-31T16:42:16.000Z","updated_at":"2024-08-13T03:39:35.000Z","dependencies_parsed_at":"2023-04-07T20:31:40.235Z","dependency_job_id":null,"html_url":"https://github.com/kilna/python-lambda-docker","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/kilna/python-lambda-docker","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kilna%2Fpython-lambda-docker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kilna%2Fpython-lambda-docker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kilna%2Fpython-lambda-docker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kilna%2Fpython-lambda-docker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kilna","download_url":"https://codeload.github.com/kilna/python-lambda-docker/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kilna%2Fpython-lambda-docker/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30412088,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-12T00:40:14.898Z","status":"ssl_error","status_checked_at":"2026-03-12T00:40:08.439Z","response_time":84,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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","aws","aws-lambda","aws-lambda-python","docker-image","dockerfile","lambda","python","python-lambda"],"created_at":"2024-08-13T07:06:59.576Z","updated_at":"2026-03-12T01:36:31.476Z","avatar_url":"https://github.com/kilna.png","language":"Shell","readme":"# python-lambda-docker\n\n[![](https://images.microbadger.com/badges/image/kilna/python-lambda.svg)](https://microbadger.com/images/kilna/python-lambda)\n[![](https://img.shields.io/docker/pulls/kilna/python-lambda.svg?style=plastic)](https://hub.docker.com/r/kilna/python-lambda/)\n[![](https://img.shields.io/docker/stars/kilna/python-lambda.svg?style=plastic)](https://hub.docker.com/r/kilna/python-lambda/)\n[![](https://img.shields.io/badge/docker_build-automated-blue.svg?style=plastic)](https://cloud.docker.com/swarm/kilna/repository/docker/kilna/python-lambda/builds)\n[![](https://img.shields.io/badge/python-2.7,_3.6-blue.svg?style=plastic)](https://github.com/kilna/python-lambda-docker/)\n\nLightweight docker image for running, testing, packaging and deploying python-based AWS lambda functions\n\n## Links\n\n* Docker: [python-lambda](https://hub.docker.com/r/kilna/python-lambda/)\n* GitHub: [python-lambda-docker](https://github.com/kilna/python-lambda-docker)\n* Based on the [python-lambda library](https://github.com/nficano/python-lambda/) by [nficano](https://github.com/nficano/)\n\n## Purpose\n\nI needed a Docker-based environment in which to host AWS python lambda functions for the purpose of testing and building them... python-lambda works well under virtualenv for development, but build and deployment automation require a clean and reproducible environment to operate in. Our CI system already supported Docker as a containerization system, so it was the obvious choice.\n\nIn order to use this, you will have your project derive its own Dockerfile based on a base python-lambda image corresponding to which version of Python you wish to run.\n\n## Usage\n\nAn example of a usable project can be found in the [example/](./example/) directory.  The lambda function in [service.py](./example/service.py) takes a JSON input file like the one provided in [event.json](./example/event.json) and returns an ASCII-art version of the text described in it.  The [Dockerfile](./example/Dockerfile) derives from python-lambda as a base image, and loading the example directory contents into the image at the path _/lambda_, then installs dependencies from the [requirements.txt](./example/requirements.txt) file.  \n\n### Building a Derived Docker Image\n\nTo build a docker image from the provided [example/](./example) called _example-lambda-image_ with the ASCII-art lambda function in it, run:\n\n```\n$ cd example/\n$ docker build --tag example-lambda-image .\n```\n\nAny time you make changes to the example project, you'll need to re-run the `docker build` command above, or you can investigate using docker volumes to sync local filesystem changes into the container. \n\n#### Switching Python Versions\n\nThe example [Dockerfile](./example/Dockerfile) uses a _:latest_ docker tag in the FROM line, which is currently the same as _:3.6_, but if you wish to use a different Python version you can change this. Supported Python versions are 2.7 and 3.6. To use Python version 2.7 change the first line of the example [Dockerfile](./example/Dockerfile) to:\n\n```\nFROM kilna/python-lambda:2.7\n```\n\nYou will also need to change the following line in [config.yaml](./example/config.yaml)\n\n```\nruntime: python2.7\n```\n\n### Executing the Lambda Function\n\nIf you want to execute the lambda function against the [event.json](./example/event.json) input file:\n\n```\n$ docker run example-lambda-image lambda invoke\n _  _     _ _                        _    _ _\n| || |___| | |___    __ __ _____ _ _| |__| | |\n| __ / -_) | / _ \\_  \\ V  V / _ \\ '_| / _` |_|\n|_||_\\___|_|_\\___( )  \\_/\\_/\\___/_| |_\\__,_(_)\n                 |/\n```\n\n### Building and Testing the Lambda Function\n\nIf you would like to build the lambda function (which will package the function and all its dependencies), run:\n\n```\n$ docker run example-lambda-image lambda build\n```\n\nThe result will be a zip file created in the /lambda/dist directory inside the container.\n\nIf you would like to build and _test_ the lambda function and gather up the results, you can run:\n\n```\n$ docker run example-lambda-image lambda_build_tar | tar -x -v\nbuild.log\ntest.log\ndist/\ndist/2017-09-01-003647-example-lambda.zip\n```\n\nBehind the scenes, what this does is:\n\n* Removes any log and dist files from prior runs\n* Executes 'lambda build' and stores the log in _/lambda/build.log_ in the container\n* If present and executable, runs _/lambda/run_tests_ and stores the log in /lambda/test.log in the container\n* Tars the log files, and the contents of the dist directory in /lambda on the container and pipes it to standard output\n* Untars the contents bundled up within the container, and extracts them into your current directory\n\n### Deploying the Lambda Function\n\nYou can deploy your lambda function to Amazon's infrastructure...  you'll need to add AWS credentials into the [config.yaml](./example/config.yaml) file. Alternately, if your local AWS CLI environment is working, you can add a _.aws/_ directory (you can `cp ~/.aws`) into the _example/_ directory), then re-build your image. Once AWS is working within your container, you can then run the following to deploy your function to Amazon:\n\n```\n$ docker run example-lambda-image lambda deploy\n```\n\n","funding_links":[],"categories":["Shell"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkilna%2Fpython-lambda-docker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkilna%2Fpython-lambda-docker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkilna%2Fpython-lambda-docker/lists"}