Chapter 11. Application Images

11.1. Node.js

11.1.1. Description

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

11.1.2. Access

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

# podman pull registry.redhat.io/rhscl/nodejs-14-rhel7

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

# podman pull registry.redhat.io/rhscl/nodejs-12-rhel7

11.1.3. Configuration

To set environment variables, you can place them as a key-value pair into a .s2i/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

11.2. PHP

11.2.1. Description

The rhscl/php-73-rhel7 image provides a PHP 7.3 platform for building and running applications. Node.js with npm is preinstalled in the PHP images.

11.2.2. Access

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

# podman pull registry.redhat.io/rhscl/php-73-rhel7

11.2.3. Configuration

To set environment variables, place them as a key-value pair into a .s2i/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-php73/root/usr/share/pear

PHP_MEMORY_LIMIT

Memory limit

128M

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)

/

Replace the version of the rh-php7* Software Collection when appropriate.

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 in megabytes

128

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

OPCACHE_MAX_FILES

The maximum number of keys (scripts) in the OPcache hash table. Only numbers between 200 and 1000000 are allowed.

4000

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, 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.

256 (this is automatically tuned by setting Cgroup limits for the container using this formula: TOTAL_MEMORY / 15MB. 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.

COMPOSER_INSTALLER

Overrides the default URL for downloading Composer of https://getcomposer.org/installer. Useful in disconnected environments.

COMPOSER_ARGS

Adds extra arguments to the composer install command line (for example, --no-dev).

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.

11.2.4. Extending the Image

The PHP image can be extended using source-to-image.

For example, to build a customized PHP image my-php-rhel7 with configuration in the ~/image-configuration/ directory, run:

$ s2i build ~/image-configuration/ rhscl/php-73-rhel7 my-php-rhel7

Make sure to change the source image version accordingly.

The structure of the application can be similar to this example:

Directory nameDescription

./httpd-cfg

Can contain additional Apache configuration files (*.conf)

./httpd-ssl

Can contain own SSL certificate (in the certs/ subdirectory) and key (in the private/ subdirectory)

./php-pre-start

Can contain shell scripts (*.sh) that are sourced before httpd is started

./php-post-assemble

Can contain shell scripts (*.sh) that are sourced at the end of assemble script

./

Application source code

11.3. Perl

11.3.1. Description

The rhscl/perl-530-rhel7 image provides a Perl 5.30 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.

These images also support deploying Perl Web Server Gateway Interface (PSGI) applications.

11.3.2. Access

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

# podman pull registry.redhat.io/rhscl/perl-530-rhel7

11.3.3. Configuration

To set environment variables, you can place them as a key-value pair into a .s2i/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 a relative path to the PSGI application file. Use an empty value to disable the PSGI auto-configuration

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

PSGI_URI_PATH

Specifies a 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.

11.4. Python

11.4.1. Description

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

11.4.2. Access

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

# podman pull registry.redhat.io/rhscl/python-38-rhel7

11.4.3. Configuration

To set environment variables, you can place them as a key-value pair into a .s2i/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_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.

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_SETUP_PY_PROCESSING

Set this variable to a non-empty value to skip processing of the 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 a site-packages directory.

ENABLE_PIPENV

Set this variable to use Pipenv, the higher-level Python packaging tool, to manage dependencies of the application. This should be used only if your project contains an appropriately formatted Pipfile and Pipfile.lock.

ENABLE_INIT_WRAPPER

Set this variable to a non-empty value to make use of an init wrapper. This is useful for servers that are not capable of reaping zombie processes, such as Django development server or Tornado. This option can be used together with the APP_SCRIPT or APP_FILE variables. It never applies to Gunicorn used through APP_MODULE as Gunicorn reaps zombie processes correctly.

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.

11.5. Ruby

11.5.1. Description

The rhscl/ruby-30-rhel7 image provides a Ruby 3.0 platform for building and running applications, the rhscl/ruby-27-rhel7 image provides a Ruby 2.7 platform, and the rhscl/ruby-26-rhel7 image provides a Ruby 2.6 platform.

Node.js with npm is preinstalled.

11.5.2. Access

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

# podman pull registry.redhat.io/rhscl/ruby-30-rhel7

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

# podman pull registry.redhat.io/rhscl/ruby-27-rhel7

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

# podman pull registry.redhat.io/rhscl/ruby-26-rhel7

11.5.3. Configuration

To set environment variables, you can place them as a key-value pair into a .s2i/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 set to true 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.