$ docker pull registry.access.redhat.com/openshift3/ruby-20-rhel7 $ docker pull registry.access.redhat.com/rhscl/ruby-22-rhel7 $ docker pull registry.access.redhat.com/rhscl/ruby-23-rhel7
OpenShift Container Platform 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 Container Platform or by Docker.
These images come in two flavors, depending on your needs:
RHEL 7
CentOS 7
RHEL 7 Based Images
The RHEL 7 images are available through the Red Hat registry:
$ docker pull registry.access.redhat.com/openshift3/ruby-20-rhel7 $ docker pull registry.access.redhat.com/rhscl/ruby-22-rhel7 $ docker pull registry.access.redhat.com/rhscl/ruby-23-rhel7
CentOS 7 Based Images
These images are available on Docker Hub:
$ docker pull openshift/ruby-20-centos7 $ docker pull openshift/ruby-22-centos7 $ docker pull centos/ruby-23-centos7
To use these images, you can either access them directly from these image registries or push them into your OpenShift Container Platform 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 Container Platform resources can then reference the ImageStream. You can find example image stream definitions for all the provided OpenShift Container Platform images.
S2I produces ready-to-run images by injecting source code into a container and letting the container prepare that source code for execution. It performs the following steps:
Starts a container from the builder image.
Downloads the application source.
Streams the scripts and application sources into the builder image container.
Runs the assemble script (from the builder image).
Saves the final image.
See S2I Build Process for a detailed overview of the build process.
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 as part of your image, you can place them into
a .s2i/environment file
inside your source code repository, or define them in
the environment
section of the build configuration’s sourceStrategy
definition.
You can also set environment variables to be used with an existing image when creating new applications, or by updating environment variables for existing objects such as deployment configurations.
Environment variables that control build behavior must be set as part of the s2i build configuration or in the .s2i/environment file to make them available to the build steps. |
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, |
|
When set to |
|
This variable indicates the minimum and maximum number of threads that will be available in Puma's thread pool. |
|
This variable indicates the number of worker processes to be launched in Puma’s
clustered mode (when Puma runs
more than two processes). If not explicitly set, the default behavior sets
|
|
Set this variable to use a custom RubyGems mirror URL to download required gem packages during the build process. Note: This environment variable is only available for Ruby 2.2+ images. |
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 set env
command:
$ oc set 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 set 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.