The Red Hat Ecosystem Catalog is the official source for discovering and learning more about the Red Hat Ecosystem of both Red Hat and certified third-party products and services.
We’re the world’s leading provider of enterprise open source solutions—including Linux, cloud, container, and Kubernetes. We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.
Perl 5.32 available as container is a base platform for building and running various Perl 5.32 applications and frameworks. Perl is a high-level programming language with roots in C, sed, awk and shell scripting. Perl is good at handling processes and files, and is especially good at handling text. Perl's hallmarks are practicality and efficiency. While it is used to do a lot of different things, Perl's most common applications are system administration utilities and web programming.
This container image includes an npm utility, so users can use it to install JavaScript modules for their web applications. There is no guarantee for any specific npm or nodejs version, that is included in the image; those versions can be changed anytime and the nodejs itself is included just to make the npm work.
In this example, we will assume that you are using the ubi9/perl-532
image, available via perl:5.32
imagestream tag in Openshift.
To build a simple nodejs-sample-app application in Openshift:
oc new-app perl:5.32~https://github.com/sclorg/dancer-ex.git
To access the application:
$ oc get pods
$ oc exec <pod> -- curl 127.0.0.1:8080
This image supports the Source-to-Image (S2I) strategy in OpenShift. The Source-to-Image is an OpenShift framework which makes it easy to write images that take application source code as an input, use a builder image like this Node.js container image, and produce a new image that runs the assembled application as an output.
To support the Source-to-Image framework, important scripts are included in the builder image:
/usr/libexec/s2i/assemble
script inside the image is run to produce a new image with the application artifacts. The script takes sources of a given application and places them into appropriate directories inside the image. It utilizes some common patterns in Perl application development (see the Environment variables section below)./usr/libexec/s2i/run
script is set as the default command in the resulting container image (the new image with the application artifacts). It runs httpd
for production.Compared to the Source-to-Image strategy, using a Dockerfile is a more flexible way to build a Node.js container image with an application. Use a Dockerfile when Source-to-Image is not sufficiently flexible for you or when you build the image outside of the OpenShift environment.
To use the Node.js image in a Dockerfile, follow these steps:
podman pull ubi9/perl-532
A RHEL9 image ubi9/perl-532
is used in this example.
An example application available at https://github.com/sclorg/dancer-ex.git is used here. Feel free to clone the repository for further experiments.
git clone https://github.com/sclorg/dancer-ex.git app-src
This step usually consists of at least these parts:
For all these three parts, users can either setup all manually and use commands perl
and cpan
explicitly in the Dockerfile (3.1.), or users can use the Source-to-Image scripts inside the image (3.2.; see more about these scripts in the section "Source-to-Image framework and scripts" above), that already know how to set-up and run some common Perl applications.
FROM ubi9/perl-532
# Add application sources
ADD app-src .
# Install the dependencies
RUN export PATH=${PATH}:/opt/rh/rh-perl532/root/usr/bin/&& \
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/opt/rh/rh-perl532/root/usr/lib64 && \
cpanm --notest -l extlib Module::CoreList && \
cpanm --notest -l extlib --installdeps .
CMD sed -i '1i<Location/>' /opt/app-root/etc/httpd.d/40-psgi.conf
CMD sed -i '2iSetHandler perl-script' /opt/app-root/etc/httpd.d/40-psgi.conf
CMD sed -i '3iPerlResponseHandler Plack::Handler::Apache2' /opt/app-root/etc/httpd.d/40-psgi.conf
CMD sed -i '4iPerlSetVar psgi_app app.psgi' /opt/app-root/etc/httpd.d/40-psgi.conf
CMD sed -i '5i</Location>' /opt/app-root/etc/httpd.d/40-psgi.conf
# Run scripts uses standard ways to run the application
CMD exec httpd -C 'Include /opt/app-root/etc/httpd.conf' -D FOREGROUND
FROM centos/perl-532-centos7
# Add application sources to a directory that the assemble scriptexpects them
# and set permissions so that the container runs without root access
USER 0
ADD app-src /tmp/src
RUN chown -R 1001:0 /tmp/src
USER 1001
# Install the dependencies
RUN /usr/libexec/s2i/assemble
# Set the default command for the resulting image
CMD /usr/libexec/s2i/run
podman build -t perl-app .
podman run -d perl-app
To set environment variables, you can place them as a key value pair into a .s2i/environment
file inside your source code repository.
ENABLE_CPAN_TEST
Allow the installation of all specified cpan packages and the running of their tests. The default value is false
.
CPAN_MIRROR
This variable specifies a mirror URL which will used by cpanminus to install dependencies. By default the URL is not specified.
PERL_APACHE2_RELOAD
Set this to "true" to enable automatic reloading of modified Perl modules.
HTTPD_START_SERVERS
The StartServers directive sets the number of child server processes created on startup. Default is 8.
HTTPD_MAX_REQUEST_WORKERS
Number of simultaneous requests that will be handled by Apache. The default is 256, but it will be automatically lowered if memory is limited.
PSGI_FILE
Override PSGI application detection.
If the PSGI_FILE variable is set to empty value, no PSGI application will be detected and mod_perl not be reconfigured.
If the PSGI_FILE variable is set and non-empty, it will define path to the PSGI application file. No detection will be used.
If the PSGI_FILE variable does not exist, autodetection will be used: If exactly one ./*.psgi file exists, mod_perl will be configured to execute that file.
PSGI_URI_PATH
This variable overrides location URI path that is handled path the PSGI application. Default value is "/".
Dockerfile and other sources are available on https://github.com/sclorg/s2i-perl-container.
In that repository you also can find another versions of Perl environment Dockerfiles.
Dockerfile for CentOS is called Dockerfile
, Dockerfile for RHEL7 is called Dockerfile.rhel7
, Dockerfile for RHEL8 is called Dockerfile.rhel8
, Dockerfile for RHEL9 is called Dockerfile.rhel9
and the Fedora Dockerfile is called Dockerfile.fedora
.
Use the following instructions to get images from a Red Hat container registry using registry service account tokens. You will need to create a registry service account to use prior to completing any of the following tasks.
First, you will need to add a reference to the appropriate secret and repository to your Kubernetes pod configuration via an imagePullSecrets field.
Then, use the following from the command line or from the OpenShift Dashboard GUI interface.
Use the following command(s) from a system with podman installed
Use the following command(s) from a system with docker service installed and running
Use the following instructions to get images from a Red Hat container registry using your Red Hat login.
For best practices, it is recommended to use registry tokens when pulling content for OpenShift deployments.
Use the following command(s) from a system with podman installed
Use the following command(s) from a system with docker service installed and running
Use the following instructions to get images from a Red Hat container registry without providing authentication.
A container image made to run with OpenShift platforms can either be pulled from the command line or from the OpenShift Dashboard GUI interface.
Use the following command(s) from a system with podman installed
Use the following command(s) from a system with docker service installed and running
Source code is available for all Red Hat UBI-based images in the form of downloadable containers. Here are a few things you should know about Red Hat source containers.
Use skopeo to copy the source image to a local directory
Inspect the image
Untar the contents
Begin examining and using the content.