Skip to content

Latest commit

 

History

History
 
 

runtime

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

google/python-runtime

google/python-runtime is a docker base image that makes it easy to dockerize standard Python application.

It can automatically bundle a Python application and its dependencies with a single line Dockerfile.

It is based on google/python base image.

Usage

  • Create a Dockerfile in your python application directory with the following content:

      FROM google/python-runtime
    
  • Run the following command in your application directory:

      docker build -t app .
    

Sample

See the sources for google/python-hello based on this image.

Notes

The image assumes that your application:

  • has a requirements.txt file to specify its dependencies
  • listens on port 8080
  • either has a main.py script as entrypoint or defines ENTRYPOINT ["/env/bin/python", "/app/some_other_file.py"] in its Dockerfile

When building your application docker image, ONBUILD triggers:

  • Create a new virtualenv under the /env directory in the container
  • Fetch the dependencies listed in requirements.txt into the virtualenv using pip install and leverage docker caching appropriately
  • Copy the application sources under the /app directory in the container