It can automatically bundle a Python application and its dependencies with a single line Dockerfile.
It is based on
wow73611/python base image.
Create a Dockerfile in your python application directory with the following content:
Run the following command in your application directory:
docker build -t my/app .
The image assumes that your application:
- has a
requirements.txtfile to specify its dependencies
- listens on port
- has a
main.pyscript as entrypoint
- or defines
ENTRYPOINT ["/env/bin/python", "/app/other.py"]in its
When building your application docker image,
- Create a new virtualenv under the
/envdirectory in the container
- Fetch the dependencies listed in
requirements.txtinto the virtualenv using
pip installand leverage docker caching appropriately
- Copy the application sources under the
/appdirectory in the container
This project heavily borrowed code from Google's google/python-runtime Docker image.