Customizing the Python runtime

You can use custom runtimes to add additional functionality to a Python app running in the flexible environment. To configure a custom runtime, you replace this line in your app.yaml file:

runtime: python

with this line:

runtime: custom

You must also specify a base image by adding a Dockerfile in the same directory that contains the app.yaml file.

Visit the Custom runtimes documentation to learn how to define a Dockerfile in a custom runtime.

Health Checking

By default, all programs running in the flexible environment receive health check requests. If a base image supports health checking, you don't need to write any additional code. If it does not, you will need to disable health checks, or write your own code to handle health check requests.

Selecting the Python version

The python runtime has Python 2.7.12 and Python 3.6.10 pre-installed. You can customize the Dockerfile to install other versions or alternative interpreters if needed.

You can specify a whether to use Python 2 or Python 3 in your application's Dockerfile when creating the virtual environment:

# Python 3
RUN venv /env -p python3.7

# Python 2 (implicit)
RUN virtualenv /env

# Python 2 (explicit)
RUN virtualenv /env -p python2.7