Skip to content

Instantly share code, notes, and snippets.

@mu373
Last active September 14, 2022 05:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mu373/c177c77863085b3205cec012eab0ce35 to your computer and use it in GitHub Desktop.
Save mu373/c177c77863085b3205cec012eab0ce35 to your computer and use it in GitHub Desktop.
AWS Lambda container on Docker template
def handler(event, context):
return 'Hello from AWS Lambda using Python!'
version: "3.6"
services:
lambda:
container_name: lambda
build: .
volumes:
- $HOME/.aws/:/root/.aws/
ports:
- "9000:8080"
env_file:
- .env.local
FROM public.ecr.aws/lambda/python:3.9
# Copy function code
COPY app.py ${LAMBDA_TASK_ROOT}
# Install the function's dependencies using file requirements.txt
# from your project folder.
COPY requirements.txt .
RUN pip3 install -r requirements.txt --target "${LAMBDA_TASK_ROOT}"
# Set the CMD to your handler (could also be done as a parameter override outside of the Dockerfile)
CMD [ "app.handler" ]
# some additional libraries
@mu373
Copy link
Author

mu373 commented Aug 5, 2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment