This repository provides a sample Python web application implemented using the Flask web framework and hosted using gunicorn
. It is intended to be used to demonstrate deployment of Python web applications to The Digital Garage via a CI/CD pipeline.
This sample Python application relies on the support provided by the default S2I builder for deploying a WSGI application using the gunicorn
WSGI server. The requirements which need to be satisfied for this to work are:
- The WSGI application code file needs to be named
wsgi.py
. - The WSGI application entry point within the code file needs to be named
application
. - The
gunicorn
package must be listed in therequirements.txt
file forpip
.
In addition, the .s2i/environment
file has been created to allow environment variables to be set to override the behaviour of the default S2I builder for Python.
- The environment variable
APP_CONFIG
has been set to declare the name of the config file forgunicorn
.
Using the oc
command line tool to deploy this sample Python web application, you can run:
oc new-app --name=py-demo-app openshift/python:latest~/~https://github.com/thedigitalgarage/devops-python-ex.git#master
In this case, because no language type was specified, OpenShift will determine the language by inspecting the code repository. Because the code repository contains a requirements.txt
, it will subsequently be interpreted as including a Python application. When such automatic detection is used, python:latest
will be used.
If needing to select a specific Python version when using oc new-app
, you should instead use the form:
oc new-app python:3.6.5~/~https://github.com/thedigitalgarage/devops-python-ex.git