Skip to content

Commit 4db4698

Browse files
hhorakpkubatrh
authored andcommitted
Copy 3.6 content back to 3.5
1 parent b5e30bf commit 4db4698

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1313
-0
lines changed

3.5/Dockerfile

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# This image provides a Python 3.5 environment you can use to run your Python
2+
# applications.
3+
FROM centos/s2i-base-centos7
4+
5+
EXPOSE 8080
6+
7+
ENV PYTHON_VERSION=3.5 \
8+
PATH=$HOME/.local/bin/:$PATH \
9+
PYTHONUNBUFFERED=1 \
10+
PYTHONIOENCODING=UTF-8 \
11+
LC_ALL=en_US.UTF-8 \
12+
LANG=en_US.UTF-8 \
13+
PIP_NO_CACHE_DIR=off
14+
15+
ENV SUMMARY="Platform for building and running Python $PYTHON_VERSION applications" \
16+
DESCRIPTION="Python $PYTHON_VERSION available as docker container is a base platform for \
17+
building and running various Python $PYTHON_VERSION applications and frameworks. \
18+
Python is an easy to learn, powerful programming language. It has efficient high-level \
19+
data structures and a simple but effective approach to object-oriented programming. \
20+
Python's elegant syntax and dynamic typing, together with its interpreted nature, \
21+
make it an ideal language for scripting and rapid application development in many areas \
22+
on most platforms."
23+
24+
LABEL summary="$SUMMARY" \
25+
description="$DESCRIPTION" \
26+
io.k8s.description="$DESCRIPTION" \
27+
io.k8s.display-name="Python 3.5" \
28+
io.openshift.expose-services="8080:http" \
29+
io.openshift.tags="builder,python,python35,rh-python35" \
30+
com.redhat.component="python35-docker" \
31+
name="centos/python-35-centos7" \
32+
version="3.5" \
33+
release="1" \
34+
maintainer="SoftwareCollections.org <[email protected]>"
35+
36+
RUN yum install -y centos-release-scl-rh && \
37+
yum-config-manager --enable centos-sclo-rh-testing && \
38+
INSTALL_PKGS="rh-python35 rh-python35-python-devel rh-python35-python-setuptools rh-python35-python-pip \
39+
nss_wrapper httpd24 httpd24-httpd-devel httpd24-mod_ssl httpd24-mod_auth_kerb httpd24-mod_ldap \
40+
httpd24-mod_session atlas-devel gcc-gfortran libffi-devel libtool-ltdl" && \
41+
yum install -y --setopt=tsflags=nodocs --enablerepo=centosplus $INSTALL_PKGS && \
42+
rpm -V $INSTALL_PKGS && \
43+
# Remove centos-logos (httpd dependency, ~20MB of graphics) to keep image
44+
# size smaller.
45+
rpm -e --nodeps centos-logos && \
46+
yum clean all -y
47+
48+
# Copy the S2I scripts from the specific language image to $STI_SCRIPTS_PATH.
49+
COPY ./s2i/bin/ $STI_SCRIPTS_PATH
50+
51+
# Copy extra files to the image.
52+
COPY ./root/ /
53+
54+
# Create a Python virtual environment for use by any application to avoid
55+
# potential conflicts with Python packages preinstalled in the main Python
56+
# installation.
57+
RUN source scl_source enable rh-python35 && \
58+
virtualenv /opt/app-root
59+
60+
# In order to drop the root user, we have to make some directories world
61+
# writable as OpenShift default security model is to run the container under
62+
# random UID.
63+
RUN chown -R 1001:0 /opt/app-root && chmod -R og+rwx /opt/app-root
64+
65+
USER 1001
66+
67+
# Set the default CMD to print the usage of the language image.
68+
CMD $STI_SCRIPTS_PATH/usage

3.5/Dockerfile.rhel7

+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# This image provides a Python 3.5 environment you can use to run your Python
2+
# applications.
3+
FROM rhscl/s2i-base-rhel7
4+
5+
EXPOSE 8080
6+
7+
ENV PYTHON_VERSION=3.5 \
8+
PATH=$HOME/.local/bin/:$PATH \
9+
PYTHONUNBUFFERED=1 \
10+
PYTHONIOENCODING=UTF-8 \
11+
LC_ALL=en_US.UTF-8 \
12+
LANG=en_US.UTF-8 \
13+
PIP_NO_CACHE_DIR=off
14+
15+
ENV SUMMARY="Platform for building and running Python $PYTHON_VERSION applications" \
16+
DESCRIPTION="Python $PYTHON_VERSION available as docker container is a base platform for \
17+
building and running various Python $PYTHON_VERSION applications and frameworks. \
18+
Python is an easy to learn, powerful programming language. It has efficient high-level \
19+
data structures and a simple but effective approach to object-oriented programming. \
20+
Python's elegant syntax and dynamic typing, together with its interpreted nature, \
21+
make it an ideal language for scripting and rapid application development in many areas \
22+
on most platforms."
23+
24+
LABEL summary="$SUMMARY" \
25+
description="$DESCRIPTION" \
26+
io.k8s.description="$DESCRIPTION" \
27+
io.k8s.display-name="Python 3.5" \
28+
io.openshift.expose-services="8080:http" \
29+
io.openshift.tags="builder,python,python35,rh-python35" \
30+
com.redhat.component="rh-python35-docker" \
31+
name="rhscl/python-35-rhel7" \
32+
version="3.5" \
33+
release="1"
34+
35+
# We need to call 2 (!) yum commands before being able to enable repositories properly
36+
# This is a workaround for https://bugzilla.redhat.com/show_bug.cgi?id=1479388
37+
RUN yum repolist > /dev/null && \
38+
yum install -y yum-utils && \
39+
yum-config-manager --disable \* &> /dev/null && \
40+
yum-config-manager --enable rhel-server-rhscl-7-rpms && \
41+
yum-config-manager --enable rhel-7-server-rpms && \
42+
yum-config-manager --enable rhel-7-server-optional-rpms && \
43+
INSTALL_PKGS="rh-python35 rh-python35-python-devel rh-python35-python-setuptools rh-python35-python-pip \
44+
nss_wrapper httpd24 httpd24-httpd-devel httpd24-mod_ssl httpd24-mod_auth_kerb httpd24-mod_ldap httpd24-mod_session \
45+
atlas-devel gcc-gfortran libffi-devel libtool-ltdl" && \
46+
yum install -y --setopt=tsflags=nodocs $INSTALL_PKGS && \
47+
rpm -V $INSTALL_PKGS && \
48+
# Remove redhat-logos (httpd dependency) to keep image size smaller.
49+
rpm -e --nodeps redhat-logos && \
50+
yum clean all -y
51+
52+
# Copy the S2I scripts from the specific language image to $STI_SCRIPTS_PATH.
53+
COPY ./s2i/bin/ $STI_SCRIPTS_PATH
54+
55+
# Copy extra files to the image.
56+
COPY ./root/ /
57+
58+
# Create a Python virtual environment for use by any application to avoid
59+
# potential conflicts with Python packages preinstalled in the main Python
60+
# installation.
61+
RUN source scl_source enable rh-python35 && \
62+
virtualenv /opt/app-root
63+
64+
# In order to drop the root user, we have to make some directories world
65+
# writable as OpenShift default security model is to run the container under
66+
# random UID.
67+
RUN chown -R 1001:0 /opt/app-root && chmod -R og+rwx /opt/app-root
68+
69+
USER 1001
70+
71+
# Set the default CMD to print the usage of the language image.
72+
CMD $STI_SCRIPTS_PATH/usage

3.5/README.md

+212
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,212 @@
1+
Python 3.5 Docker image
2+
===================
3+
4+
This container image includes Python 3.5 as a [S2I](https://github.com/openshift/source-to-image) base image for your Python 3.5 applications.
5+
Users can choose between RHEL and CentOS based builder images.
6+
The RHEL image is available in the [Red Hat Container Catalog](https://access.redhat.com/containers/#/registry.access.redhat.com/rhscl/python-35-rhel7)
7+
as registry.access.redhat.com/rhscl/python-35-rhel7.
8+
The CentOS image is then available on [Docker Hub](https://hub.docker.com/r/centos/python-35-centos7/)
9+
as centos/python-35-centos7.
10+
The resulting image can be run using [Docker](http://docker.io).
11+
12+
Description
13+
-----------
14+
15+
Python 3.5 available as docker container is a base platform for
16+
building and running various Python 3.5 applications and frameworks.
17+
Python is an easy to learn, powerful programming language. It has efficient high-level
18+
data structures and a simple but effective approach to object-oriented programming.
19+
Python's elegant syntax and dynamic typing, together with its interpreted nature,
20+
make it an ideal language for scripting and rapid application development in many areas
21+
on most platforms.
22+
23+
Usage
24+
---------------------
25+
To build a simple [python-sample-app](https://github.com/sclorg/s2i-python-container/tree/master/3.5/test/setup-test-app) application
26+
using standalone [S2I](https://github.com/openshift/source-to-image) and then run the
27+
resulting image with [Docker](http://docker.io) execute:
28+
29+
* **For RHEL based image**
30+
```
31+
$ s2i build https://github.com/sclorg/s2i-python-container.git --context-dir=3.5/test/setup-test-app/ rhscl/python-35-rhel7 python-sample-app
32+
$ docker run -p 8080:8080 python-sample-app
33+
```
34+
35+
* **For CentOS based image**
36+
```
37+
$ s2i build https://github.com/sclorg/s2i-python-container.git --context-dir=3.5/test/setup-test-app/ centos/python-35-centos7 python-sample-app
38+
$ docker run -p 8080:8080 python-sample-app
39+
```
40+
41+
**Accessing the application:**
42+
```
43+
$ curl 127.0.0.1:8080
44+
```
45+
46+
Environment variables
47+
---------------------
48+
49+
To set these environment variables, you can place them as a key value pair into a `.s2i/environment`
50+
file inside your source code repository.
51+
52+
* **APP_SCRIPT**
53+
54+
Used to run the application from a script file.
55+
This should be a path to a script file (defaults to `app.sh` unless set to null) that will be
56+
run to start the application.
57+
58+
* **APP_FILE**
59+
60+
Used to run the application from a Python script.
61+
This should be a path to a Python file (defaults to `app.py` unless set to null) that will be
62+
passed to the Python interpreter to start the application.
63+
64+
* **APP_MODULE**
65+
66+
Used to run the application with Gunicorn, as documented
67+
[here](http://docs.gunicorn.org/en/latest/run.html#gunicorn).
68+
This variable specifies a WSGI callable with the pattern
69+
`MODULE_NAME:VARIABLE_NAME`, where `MODULE_NAME` is the full dotted path
70+
of a module, and `VARIABLE_NAME` refers to a WSGI callable inside the
71+
specified module.
72+
Gunicorn will look for a WSGI callable named `application` if not specified.
73+
74+
If `APP_MODULE` is not provided, the `run` script will look for a `wsgi.py`
75+
file in your project and use it if it exists.
76+
77+
If using `setup.py` for installing the application, the `MODULE_NAME` part
78+
can be read from there. For an example, see
79+
[setup-test-app](https://github.com/sclorg/s2i-python-container/tree/master/3.5/test/setup-test-app).
80+
81+
* **APP_HOME**
82+
83+
This variable can be used to specify a sub-directory in which the application to be run is contained.
84+
The directory pointed to by this variable needs to contain `wsgi.py` (for Gunicorn) or `manage.py` (for Django).
85+
86+
If `APP_HOME` is not provided, the `assemble` and `run` scripts will use the application's root
87+
directory.
88+
89+
* **APP_CONFIG**
90+
91+
Path to a valid Python file with a
92+
[Gunicorn configuration](http://docs.gunicorn.org/en/latest/configure.html#configuration-file) file.
93+
94+
* **DISABLE_COLLECTSTATIC**
95+
96+
Set this variable to a non-empty value to inhibit the execution of
97+
'manage.py collectstatic' during the build. This only affects Django projects.
98+
99+
* **DISABLE_MIGRATE**
100+
101+
Set this variable to a non-empty value to inhibit the execution of 'manage.py migrate'
102+
when the produced image is run. This only affects Django projects.
103+
104+
* **PIP_INDEX_URL**
105+
106+
Set this variable to use a custom index URL or mirror to download required packages
107+
during build process. This only affects packages listed in requirements.txt.
108+
109+
* **UPGRADE_PIP_TO_LATEST**
110+
111+
Set this variable to a non-empty value to have the 'pip' program and related
112+
python packages (setuptools and wheel) be upgraded to the most recent version
113+
before any Python packages are installed. If not set it will use whatever
114+
the default version is included by the platform for the Python version being used.
115+
116+
* **WEB_CONCURRENCY**
117+
118+
Set this to change the default setting for the number of
119+
[workers](http://docs.gunicorn.org/en/stable/settings.html#workers). By
120+
default, this is set to the number of available cores times 2.
121+
122+
Source repository layout
123+
------------------------
124+
125+
You do not need to change anything in your existing Python project's repository.
126+
However, if these files exist they will affect the behavior of the build process:
127+
128+
* **requirements.txt**
129+
130+
List of dependencies to be installed with `pip`. The format is documented
131+
[here](https://pip.pypa.io/en/latest/user_guide.html#requirements-files).
132+
133+
134+
* **setup.py**
135+
136+
Configures various aspects of the project, including installation of
137+
dependencies, as documented
138+
[here](https://packaging.python.org/en/latest/distributing.html#setup-py).
139+
For most projects, it is sufficient to simply use `requirements.txt`, if this
140+
file is present `setup.py` is not processed by default, please use `-e .` to
141+
trigger its processing from the requirements.txt file.
142+
143+
144+
Run strategies
145+
--------------
146+
147+
The Docker image produced by s2i-python executes your project in one of the
148+
following ways, in precedence order:
149+
150+
* **Gunicorn**
151+
152+
The Gunicorn WSGI HTTP server is used to serve your application in the case that it
153+
is installed. It can be installed by listing it either in the `requirements.txt`
154+
file or in the `install_requires` section of the `setup.py` file.
155+
156+
If a file named `wsgi.py` is present in your repository, it will be used as
157+
the entry point to your application. This can be overridden with the
158+
environment variable `APP_MODULE`.
159+
This file is present in Django projects by default.
160+
161+
If you have both Django and Gunicorn in your requirements, your Django project
162+
will automatically be served using Gunicorn.
163+
164+
* **Django development server**
165+
166+
If you have Django in your requirements but don't have Gunicorn, then your
167+
application will be served using Django's development web server. However, this is not
168+
recommended for production environments.
169+
170+
* **Python script**
171+
172+
This would be used where you provide a Python code file for running you
173+
application. It will be used in the case where you specify a path to a
174+
Python script via the `APP_FILE` environment variable, defaulting to a
175+
file named `app.py` if it exists. The script is passed to a regular
176+
Python interpreter to launch your application.
177+
178+
* **Application script file**
179+
180+
This is the most general way of executing your application. It will be
181+
used in the case where you specify a path to an executable script file
182+
via the `APP_SCRIPT` environment variable, defaulting to a file named
183+
`app.sh` if it exists. The script is executed directly to launch your
184+
application.
185+
186+
Hot deploy
187+
---------------------
188+
189+
If you are using Django, hot deploy will work out of the box.
190+
191+
To enable hot deploy while using Gunicorn, make sure you have a Gunicorn
192+
configuration file inside your repository with the
193+
[`reload`](https://gunicorn-docs.readthedocs.org/en/latest/settings.html#reload)
194+
option set to `true`. Make sure to specify your config via the `APP_CONFIG`
195+
environment variable.
196+
197+
To change your source code in running container, use Docker's
198+
[exec](https://docs.docker.com/reference/commandline/exec/) command:
199+
200+
```
201+
docker exec -it <CONTAINER_ID> /bin/bash
202+
```
203+
204+
After you enter into the running container, your current directory is set
205+
to `/opt/app-root/src`, where the source code is located.
206+
207+
208+
See also
209+
--------
210+
Dockerfile and other sources are available on https://github.com/sclorg/s2i-python-container.
211+
In that repository you also can find another versions of Python environment Dockerfiles.
212+
Dockerfile for CentOS is called Dockerfile, Dockerfile for RHEL is called Dockerfile.rhel7.

3.5/cccp.yml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# This is for the purpose of building this container
2+
# on the centos container pipeline.
3+
job-id: python-35-centos7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Set current user in nss_wrapper
2+
USER_ID=$(id -u)
3+
GROUP_ID=$(id -g)
4+
5+
if [ x"$USER_ID" != x"0" -a x"$USER_ID" != x"1001" ]; then
6+
7+
NSS_WRAPPER_PASSWD=/opt/app-root/etc/passwd
8+
NSS_WRAPPER_GROUP=/etc/group
9+
10+
cat /etc/passwd | sed -e 's/^default:/builder:/' > $NSS_WRAPPER_PASSWD
11+
12+
echo "default:x:${USER_ID}:${GROUP_ID}:Default Application User:${HOME}:/sbin/nologin" >> $NSS_WRAPPER_PASSWD
13+
14+
export NSS_WRAPPER_PASSWD
15+
export NSS_WRAPPER_GROUP
16+
17+
LD_PRELOAD=libnss_wrapper.so
18+
export LD_PRELOAD
19+
fi

3.5/root/opt/app-root/etc/scl_enable

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# IMPORTANT: Do not add more content to this file unless you know what you are
2+
# doing. This file is sourced everytime the shell session is opened.
3+
# This will make scl collection binaries work out of box.
4+
unset BASH_ENV PROMPT_COMMAND ENV
5+
source scl_source enable httpd24 rh-nodejs6 rh-python35
6+
source /opt/app-root/bin/activate

0 commit comments

Comments
 (0)