Pull changes from upstream repository.

This commit is contained in:
Marek Skalický 2018-10-29 09:36:11 +00:00
commit 8de2f6ec06
No known key found for this signature in database
GPG key ID: ADCAA1DEE100A66D
28 changed files with 2262 additions and 129 deletions

140
README.md
View file

@ -1,16 +1,33 @@
Python Docker image
Python 3.6 container image
===================
This repository contains the source for building various versions of
the Python application as a reproducible Docker image using
[source-to-image](https://github.com/openshift/source-to-image).
This container image includes Python 3.6 as a [S2I](https://github.com/openshift/source-to-image) base image for your Python 3.6 applications.
Users can choose between RHEL and CentOS based builder images.
The RHEL image is available in the [Red Hat Container Catalog](https://access.redhat.com/containers/#/registry.access.redhat.com/rhscl/python-36-rhel7)
as registry.access.redhat.com/rhscl/python-36-rhel7.
The CentOS image is then available on [Docker Hub](https://hub.docker.com/r/centos/python-36-centos7/)
as centos/python-36-centos7.
The resulting image can be run using [Docker](http://docker.io).
Description
-----------
Python 3.6 available as container is a base platform for
building and running various Python 3.6 applications and frameworks.
Python is an easy to learn, powerful programming language. It has efficient high-level
data structures and a simple but effective approach to object-oriented programming.
Python's elegant syntax and dynamic typing, together with its interpreted nature,
make it an ideal language for scripting and rapid application development in many areas
on most platforms.
This container image includes an npm utility, so users can use it to install JavaScript
modules for their web applications. There is no guarantee for any specific npm or nodejs
version, that is included in the image; those versions can be changed anytime and
the nodejs itself is included just to make the npm work.
Usage
---------------------
To build a simple [python-sample-app](https://github.com/openshift/s2i-python/tree/master/3.6/test/setup-test-app) application
To build a simple [python-sample-app](https://github.com/sclorg/s2i-python-container/tree/master/3.6/test/setup-test-app) application
using standalone [S2I](https://github.com/openshift/source-to-image) and then run the
resulting image with [Docker](http://docker.io) execute:
@ -31,61 +48,6 @@ resulting image with [Docker](http://docker.io) execute:
$ curl 127.0.0.1:8080
```
Repository organization
------------------------
* **`<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.
* **`s2i/bin/`**
This folder contains scripts that are run by [S2I](https://github.com/openshift/source-to-image):
* **assemble**
Used to install the sources into the location 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 a file with commonly used modules.
* **`test/`**
This folder contains a [S2I](https://github.com/openshift/source-to-image)
test framework with a simple server.
* **`setup-test-app/`**
Simple Gunicorn application used for testing purposes by the [S2I](https://github.com/openshift/source-to-image) test framework.
* **`standalone-test-app/`**
Simple standalone application used for testing purposes by the [S2I](https://github.com/openshift/source-to-image) test framework.
* **run**
Script that runs the [S2I](https://github.com/openshift/source-to-image) test framework.
Environment variables
---------------------
@ -119,7 +81,7 @@ file inside your source code repository.
If using `setup.py` for installing the application, the `MODULE_NAME` part
can be read from there. For an example, see
[setup-test-app](https://github.com/openshift/s2i-python/tree/master/3.6/test/setup-test-app).
[setup-test-app](https://github.com/sclorg/s2i-python-container/tree/master/3.6/test/setup-test-app).
* **APP_HOME**
@ -134,33 +96,52 @@ file inside your source code repository.
Path to a valid Python file with a
[Gunicorn configuration](http://docs.gunicorn.org/en/latest/configure.html#configuration-file) file.
* **DISABLE_MIGRATE**
Set this variable to a non-empty value to inhibit the execution of 'manage.py migrate'
when the produced image is run. This only affects Django projects. See
"Handling Database Migrations" section of [Django blogpost on OpenShift blog](
https://blog.openshift.com/migrating-django-applications-openshift-3/) on suggestions
how/when to run DB migrations in OpenShift environment. Most importantly,
note that running DB migrations from two or more pods might corrupt your database.
* **DISABLE_COLLECTSTATIC**
Set this variable to a non-empty value to inhibit the execution of
'manage.py collectstatic' during the build. This only affects Django projects.
* **DISABLE_MIGRATE**
* **DISABLE_SETUP_PY_PROCESSING**
Set this variable to a non-empty value to inhibit the execution of 'manage.py migrate'
when the produced image is run. This only affects Django projects.
Set this to a non-empty value to skip processing of setup.py script if you
use `-e .` in requirements.txt to trigger its processing or you don't want
your application to be installed into site-packages directory.
* **ENABLE_PIPENV**
Set this variable to use [Pipenv](https://github.com/kennethreitz/pipenv),
the higher-level Python packaging tool, to manage dependencies of the application.
This should be used only if your project contains properly formated Pipfile
and Pipfile.lock.
* **PIP_INDEX_URL**
Set this variable to use a custom index URL or mirror to download required packages
during build process. This only affects packages listed in requirements.txt.
Pipenv ignores this variable.
* **UPGRADE_PIP_TO_LATEST**
Set this variable to a non-empty value to have the 'pip' program be upgraded
to the most recent version before any Python packages are installed. If not
set it will use whatever the default version is included by the platform
for the Python version being used.
Set this variable to a non-empty value to have the 'pip' program and related
python packages (setuptools and wheel) be upgraded to the most recent version
before any Python packages are installed. If not set it will use whatever
the default version is included by the platform for the Python version being used.
* **WEB_CONCURRENCY**
Set this to change the default setting for the number of
[workers](http://docs.gunicorn.org/en/stable/settings.html#workers). By
default, this is set to the number of available cores times 2.
default, this is set to the number of available cores times 2, capped
at 12.
Source repository layout
------------------------
@ -174,18 +155,26 @@ However, if these files exist they will affect the behavior of the build process
[here](https://pip.pypa.io/en/latest/user_guide.html#requirements-files).
* **Pipfile**
The replacement for requirements.txt, project is currently under active
design and development, as documented [here](https://github.com/pypa/pipfile).
Set `ENABLE_PIPENV` environment variable to true in order to process this file.
* **setup.py**
Configures various aspects of the project, including installation of
dependencies, as documented
[here](https://packaging.python.org/en/latest/distributing.html#setup-py).
For most projects, it is sufficient to simply use `requirements.txt`.
For most projects, it is sufficient to simply use `requirements.txt` or
`Pipfile`. Set `DISABLE_SETUP_PY_PROCESSING` environment variable to true
in order to skip processing of this file.
Run strategies
--------------
The Docker image produced by s2i-python executes your project in one of the
The container image produced by s2i-python executes your project in one of the
following ways, in precedence order:
* **Gunicorn**
@ -244,3 +233,10 @@ docker exec -it <CONTAINER_ID> /bin/bash
After you enter into the running container, your current directory is set
to `/opt/app-root/src`, where the source code is located.
See also
--------
Dockerfile and other sources are available on https://github.com/sclorg/s2i-python-container.
In that repository you also can find another versions of Python environment Dockerfiles.
Dockerfile for CentOS is called Dockerfile, Dockerfile for RHEL is called Dockerfile.rhel7.