This repository contains sources of the images for building various versions of Python applications as reproducible Docker images using source-to-image. User can choose between RHEL and CentOS based builder images. The resulting image can be run using Docker.
Python versions currently provided are:
- python-3.3
RHEL versions currently supported are:
- RHEL7
CentOS versions currently supported are:
- CentOS7
To build Python image, choose between CentOS or RHEL based image:
-
RHEL based image
To build a rhel-based python-3.3 image, you need to run the build on a properly subscribed RHEL machine.
$ git clone https://github.com/openshift/sti-python.git $ cd sti-python $ make build TARGET=rhel7 VERSION=3.3
-
CentOS based image
This image is available on DockerHub. To download it use:
$ docker pull openshift/python-33-centos7
To build Python image from scratch use:
$ git clone https://github.com/openshift/sti-python.git $ cd sti-python $ make build VERSION=3.3
Notice: By omitting the VERSION
parameter, the build/test action will be performed
on all provided versions of Python. Since we are now providing only version 3.3
,
you can omit this parameter.
To build a simple python-sample-app application, using standalone STI and then run the resulting image with Docker execute:
-
For RHEL based image
$ sti build https://github.com/openshift/sti-python.git --context-dir=3.3/test/setup-test-app/ openshift/python-33-rhel7 python-sample-app $ docker run -p 8080:8080 python-sample-app
-
For CentOS based image
$ sti build https://github.com/openshift/sti-python.git --context-dir=3.3/test/setup-test-app/ openshift/python-33-centos7 python-sample-app $ docker run -p 8080:8080 python-sample-app
Accessing the application:
$ curl 127.0.0.1:8080
This repository also provides STI test framework, which launches tests to check functionality of a simple python application built on top of sti-python image.
User can choose between testing python test application based on RHEL or CentOS image.
-
RHEL based image
To test a rhel7-based python-3.3 image, you need to run the test on a properly subscribed RHEL machine.
$ cd sti-python $ make test TARGET=rhel7 VERSION=3.3
-
CentOS based image
$ cd sti-python $ make test VERSION=3.3
Notice: By omitting the VERSION
parameter, the build/test action will be performed
on all provided versions of Python. Since we are now providing only version 3.3
you can omit this parameter.
-
<python-version>
-
Dockerfile
CentOS based Dockerfile.
-
Dockerfile.rhel7
RHEL based Dockerfile. In order to perform build or test actions on this Dockerfile you need to run the action on a properly subscribed RHEL machine.
-
.sti/bin/
This folder contains scripts that are run by STI:
-
assemble
Is used to install the sources into location from where the application will be run and prepare the application for deployment (eg. installing dependencies, etc.)
-
run
This script is responsible for running the application, by using the application web server.
-
usage*
This script prints the usage of this image.
-
-
contrib/
This folder contains file with commonly used modules.
-
test/
This folder is containing STI test framework with simple server.
-
-
hack/
Folder contains scripts which are responsible for build and test actions performed by the
Makefile
.
- Platform name - python
- Platform version(without dots)
- Base builder image - centos7/rhel7
Examples: openshift/python-33-centos7
, openshift/python-33-rhel7
To set these environment variables, you can place them into .sti/environment
file inside your source code repository.
-
APP_FILE
This variable specifies file name (defaults to
app.py
) passed to the python interpreter which is responsible for launching application. -
APP_MODULE
This variable specifies WSGI callable. It is of the pattern
$(MODULE_NAME):$(VARIABLE_NAME)
, where module name is a full dotted path and the variable name refers to a inside the specified module. If usingsetup.py
for installing the application the module name can be read from that file and variable will default toapplication
, eg. see setup-test-app. -
APP_CONFIG
This variable indicates path to a module which contains gunicorn configuration.