이 콘텐츠는 선택한 언어로 제공되지 않습니다.
Chapter 2. Source-to-Image (S2I)
2.1. Overview
This topic group includes information on the different S2I (Source-to-Image) supported images available for OpenShift Enterprise users.
2.2. Node.js
2.2.1. Overview
OpenShift Enterprise provides S2I enabled Node.js images for building and running Node.js applications. The Node.js S2I builder image assembles your application source with any required dependencies to create a new image containing your Node.js application. This resulting image can be run either by OpenShift Enterprise or by Docker.
2.2.2. Versions
Currently, OpenShift Enterprise provides version 0.10 of Node.js.
2.2.3. Images
This image comes in two flavors, depending on your needs:
- RHEL 7
- CentOS 7
RHEL 7 Based Image
The RHEL 7 image is available through Red Hat’s subscription registry using:
$ docker pull registry.access.redhat.com/openshift3/nodejs-010-rhel7
CentOS 7 Based Image
This image is available on DockerHub. To download it:
$ docker pull openshift/nodejs-010-centos7
To use these images, you can either access them directly from these image registries, or push them into your OpenShift Enterprise Docker registry. Additionally, you can create an image stream that points to the image, either in your Docker registry or at the external location. Your OpenShift Enterprise resources can then reference the ImageStream. You can find example image stream definitions for all the provided OpenShift Enterprise images.
2.2.4. Configuration
The Node.js image does not offer any environment variable based configuration settings.
2.3. Ruby
2.3.1. Overview
OpenShift Enterprise provides S2I enabled Ruby images for building and running Ruby applications. The Ruby S2I builder image assembles your application source with any required dependencies to create a new image containing your Ruby application. This resulting image can be run either by OpenShift Enterprise or by Docker.
2.3.2. Versions
Currently, OpenShift Enterprise provides versions 2.0, 2.2, and 2.3 of Ruby.
2.3.3. Images
This image comes in two flavors, depending on your needs:
- RHEL 7
- CentOS 7
RHEL 7 Based Image
The RHEL 7 image is available through Red Hat’s subscription registry using:
$ docker pull registry.access.redhat.com/openshift3/ruby-20-rhel7
CentOS 7 Based Image
This image is available on DockerHub. To download it:
$ docker pull openshift/ruby-20-centos7
To use these images, you can either access them directly from these image registries, or push them into your OpenShift Enterprise Docker registry. Additionally, you can create an image stream that points to the image, either in your Docker registry or at the external location. Your OpenShift Enterprise resources can then reference the ImageStream. You can find example image stream definitions for all the provided OpenShift Enterprise images.
2.3.4. Configuration
The Ruby image supports a number of environment variables which can be set to control the configuration and behavior of the Ruby runtime.
To set these environment variables, you can place them into a .sti/environment file inside your source code repository, or define them in the environment section of the build configuration’s sourceStrategy
definition.
Variable name | Description |
---|---|
|
This variable specifies the environment within which the Ruby application is deployed; for example, |
|
This variable specifies the environment within which the Ruby on Rails application is deployed; for example, |
|
This variable set to |
2.3.5. Hot Deploying
Hot deployment allows you to quickly make and deploy changes to your application without having to generate a new S2I build. The method for enabling hot deployment in this image differs based on the application type.
Ruby on Rails Applications
For Ruby on Rails application, run the built Rails application with the RAILS_ENV=development
environment variable passed to the running pod. For an existing deployment configuration, you can use the oc env
command:
$ oc env dc/rails-app RAILS_ENV=development
Other Types of Ruby Applications (Sinatra, Padrino, etc.)
For other types of Ruby applications, your application must be built with a gem that can reload the server every time a change to the source code is made inside the running container. Those gems are:
In order to be able to run your application in development mode, you must modify the S2I run script so that the web server is launched by the chosen gem, which checks for changes in the source code.
After you build your application image with your version of the S2I run script, run the image with the RACK_ENV=development
environment variable. For example, see the oc new-app
command. You can use the oc env
command to update environment variables of existing objects.
You should only use this option while developing or debugging; it is not recommended to turn this on in your production environment.
To change your source code in a running pod, use the oc rsh
command to enter the container:
$ oc rsh <pod_id>
After you enter into the running container, your current directory is set to /opt/app-root/src, where the source code is located.
2.4. Perl
2.4.1. Overview
OpenShift Enterprise provides S2I enabled Perl images for building and running Perl applications. The Perl S2I builder image assembles your application source with any required dependencies to create a new image containing your Perl application. This resulting image can be run either by OpenShift Enterprise or by Docker.
2.4.2. Versions
Currently, OpenShift Enterprise supports version 5.16 of Perl.
2.4.3. Images
This image comes in two flavors, depending on your needs:
- RHEL 7
- CentOS 7
RHEL 7 Based Image
The RHEL 7 image is available through Red Hat’s subscription registry using:
$ docker pull registry.access.redhat.com/openshift3/perl-516-rhel7
CentOS 7 Based Image
This image is available on DockerHub. To download it:
$ docker pull openshift/perl-516-centos7
To use these images, you can either access them directly from these image registries, or push them into your OpenShift Enterprise Docker registry. Additionally, you can create an image stream that points to the image, either in your Docker registry or at the external location. Your OpenShift Enterpriset resources can then reference the ImageStream. You can find example image stream definitions for all the provided OpenShift Enterprise images.
2.4.4. Configuration
The Perl image supports a number of environment variables which can be set to control the configuration and behavior of the Perl runtime.
To set these environment variables, you can place them into a .sti/environment file inside your source code repository, or define them in the environment section of the build configuration’s sourceStrategy
definition.
Variable name | Description |
---|---|
| This variable installs all the cpan modules and runs their tests. By default, the testing of the modules is turned off. |
| This variable specifies a mirror URL which cpanminus uses to install dependencies. By default, this URL is not specified. |
| Set this to true to enable automatic reloading of modified Perl modules. By default, automatic reloading is turned off. |
2.4.5. Accessing Logs
Access logs are streamed to standard output and as such they can be viewed using the oc logs
command. Error logs are stored in the /tmp/error_log file, which can be viewed using the oc rsh
command to access the container.
2.4.6. Hot Deploying
Hot deployment allows you to quickly make and deploy changes to your application without having to generate a new S2I build. To enable hot deployment in this image, you must set the PERL_APACHE2_RELOAD
environment variable to true. For example, see the oc new-app
command. You can use the oc env
command to update environment variables of existing objects.
You should only use this option while developing or debugging; it is not recommended to turn this on in your production environment.
To change your source code in a running pod, use the oc rsh
command to enter the container:
$ oc rsh <pod_id>
After you enter into the running container, your current directory is set to /opt/app-root/src, where the source code is located.
2.5. PHP
2.5.1. Overview
OpenShift Enterprise provides S2I enabled PHP images for building and running PHP applications. The PHP S2I builder image assembles your application source with any required dependencies to create a new image containing your PHP application. This resulting image can be run either by OpenShift Enterprise or by Docker.
2.5.2. Versions
Currently, OpenShift Enterprise provides version 5.5 and 5.6 of PHP.
2.5.3. Images
This image comes in two flavors, depending on your needs:
- RHEL 7
- CentOS 7
RHEL 7 Based Image
The RHEL 7 image is available through Red Hat’s subscription registry using:
$ docker pull registry.access.redhat.com/openshift3/php-55-rhel7
CentOS 7 Based Image
This image is available on DockerHub. To download it:
$ docker pull openshift/php-55-centos7
To use these images, you can either access them directly from these image registries, or push them into your OpenShift Enterprise Docker registry. Additionally, you can create an image stream that points to the image, either in your Docker registry or at the external location. Your OpenShift Enterprise resources can then reference the image stream.
You can find example image stream definitions for all the provided OpenShift Enterprise images.
2.5.4. Configuration
The PHP image supports a number of environment variables which can be set to control the configuration and behavior of the PHP runtime.
To set these environment variables, you can place them into a .sti/environment file inside your source code repository, or define them in the environment section of the build configuration’s sourceStrategy
definition.
The following environment variables set their equivalent property value in the php.ini file:
Variable name | Description | Default |
---|---|---|
| Informs PHP of the errors, warnings, and notices for which you would like it to take action. | E_ALL & ~E_NOTICE |
| Controls if and where PHP outputs errors, notices, and warnings. | ON |
| Causes any display errors that occur during PHP’s startup sequence to be handled separately from display errors. | OFF |
|
Stores the last error/warning message in | OFF |
| Links errors to documentation that is related to the error. | ON |
| Path for PHP source files. | .:/opt/openshift/src:/opt/rh/php55/root/usr/share/pear |
| Location for session data files. | /tmp/sessions |
The following environment variable sets its equivalent property value in the opcache.ini file:
Variable name | Description | Default |
---|---|---|
| The OPcache shared memory storage size. | 16M |
| How often to check script time stamps for updates, in seconds. 0 results in OPcache checking for updates on every request. | 2 |
You can also override the entire directory used to load the PHP configuration by setting:
Variable name | Description |
---|---|
| Sets the path to the php.ini file. |
| Path to scan for additional .ini configuration files |
2.5.4.1. Apache Configuration
If the DocumentRoot
of the application is nested in the source directory /opt/openshift/src, you can provide your own .htaccess file to override the default Apache behavior and specify how application requests should be handled. The .htaccess file must be located at the root of the application source.
2.5.5. Accessing Logs
Access logs are streamed to standard out and as such they can be viewed using the oc logs
command. Error logs are stored in the /tmp/error_log file, which can be viewed using the oc rsh
command to access the container.
2.5.6. Hot Deploying
Hot deployment allows you to quickly make and deploy changes to your application without having to generate a new S2I build. In order to immediately pick up changes made in your application source code, you must run your built image with the OPCACHE_REVALIDATE_FREQ=0
environment variable.
For example, see the oc new-app
command. You can use the oc env
command to update environment variables of existing objects.
You should only use this option while developing or debugging; it is not recommended to turn this on in your production environment.
To change your source code in a running pod, use the oc rsh
command to enter the container:
$ oc rsh <pod_id>
After you enter into the running container, your current directory is set to /opt/app-root/src, where the source code is located.
2.6. Python
2.6.1. Overview
OpenShift Enterprise provides S2I enabled Python images for building and running Python applications. The Python S2I builder image assembles your application source with any required dependencies to create a new image containing your Python application. This resulting image can be run either by OpenShift Enterprise or by Docker.
2.6.2. Versions
Currently, OpenShift Enterprise provides versions 2.7, 3.3, 3.4, and 3.5 of Python.
2.6.3. Images
This image comes in two flavors, depending on your needs:
- RHEL 7
- CentOS 7
RHEL 7 Based Image
The RHEL 7 image is available through Red Hat’s subscription registry using:
$ docker pull registry.access.redhat.com/openshift3/python-33-rhel7
CentOS 7 Based Image
This image is available on DockerHub. To download it:
$ docker pull openshift/python-33-centos7
To use these images, you can either access them directly from these image registries, or push them into your OpenShift Enterprise Docker registry. Additionally, you can create an image stream that points to the image, either in your Docker registry or at the external location. Your OpenShift Enterprise resources can then reference the ImageStream. You can find example image stream definitions for all the provided OpenShift Enterprise images.
2.6.4. Configuration
The Python image supports a number of environment variables which can be set to control the configuration and behavior of the Python runtime.
To set these environment variables, you can place them into a .sti/environment file inside your source code repository, or define them in the environment section of the build configuration’s sourceStrategy
definition.
Variable name | Description |
---|---|
| This variable specifies the file name passed to the python interpreter which is responsible for launching the application. This variable is set to app.py by default. |
|
This variable specifies the WSGI callable. It follows the pattern |
| This variable indicates the path to a valid Python file with a gunicorn configuration. |
|
Set it to a nonempty value to inhibit the execution of |
|
Set it to a nonempty value to inhibit the execution of |
2.6.5. Hot Deploying
Hot deployment allows you to quickly make and deploy changes to your application without having to generate a new S2I build. If you are using Django, hot deployment works out of the box.
To enable hot deployment while using Gunicorn, ensure you have a Gunicorn configuration file inside your repository with the reload
option set to true. Specify your configuration file using the APP_CONFIG
environment variable. For example, see the oc new-app
command. You can use the oc env
command to update environment variables of existing objects.
You should only use this option while developing or debugging; it is not recommended to turn this on in your production environment.
To change your source code in a running pod, use the oc rsh
command to enter the container:
$ oc rsh <pod_id>
After you enter into the running container, your current directory is set to /opt/app-root/src, where the source code is located.