Chapter 6. Application Images

6.1. Node.js

6.1.1. Description

The rhscl/nodejs-8-rhel7 image provides a Node.js 8 platform for building and running applications.

6.1.2. Access

To pull the rhscl/nodejs-8-rhel7 image, run the following command as root:

# docker pull registry.access.redhat.com/rhscl/nodejs-8-rhel7

6.1.3. Configuration

To set environment variables, you can place them as a key-value pair into a .sti/environment file inside your source code repository.

Variable NameDescription

NODE_ENV

NodeJS runtime mode (default: "production")

DEV_MODE

When set to "true", nodemon will be used to automatically reload the server while you work (default: "false"). Setting DEV_MODE to "true" will change the NODE_ENV default to "development" (if not explicitly set).

NPM_RUN

Select an alternate / custom runtime mode, defined in your package.json file’s scripts section (default: npm run "start"). These user-defined run-scripts are unavailable while DEV_MODE is in use.

HTTP_PROXY

Use an npm proxy during assembly

HTTPS_PROXY

Use an npm proxy during assembly

NPM_MIRROR

Use a custom NPM registry mirror to download packages during the build process

6.2. PHP

6.2.1. Description

The rhscl/php-71-rhel7 image provides a PHP 7.1 platform for building and running applications; the rhscl/php-70-rhel7 image provides a PHP 7.0 platform. Node.js with npm is preinstalled in the PHP images.

6.2.2. Access

To pull the rhscl/php-71-rhel7 image, run the following command as root:

# docker pull registry.access.redhat.com/rhscl/php-71-rhel7

To pull the rhscl/php-70-rhel7 image, run the following command as root:

# docker pull registry.access.redhat.com/rhscl/php-70-rhel7

6.2.3. Configuration

To set environment variables, place them as a key-value pair into a .sti/environment file inside your source code repository.

The following environment variables set their equivalent property value in the php.ini file:

Variable NameDescriptionDefault

ERROR_REPORTING

Informs PHP of which errors, warnings and notices you would like it to take action for

E_ALL & ~E_NOTICE

DISPLAY_ERRORS

Controls whether or not and where PHP will output errors, notices and arnings

ON

DISPLAY_STARTUP_ERRORS

Cause display errors which occur during PHP’s startup sequence to be handled separately from display errors

OFF

TRACK_ERRORS

Store the last error/warning message in $php_errormsg (boolean)

OFF

HTML_ERRORS

Link errors to documentation related to the error

ON

INCLUDE_PATH

Path for PHP source files

.:/opt/app-root/src:/opt/rh/rh-php71/root/usr/share/pear

SESSION_NAME

Name of the session

PHPSESSID

SESSION_HANDLER

Method for saving sessions

`files

SESSION_PATH

Location for session data files

/tmp/sessions

SESSION_COOKIE_DOMAIN

The domain for which the cookie is valid

 

SESSION_COOKIE_HTTPONLY

Whether or not to add the httpOnly flag to the cookie

0

SESSION_COOKIE_SECURE

Specifies whether cookies should only be sent over secure connections

Off

SHORT_OPEN_TAG

Determines whether or not PHP will recognize code between <? and ?> tags

OFF

DOCUMENTROOT

Path that defines the DocumentRoot for your application (ie. /public)

/

The following environment variables set their equivalent property value in the opcache.ini file:

Variable NameDescriptionDefault

OPCACHE_MEMORY_CONSUMPTION

The OPcache shared memory storage size

16M

OPCACHE_REVALIDATE_FREQ

How often to check script timestamps for updates, in seconds. 0 will result 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 NameDescription

PHPRC

Sets the path to the php.ini file

PHP_INI_SCAN_DIR

Path to scan for additional ini configuration files

You can override the Apache MPM prefork settings to increase the performance for of the PHP application. In case you set the Cgroup limits in Docker, the image will attempt to automatically set the optimal values. You can override this at any time by specifying the values yourself:

Variable NameDescriptionDefault

HTTPD_START_SERVERS

The StartServers directive sets the number of child server processes created on startup.

8

HTTPD_MAX_REQUEST_WORKERS

The MaxRequestWorkers directive sets the limit on the number of simultaneous requests that will be served. MaxRequestWorkers was called MaxClients before version httpd 2.3.13.

256 (this is automatically tuned by setting Cgroup limits for the container using this formula: TOTAL_MEMORY / 15MB. The 15MB is average size of a single httpd process.

You can use a custom composer repository mirror URL to download packages instead of the default packagist.org:

Variable NameDescription

COMPOSER_MIRROR

Adds a custom composer repository mirror URL to composer configuration. Note: This only affects packages listed in composer.json.

In case the DocumentRoot of the application is nested within the source directory /opt/app-root/src, users can provide their own .htaccess file. This allows the overriding of Apache’s behavior and specifies how application requests should be handled. The .htaccess file needs to be located at the root of the application source. For details about .htaccess, see the Apache HTTP Server Tutorial.

6.3. Perl

6.3.1. Description

The rhscl/perl-526-rhel7 image provides a Perl 5.26 platform for building and running applications. Apache httpd 2.4 with mod_perl for deploying Perl web applications is preinstalled, as well as Node.js with npm.

The image also supports deploying Perl Web Server Gateway Interface (PSGI) applications.

6.3.2. Access

To pull the rhscl/perl-526-rhel7 image, run the following command as root:

# docker pull registry.access.redhat.com/rhscl/perl-526-rhel7

6.3.3. Configuration

To set environment variables, you can place them as a key-value pair into a .sti/environment file inside your source code repository.

Variable NameDescriptionDefault

ENABLE_CPAN_TEST

Allows the installation of all specified cpan packages and the running of their tests

false

CPAN_MIRROR

Specifies a mirror URL which will used by cpanminus to install dependencies

URL is not specified by default

PERL_APACHE2_RELOAD

Enables automatic reloading of modified Perl modules

false

HTTPD_START_SERVERS

The StartServers directive sets the number of child server processes created on startup

8

HTTPD_MAX_REQUEST_WORKERS

Number of simultaneous requests that will be handled by Apache

256 but will be automatically lowered if memory is limited

PSGI_FILE

Specifies relative path to the PSGI application file. Use empty value to disable the PSGI autoconfiguration

Single *.psgi file in the top-level directory, if it exists

PSGI_URI_PATH

Specifies URI path that is handled by the PSGI application

/

To install additional Perl modules from the Comprehensive Perl Archive Network (CPAN), create a cpanfile in the root directory of your application sources. The file must conform to the cpanfile format as defined in Module-CPANFile CPAN distribution. For detailed information about the cpanfile format, refer to the cpanfile documentation.

To modify the Apache httpd behavior, drop the .htaccess file in the application sources tree where appropriate. For details about .htaccess, see the Apache HTTP Server Tutorial.

6.4. Python

6.4.1. Description

The rhscl/python-36-rhel7 image provides a Python 3.6 platform for building and running applications; Node.js with npm is preinstalled.

6.4.2. Access

To pull the rhscl/python-36-rhel7 image, run the following command as root:

# docker pull registry.access.redhat.com/rhscl/python-36-rhel7

6.4.3. Configuration

To set environment variables, you can place them as a key-value pair into a .sti/environment file inside your source code repository.

Variable NameDescription

APP_SCRIPT

Used to run the application from a script file. This should be a path to a script file (defaults to app.sh unless set to null) that will be run to start the application.

APP_FILE

Used to run the application from a Python script. This should be a path to a Python file (defaults to app.py) that will be passed to the Python interpreter to start the application.

APP_MODULE

Used to run the application with Gunicorn, as documented here. This variable specifies a WSGI callable with the pattern MODULE_NAME:VARIABLE_NAME, where MODULE_NAME is the full dotted path of a module, and VARIABLE_NAME refers to a WSGI callable inside the specified module. Gunicorn will look for a WSGI callable named application if not specified. If APP_MODULE is not provided, the run script will look for a wsgi.py file in your project and use it if it exists. If using setup.py for installing the application, the MODULE_NAME part can be read from there. For an example, see setup-test-app.

APP_HOME

This variable can be used to specify a sub-directory in which the application to be run is contained. The directory pointed to by this variable needs to contain wsgi.py (for Gunicorn) or manage.py (for Django). If APP_HOME is not provided, the assemble and run scripts will use the application’s root directory.

APP_CONFIG

Path to a valid Python file with a Gunicorn configuration file.

DISABLE_COLLECTSTATIC

Set this variable to a non-empty value to inhibit the execution of manage.py collectstatic during the build. This affects only Django projects.

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 affects only Django projects.

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.

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.

WEB_CONCURRENCY

Set this to change the default setting for the number of workers. By default, this is set to the number of available cores times 2.

6.5. Ruby

6.5.1. Description

The rhscl/ruby-25-rhel7 image provides a Ruby 2.5 platform for building and running applications; Node.js with npm is preinstalled.

6.5.2. Access

To pull the rhscl/ruby-25-rhel7 image, run the following command as root:

# docker pull registry.access.redhat.com/rhscl/ruby-25-rhel7

6.5.3. Configuration

To set environment variables, you can place them as a key-value pair into a .sti/environment file inside your source code repository.

Variable NameDescription

RACK_ENV

This variable specifies the environment where the Ruby application will be deployed (unless overwritten) - production, development, test. Each level has different behaviors in terms of logging verbosity, error pages, Ruby gem installation, and other. Note that application assets will be compiled only if the RACK_ENV is set to production.

DISABLE_ASSET_COMPILATION

This variable indicates that the asset compilation process will be skipped. Because this only takes place when the application is run in the production environment, it should be used only when assets are already compiled.

PUMA_MIN_THREADS, PUMA_MAX_THREADS

These variables indicate the minimum and maximum threads that will be available in Puma's thread pool.

PUMA_WORKERS

This variable indicates the number of worker processes that will be launched. See documentation on Puma’s clustered mode.

RUBYGEM_MIRROR

Set this variable to use a custom RubyGems mirror URL to download required gem packages during the build process.

For S2I scripts to work, you need to include the puma or rack gem in the application’s Gemfile.