See the accompanying blog post for more information.
- Make sure you have poetry, the AWS CLI & docker installed on your system
- Clone the repo and set your working directory to the root of the repository (i.e.
cd path/to/zappa-serverless-docker
) - Run
poetry install --no-root
- You may need to run
pip install --upgrade pip
after (for some reason poetry is using an older version of pip
- You may need to run
- Activate your new virtual environment with
poetry shell
- Run
zappa save-python-settings-file lambda_docker_flask -o zappa_settings.py
to generate & save the Python settings file required by Zappa - Build the Docker image with
docker build -t lambda-docker-flask:latest .
- Create a new ECR repository by running
aws ecr create-repository --repository-name lambda-docker-flask --image-scanning-configuration scanOnPush=true
- Authenticate your local machine so it can push images to your repostiroy by running
aws ecr get-login-password | docker login --username AWS --password-stdin <your_registry_id>.dkr.ecr.us-east-1.amazonaws.com
- Point your Docker image to your new repository
docker tag lambda-docker-flask:latest <your_registry_id>.dkr.ecr.us-east-1.amazonaws.com/lambda-docker-flask:latest
- And push it
docker push <your_registry_id>.dkr.ecr.us-east-1.amazonaws.com/lambda-docker-flask:latest
Deploying the lambda function with your new Docker image can be accomplished by using the zappa deploy
command and passing in the Docker image URI:
zappa deploy lambda_docker_flask -d <your_registry_id>.dkr.ecr.us-east-1.amazonaws.com/lambda-docker-flask:latest