In a previous post, Matthew Crowson reviewed how to get a docker environment that closely resembles the AWS lambda environment. This allows you to have a local environment that can be used to debug package and other system library installations.

Since that blog post was published, AWS announced support for Python 3.6 and some things have changed. This post goes through the process of setting up your own docker environment for zappa using Python 3.6.

Pull the Docker Image

We'll pull directly from the lambci images directly by running: docker pull lambci/lambda:build-python3.6

Setup your Dockerfile

The Dockerfile is important to allow you to customize any system library dependencies.

If you need to compile stuff or install any packages that are not in lambda-packages you can install them using Dockerfile

Build your Docker Image

Easy by running docker build -t myzappa .

Add an alias for quick access

Note there are many alternative options depending on how you have setup your AWS credentials

Get rolling

Now you can easily start up the docker container by:

cd /myzappaproject zappashell

And setup your virtual environment

python -m venv ve source ve/bin/activate pip install -r requirements.txt

NOTE: It is very important that you create, activate, and install packages into the virtualenv only in the docker shell. This will prevent any incompatibilities with the local system environment and the docker environment.

More info and advanced setup

More info including a dual-python version setup can be found here

News, announcements and commentary from Zappa, Python's server-less framework.

Build Status

PyPI

Slack

Patreon

Star

Made by Gun.io