diff --git a/.github/workflows/build-and-push.yml b/.github/workflows/build-and-push.yml index 6a7bc74..9d011b2 100644 --- a/.github/workflows/build-and-push.yml +++ b/.github/workflows/build-and-push.yml @@ -30,6 +30,14 @@ jobs: quayio_username: "QUAY_IMAGE_FEDORA_BUILDER_USERNAME" quayio_token: "QUAY_IMAGE_FEDORA_BUILDER_TOKEN" + - dockerfile: "5.38/Dockerfile.fedora" + docker_context: "5.38" + registry_namespace: "fedora" + tag: "5.38" + image_name: "perl-538" + quayio_username: "QUAY_IMAGE_FEDORA_BUILDER_USERNAME" + quayio_token: "QUAY_IMAGE_FEDORA_BUILDER_TOKEN" + steps: - name: Build and push to quay.io registry uses: sclorg/build-and-push-action@v4 diff --git a/5.38/.exclude-c9s b/5.38/.exclude-c9s new file mode 100644 index 0000000..e69de29 diff --git a/5.38/Dockerfile.c9s b/5.38/Dockerfile.c9s new file mode 100644 index 0000000..237e24e --- /dev/null +++ b/5.38/Dockerfile.c9s @@ -0,0 +1,63 @@ +FROM quay.io/sclorg/s2i-base-c9s:c9s + +# This image provides a Perl 5.38 environment you can use to run your Perl applications. + +EXPOSE 8080 + +# Image metadata +ENV PERL_VERSION=5.38 \ + PERL_SHORT_VER=538 \ + NAME=perl + +ENV SUMMARY="Platform for building and running Perl $PERL_VERSION applications" \ + DESCRIPTION="Perl $PERL_VERSION available as container is a base platform for \ +building and running various Perl $PERL_VERSION 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." + +LABEL summary="$SUMMARY" \ + description="$DESCRIPTION" \ + io.k8s.description="$DESCRIPTION" \ + io.k8s.display-name="Apache 2.4 with mod_fcgid and Perl $PERL_VERSION" \ + io.openshift.expose-services="8080:http" \ + io.openshift.tags="builder,${NAME},${NAME}${PERL_SHORT_VER}","${NAME}-${PERL_SHORT_VER}" \ + io.openshift.s2i.scripts-url="image:///usr/libexec/s2i" \ + io.s2i.scripts-url="image:///usr/libexec/s2i" \ + name="sclorg/${NAME}-${PERL_SHORT_VER}-c9s" \ + com.redhat.component="${NAME}-${PERL_SHORT_VER}-container" \ + version="1" \ + com.redhat.license_terms="https://www.redhat.com/en/about/red-hat-end-user-license-agreements#UBI" \ + maintainer="SoftwareCollections.org " \ + help="For more information visit https://github.com/sclorg/s2i-${NAME}-container" \ + usage="s2i build quay.io/sclorg/${NAME}-${PERL_SHORT_VER}:latest " + +# Deselect a default stream +RUN INSTALL_PKGS="perl perl-devel mod_fcgid perl-App-cpanminus perl-FCGI patch" && \ + yum -y --allowerasing distrosync && \ + yum install -y --setopt=tsflags=nodocs $INSTALL_PKGS && \ + rpm -V $INSTALL_PKGS && \ + perl -v | grep -qe "v$PERL_VERSION\." && echo "Found VERSION $PERL_VERSION" && \ + yum -y clean all --enablerepo='*' + +# Copy the S2I scripts from the specific language image to $STI_SCRIPTS_PATH +COPY ./s2i/bin/ $STI_SCRIPTS_PATH + +# Copy extra files to the image. +COPY ./root/ / + +# In order to drop the root user, we have to make some directories world +# writeable as OpenShift default security model is to run the container under +# random UID. +RUN mkdir -p ${APP_ROOT}/etc/httpd.d && \ + sed -i -f ${APP_ROOT}/etc/httpdconf.sed /etc/httpd/conf/httpd.conf && \ + chmod -R og+rwx /var/run/httpd /run/mod_fcgid ${APP_ROOT}/etc/httpd.d && \ + chown -R 1001:0 ${APP_ROOT} && chmod -R ug+rwx ${APP_ROOT} && \ + rpm-file-permissions + +USER 1001 + +# Set the default CMD to print the usage of the language image +CMD $STI_SCRIPTS_PATH/usage diff --git a/5.38/Dockerfile.fedora b/5.38/Dockerfile.fedora new file mode 100644 index 0000000..bb40d4b --- /dev/null +++ b/5.38/Dockerfile.fedora @@ -0,0 +1,62 @@ +FROM quay.io/fedora/s2i-base:39 + +# This image provides a Perl 5.38 environment you can use to run your Perl applications. +EXPOSE 8080 + +# Image metadata +ENV PERL_VERSION=5.38 \ + PERL_SHORT_VER=538 \ + VERSION=0 \ + NAME=perl \ + PATH=/opt/app-root/src/extlib/bin:$PATH \ + PERL5LIB=/opt/app-root/src/extlib/lib/perl5 + +ENV SUMMARY="Platform for building and running Perl $PERL_VERSION applications" \ + DESCRIPTION="Perl $PERL_VERSION available as container is a base platform for \ +building and running various Perl $PERL_VERSION 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." + +LABEL summary="$SUMMARY" \ + description="$DESCRIPTION" \ + io.k8s.description="$DESCRIPTION" \ + io.k8s.display-name="Apache 2.4 with mod_fcgid and Perl $PERL_VERSION" \ + io.openshift.expose-services="8080:http" \ + io.openshift.tags="builder,${NAME},${NAME}${PERL_SHORT_VER}" \ + io.openshift.s2i.scripts-url="image:///usr/libexec/s2i" \ + io.s2i.scripts-url="image:///usr/libexec/s2i" \ + name="fedora/$NAME-$PERL_SHORT_VER" \ + com.redhat.component="$NAME" \ + version="$VERSION" \ + maintainer="SoftwareCollections.org " \ + help="For more information visit https://github.com/sclorg/s2i-${NAME}-container" \ + usage="s2i build quay.io/fedora/fedora/$NAME-$PERL_SHORT_VER " + +RUN INSTALL_PKGS="perl perl-devel mod_fcgid perl-App-cpanminus perl-FCGI patch" && \ + dnf install -y --setopt=tsflags=nodocs $INSTALL_PKGS && \ + rpm -V $INSTALL_PKGS && \ + perl -v | grep -qe "v$PERL_VERSION\." && echo "Found VERSION $PERL_VERSION" && \ + dnf -y clean all --enablerepo='*' + +# Copy the S2I scripts from the specific language image to $STI_SCRIPTS_PATH +COPY ./s2i/bin/ $STI_SCRIPTS_PATH + +# Copy extra files to the image. +COPY ./root/ / + +# In order to drop the root user, we have to make some directories world +# writeable as OpenShift default security model is to run the container under +# random UID. +RUN mkdir -p ${APP_ROOT}/etc/httpd.d && \ + sed -i -f ${APP_ROOT}/etc/httpdconf-fed.sed /etc/httpd/conf/httpd.conf && \ + chmod -R og+rwx /var/run/httpd /run/mod_fcgid ${APP_ROOT}/etc/httpd.d && \ + chown -R 1001:0 ${APP_ROOT} && chmod -R ug+rwx ${APP_ROOT} && \ + rpm-file-permissions + +USER 1001 + +# Set the default CMD to print the usage of the language image +CMD $STI_SCRIPTS_PATH/usage diff --git a/5.38/README.md b/5.38/README.md new file mode 100644 index 0000000..9281fc5 --- /dev/null +++ b/5.38/README.md @@ -0,0 +1,220 @@ +Perl 5.38 container image +========================= + +This container image includes Perl 5.38 as an [S2I](https://github.com/openshift/source-to-image) base image for your Perl 5.38 applications. +Users can choose Fedora based builder image. +The Fedora images are available in [Quay.io](https://quay.io/fedora/). +The resulting image can be run using [podman](https://github.com/containers/libpod). + +Note: while the examples in this README are calling `podman`, you can replace any such calls by `docker` with the same arguments. + +Description +----------- + +Perl 5.38 available as container is a base platform for +building and running various Perl 5.38 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 cpanm utility, so users can use it to install Perl +modules for their web applications. There is no guarantee for any specific CPAN module +version, that is included in the image; those versions can be changed anytime. + +Usage in Openshift +------------------ + +In this example, we will assume that you are using the `ubi9/perl-538` image, available via `perl:5.38` imagestream tag in Openshift. +To build a simple [perl-sample-app](https://github.com/sclorg/dancer-ex.git) application in Openshift: + +``` +oc new-app perl:5.38~https://github.com/sclorg/dancer-ex.git +``` + +**To access the application:** + +``` +oc get pods +oc exec -- curl 127.0.0.1:8080 +``` + +Source-to-Image framework and scripts +------------------------------------- + +This image supports the [Source-to-Image](https://docs.openshift.com/container-platform/3.11/creating_images/s2i.html) +(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 PHP 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: + +* The `/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). +* The `/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. + +Building an application using a Dockerfile +------------------------------------------ + +Compared to the Source-to-Image strategy, using a Dockerfile is a more +flexible way to build a Perl 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 Perl image in a Dockerfile, follow these steps: + +#### 1. Pull a base builder image to build on + +``` +podman pull ubi9/perl-538 +``` + +An ubi9 image `ubi9/perl-538` is used in this example. + +#### 2. Pull and application code + +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 +``` + +#### 3. Prepare an application inside a container + +This step usually consists of at least these parts: + +* putting the application source into the container +* installing the dependencies +* setting the default command in the resulting image + +For all these three parts, users can either setup all manually and use commands `perl` and `cpanm` explicitly in the Dockerfile ([3.1.](#31-to-use-your-own-setup-create-a-dockerfile-with-this-content)), or users can use the Source-to-Image scripts inside the image ([3.2.](#32-to-use-the-source-to-image-scripts-and-build-an-image-using-a-dockerfile-create-a-dockerfile-with-this-content); 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. + +##### 3.1 To use your own setup, create a Dockerfile with this content: + +``` +FROM ubi9/perl-538 + +# Add application sources +ADD app-src . + +# Set the paths to local Perl modules +ENV PATH=/opt/app-root/src/extlib/bin:${PATH} +ENV PERL5LIB=/opt/app-root/src/extlib/lib/perl5 + +# Install the dependencies +RUN cpanm --notest -l extlib Module::CoreList && \ + cpanm --notest -l extlib --installdeps . + +# Install Plack as an FCGI server +RUN cpanm --notest -l extlib Plack::Handler::FCGI FCGI::ProcManager +RUN patch --read-only=ignore -d ./extlib/lib/perl5 -p2 < /opt/app-root/Plack-1.0047-Work-around-mod_fcgid-bogus-SCRIPT_NAME-PATH_INFO.patch +RUN printf '\ +FcgidInitialEnv MODFCGID_VIRTUAL_LOCATION /\n\ +PassEnv HOME\n\ +FcgidInitialEnv "HOME" "%s"\n\ +PassEnv PATH\n\ +FcgidInitialEnv "PATH" "%s"\n\ +PassEnv PERL5LIB\n\ +FcgidInitialEnv "PERL5LIB" "%s"\n\ +\n\ +SetHandler fcgid-script\n\ +Options +ExecCGI\n\ +FcgidWrapper "/opt/app-root/psgiwrapper /usr/bin/env plackup -s FCGI ./app.psgi" virtual\n\ +\n' "$HOME" "$PATH" "$PERL5LIB"> /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 +``` + +##### 3.2 To use the Source-to-Image scripts and build an image using a Dockerfile, create a Dockerfile with this content: + +``` +FROM ubi9/perl-538 + +# 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 +``` + +#### 4. Build a new image from a Dockerfile prepared in the previous step + +``` +podman build -t perl-app . +``` + +#### 5. Run the resulting image with final application + +``` +podman run -d perl-app +``` + +Environment variables for Source-to-Image +----------------------------------------- + +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. + +* **HTTPD_START_SERVERS** + + The [StartServers](https://httpd.apache.org/docs/2.4/mod/mpm_common.html#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 httpd. 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_fcgid 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_fcgid will be configured to + execute that file. + +* **PSGI_RELOAD** + + Reload PSGI application when source code in application directory will be changed. + + If the PSGI_RELOAD variable is set to empty value, no reload will be used. + + If the PSGI_RELOAD variable is set and non-empty, it will cause reload defined by + code change in application directory. + +* **PSGI_URI_PATH** + + This variable overrides location URI path that is handled path the PSGI + application. Default value is "/". + +See also +-------- + +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`, for RHEL8 `Dockerfile.rhel8`, +for CentOS Stream 9 `Dockerfile.c9s` and the Fedora Dockerfile is called `Dockerfile.fedora`. diff --git a/5.38/root/opt/app-root/Plack-1.0047-Work-around-mod_fcgid-bogus-SCRIPT_NAME-PATH_INFO.patch b/5.38/root/opt/app-root/Plack-1.0047-Work-around-mod_fcgid-bogus-SCRIPT_NAME-PATH_INFO.patch new file mode 100644 index 0000000..cd313b9 --- /dev/null +++ b/5.38/root/opt/app-root/Plack-1.0047-Work-around-mod_fcgid-bogus-SCRIPT_NAME-PATH_INFO.patch @@ -0,0 +1,49 @@ +From d65d28410b91dfb3d9d12b6b8e49a79c7da54e1c Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= +Date: Wed, 9 Jan 2019 12:33:59 +0100 +Subject: [PATCH] Work around mod_fcgid bogus SCRIPT_NAME/PATH_INFO +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +mod_fcgid sends wrong PATH_INFO to virtual FcgidWrapper and that +prevents Plack from passing an application path to PSGI. + +This adds a side channel for passing application URI location to +Plack's FCGI handler. + +https://bugzilla.redhat.com/show_bug.cgi?id=1651746 + + + + +Signed-off-by: Petr Písař +--- + lib/Plack/Handler/FCGI.pm | 11 +++++++++++ + 1 file changed, 11 insertions(+) + +diff --git a/lib/Plack/Handler/FCGI.pm b/lib/Plack/Handler/FCGI.pm +index 029051c..0c491b2 100644 +--- a/lib/Plack/Handler/FCGI.pm ++++ b/lib/Plack/Handler/FCGI.pm +@@ -124,6 +124,17 @@ sub run { + delete $env->{HTTP_CONTENT_TYPE}; + delete $env->{HTTP_CONTENT_LENGTH}; + ++ # mod_fcgid provides wrong SCRIPT_NAME and PATH_INFO for virtual FCGI script handlers ++ # ++ # ++ # ++ if (exists $ENV{MODFCGID_VIRTUAL_LOCATION}) { ++ if ($ENV{MODFCGID_VIRTUAL_LOCATION} eq '/') { ++ $ENV{MODFCGID_VIRTUAL_LOCATION} = ''; ++ } ++ $env->{SCRIPT_NAME} = $ENV{MODFCGID_VIRTUAL_LOCATION}; ++ } ++ + # lighttpd munges multiple slashes in PATH_INFO into one. Try recovering it + my $uri = URI->new("http://localhost" . $env->{REQUEST_URI}); + $env->{PATH_INFO} = uri_unescape($uri->path); +-- +2.17.2 + diff --git a/5.38/root/opt/app-root/etc/httpd.conf b/5.38/root/opt/app-root/etc/httpd.conf new file mode 100644 index 0000000..c906339 --- /dev/null +++ b/5.38/root/opt/app-root/etc/httpd.conf @@ -0,0 +1,37 @@ +LoadModule env_module modules/mod_env.so + + + LoadModule cgid_module modules/mod_cgid.so + + + LoadModule cgid_module modules/mod_cgid.so + + + LoadModule cgi_module modules/mod_cgi.so + + +LoadModule unixd_module modules/mod_unixd.so +LoadModule authn_core_module modules/mod_authn_core.so +LoadModule authz_core_module modules/mod_authz_core.so +LoadModule fcgid_module modules/mod_fcgid.so + +FcgidIPCDir /run/mod_fcgid +FcgidProcessTableFile /run/mod_fcgid/fcgid_shm + +DirectoryIndex index.pl index.cgi index.fcg index.fcgi index.fpl + + + SetHandler cgi-script + Options +ExecCGI +SymLinksIfOwnerMatch + + + + SetHandler fcgid-script + Options +ExecCGI +SymLinksIfOwnerMatch + + + + Require all granted + + +IncludeOptional /opt/app-root/etc/httpd.d/*.conf \ No newline at end of file diff --git a/5.38/root/opt/app-root/etc/httpd.d/50-mpm.conf.template b/5.38/root/opt/app-root/etc/httpd.d/50-mpm.conf.template new file mode 100644 index 0000000..ebe24e8 --- /dev/null +++ b/5.38/root/opt/app-root/etc/httpd.d/50-mpm.conf.template @@ -0,0 +1,13 @@ +# This value should mirror what is set in MinSpareServers. +StartServers ${HTTPD_START_SERVERS} + + MinSpareServers ${HTTPD_START_SERVERS} + MaxSpareServers ${HTTPD_MAX_SPARE_SERVERS} + +# The MaxRequestWorkers directive sets the limit on the number of +# simultaneous requests that will be served. +# The default value, when no cgroup limits are set is 256. +MaxRequestWorkers ${HTTPD_MAX_REQUEST_WORKERS} +ServerLimit ${HTTPD_MAX_REQUEST_WORKERS} +MaxConnectionsPerChild 4000 +MaxKeepAliveRequests 100 \ No newline at end of file diff --git a/5.38/root/opt/app-root/etc/httpdconf-fed.sed b/5.38/root/opt/app-root/etc/httpdconf-fed.sed new file mode 100644 index 0000000..45f14db --- /dev/null +++ b/5.38/root/opt/app-root/etc/httpdconf-fed.sed @@ -0,0 +1,7 @@ +s/^Listen 80/Listen 0.0.0.0:8080/ +s/^User apache/User default/ +s/^Group apache/Group root/ +s%^DocumentRoot "/var/www/html"%DocumentRoot "/opt/app-root/src"% +s%^ Installing application source ..." +mv /tmp/src/* ./ + +# Fix source directory permissions +fix-permissions ./ + +if [ -d ./cfg ]; then + echo "---> Copying configuration files..." + if [ "$(ls -A ./cfg/*.conf)" ]; then + cp -av ./cfg/*.conf /opt/app-root/etc/httpd.d/ + fi +fi + +# Allow for http proxy to be specified in uppercase +if [[ -n "${HTTP_PROXY:-}" && -z "${http_proxy:-}" ]]; then + export http_proxy=$HTTP_PROXY +fi + +export CPAN_MIRROR=${CPAN_MIRROR:-""} + +MIRROR_ARGS="" + +if [ -n "$CPAN_MIRROR" ]; then + MIRROR_ARGS="--mirror $CPAN_MIRROR" +fi + +# Change the npm registry mirror if provided +if [ -n "$NPM_MIRROR" ]; then + npm config set registry $NPM_MIRROR +fi + + +# Don't test installed Perl modules by default +if [ "${ENABLE_CPAN_TEST}" = true ]; then + export ENABLE_CPAN_TEST="" +else + export ENABLE_CPAN_TEST="--notest" +fi + +# Configure mod_fcgid for PSGI. +# If PSGI_FILE variable is set but empty, skip it. +# If PSGI_FILE is set and non-empty, use it. +# If PSGI_FILE does not exist, check if exactly one ./*.psgi file exists and +# use that file. +# If PSGI_URI_PATH variable has a value, use it as a location. Default is "/". +PSGI_URI_PATH="${PSGI_URI_PATH:=/}" +if [ ! -v PSGI_FILE ]; then + PSGI_FILE=$(find -maxdepth 1 -name '*.psgi' -type f) +fi +PSGI_FILE_NUMBER=$(printf '%s' "$PSGI_FILE" | wc -l) +if [ -n "$PSGI_FILE" -a "$PSGI_FILE_NUMBER" -eq 0 ]; then + CONFIGURE_PSGI=1; +fi +if [ -n "$CONFIGURE_PSGI" ]; then + echo "---> PSGI application found in $PSGI_FILE" + cat >> cpanfile <<"EOF" +requires 'Plack::Handler::FCGI'; +requires 'FCGI::ProcManager'; +EOF + # XXX: Escape PSGI_FILE value against httpd control characters + PSGI_FILE=$(printf '%s' "$PSGI_FILE" | sed -e 's/\\/\\\\/g' -e 's/"/\\"/g') + cat > ${APP_ROOT}/etc/httpd.d/40-psgi.conf.template < + SetHandler fcgid-script + Options +ExecCGI + FcgidWrapper "${APP_ROOT}/psgiwrapper /usr/bin/env plackup \${PLACKUP_ARGS} -s FCGI $PSGI_FILE" virtual + +EOF +elif [ "$PSGI_FILE_NUMBER" -gt 0 ]; then + echo "---> Multiple PSGI applications found:" + printf '%s' "$PSGI_FILE" + echo "---> Skipping PSGI autoconfiguration!" +fi + +# Installing dependencies with cpanfile +if [ -f "cpanfile" ]; then + echo "---> Installing modules from cpanfile ..." + set +e + cpanm --no-interactive $MIRROR_ARGS $ENABLE_CPAN_TEST -l extlib --installdeps . + if [ $? != 0 ]; then + echo "---> Module installation failed, build.log content is:" + cat .cpanm/build.log + echo "---> Module installation failed!" + exit 1; + fi + set -e +else + echo "---> No cpanfile found, nothing to install" +fi + +# Make Plack compatible with broken mod_fcgi (bug #1651746) +if [ -n "$CONFIGURE_PSGI" ]; then + echo "---> Patching Plack::Handler::FCGI to work with mod_fcgi ..." + pushd ./extlib/lib/perl5 + patch --read-only=ignore -p2 < /opt/app-root/Plack-1.0047-Work-around-mod_fcgid-bogus-SCRIPT_NAME-PATH_INFO.patch + popd +fi + +# Fix source directory permissions +fix-permissions ./ diff --git a/5.38/s2i/bin/run b/5.38/s2i/bin/run new file mode 100755 index 0000000..4a8c879 --- /dev/null +++ b/5.38/s2i/bin/run @@ -0,0 +1,49 @@ +#!/bin/bash + +set -e + +# cpanm can install scripts. They should be available too. +export PATH=/opt/app-root/src/extlib/bin:${PATH} +# And we have to set Perl include path too because cpanm can install modules. +export PERL5LIB=/opt/app-root/src/extlib/lib/perl5 + +# Warning: Please note that this will pass all environment variables available +# within the container to mod_cgid by means of PassEnv and to mod_fcgid by +# means of FcgidInitialEnv in the env.conf file. +if [ ! -f /opt/app-root/etc/httpd.d/env.conf ]; then + env | awk -F'=' '{print "PassEnv "$1"\nFcgidInitialEnv "$1" \""$2"\""}' \ + > /opt/app-root/etc/httpd.d/env.conf +fi + +export_vars=$(cgroup-limits) ; export $export_vars + +# Validate server limit option +if [[ ! "${HTTPD_MAX_REQUEST_WORKERS:-1}" =~ ^[1-9][0-9]*$ || "${HTTPD_MAX_REQUEST_WORKERS:-1}" -gt 20000 ]]; then + echo "HTTPD_MAX_REQUEST_WORKERS needs be an integer between 1 and 20000" + exit 1 +fi + +# If there is no server limit specified, try to guess the best value +if [ -z "${HTTPD_MAX_REQUEST_WORKERS:-}" ]; then + MAX_SERVER_LIMIT=$(((MEMORY_LIMIT_IN_BYTES/1024/1024 - 30) / 7)) + MAX_SERVER_LIMIT=$((MAX_SERVER_LIMIT > 0 ? MAX_SERVER_LIMIT : 1)) + export HTTPD_MAX_REQUEST_WORKERS=$((MAX_SERVER_LIMIT > 256 ? 256 : MAX_SERVER_LIMIT)) +fi + +export HTTPD_START_SERVERS=${HTTPD_START_SERVERS:-8} +export HTTPD_MAX_SPARE_SERVERS=$((HTTPD_START_SERVERS+10)) + +envsubst < /opt/app-root/etc/httpd.d/50-mpm.conf.template > /opt/app-root/etc/httpd.d/50-mpm.conf + +if [ -f ${APP_ROOT}/etc/httpd.d/40-psgi.conf.template ]; then + PLACKUP_ARGS="" + if [ -n "$PSGI_RELOAD" ]; then + PLACKUP_ARGS="-r -R ${APP_ROOT}/src/" + fi + + export PLACKUP_ARGS=${PLACKUP_ARGS} + + envsubst < ${APP_ROOT}/etc/httpd.d/40-psgi.conf.template > ${APP_ROOT}/etc/httpd.d/40-psgi.conf +fi + +exec httpd -C 'Include /opt/app-root/etc/httpd.conf' -D FOREGROUND diff --git a/5.38/s2i/bin/usage b/5.38/s2i/bin/usage new file mode 100755 index 0000000..cfdd155 --- /dev/null +++ b/5.38/s2i/bin/usage @@ -0,0 +1,19 @@ +#!/bin/sh + +DISTRO=`cat /etc/*-release | grep ^ID= | grep -Po '".*?"' | tr -d '"'` +NAMESPACE=centos +[[ $DISTRO =~ rhel* ]] && NAMESPACE=rhscl + +cat < -- curl 127.0.0.1:8080 +EOF diff --git a/5.38/test/binpath b/5.38/test/binpath new file mode 120000 index 0000000..9f59bea --- /dev/null +++ b/5.38/test/binpath @@ -0,0 +1 @@ +../../test/binpath \ No newline at end of file diff --git a/5.38/test/examples b/5.38/test/examples new file mode 120000 index 0000000..da7b196 --- /dev/null +++ b/5.38/test/examples @@ -0,0 +1 @@ +../../examples/ \ No newline at end of file diff --git a/5.38/test/fcgi b/5.38/test/fcgi new file mode 120000 index 0000000..c8cb399 --- /dev/null +++ b/5.38/test/fcgi @@ -0,0 +1 @@ +../../test/fcgi \ No newline at end of file diff --git a/5.38/test/imagestreams b/5.38/test/imagestreams new file mode 120000 index 0000000..0dcbe9e --- /dev/null +++ b/5.38/test/imagestreams @@ -0,0 +1 @@ +../../imagestreams/ \ No newline at end of file diff --git a/5.38/test/psgi b/5.38/test/psgi new file mode 120000 index 0000000..1708384 --- /dev/null +++ b/5.38/test/psgi @@ -0,0 +1 @@ +../../test/psgi \ No newline at end of file diff --git a/5.38/test/psgi-hot_deploy b/5.38/test/psgi-hot_deploy new file mode 120000 index 0000000..f63fd8e --- /dev/null +++ b/5.38/test/psgi-hot_deploy @@ -0,0 +1 @@ +../../test/psgi-hot_deploy \ No newline at end of file diff --git a/5.38/test/psgi-variables b/5.38/test/psgi-variables new file mode 120000 index 0000000..a8e0f13 --- /dev/null +++ b/5.38/test/psgi-variables @@ -0,0 +1 @@ +../../test/psgi-variables \ No newline at end of file diff --git a/5.38/test/run b/5.38/test/run new file mode 120000 index 0000000..d2c52f2 --- /dev/null +++ b/5.38/test/run @@ -0,0 +1 @@ +../../test/run-modfcgid \ No newline at end of file diff --git a/5.38/test/run-openshift b/5.38/test/run-openshift new file mode 120000 index 0000000..ec13e4a --- /dev/null +++ b/5.38/test/run-openshift @@ -0,0 +1 @@ +../../test/run-openshift \ No newline at end of file diff --git a/5.38/test/run-openshift-remote-cluster b/5.38/test/run-openshift-remote-cluster new file mode 120000 index 0000000..1bffcba --- /dev/null +++ b/5.38/test/run-openshift-remote-cluster @@ -0,0 +1 @@ +../../test/run-openshift-remote-cluster \ No newline at end of file diff --git a/5.38/test/sample-test-app b/5.38/test/sample-test-app new file mode 120000 index 0000000..ba0a23b --- /dev/null +++ b/5.38/test/sample-test-app @@ -0,0 +1 @@ +../../examples/sample-test-app/ \ No newline at end of file diff --git a/5.38/test/sample-test-app.json b/5.38/test/sample-test-app.json new file mode 120000 index 0000000..3627c79 --- /dev/null +++ b/5.38/test/sample-test-app.json @@ -0,0 +1 @@ +../../examples/templates/sample-test-app.json \ No newline at end of file diff --git a/5.38/test/test-lib-openshift.sh b/5.38/test/test-lib-openshift.sh new file mode 120000 index 0000000..4f9f299 --- /dev/null +++ b/5.38/test/test-lib-openshift.sh @@ -0,0 +1 @@ +../../common/test-lib-openshift.sh \ No newline at end of file diff --git a/5.38/test/test-lib-perl.sh b/5.38/test/test-lib-perl.sh new file mode 120000 index 0000000..bac54d8 --- /dev/null +++ b/5.38/test/test-lib-perl.sh @@ -0,0 +1 @@ +../../test/test-lib-perl.sh \ No newline at end of file diff --git a/5.38/test/test-lib-remote-openshift.sh b/5.38/test/test-lib-remote-openshift.sh new file mode 120000 index 0000000..92ad2f4 --- /dev/null +++ b/5.38/test/test-lib-remote-openshift.sh @@ -0,0 +1 @@ +../../common/test-lib-remote-openshift.sh \ No newline at end of file diff --git a/5.38/test/test-lib.sh b/5.38/test/test-lib.sh new file mode 120000 index 0000000..1ac99b9 --- /dev/null +++ b/5.38/test/test-lib.sh @@ -0,0 +1 @@ +../../common/test-lib.sh \ No newline at end of file diff --git a/5.38/test/test-openshift.yaml b/5.38/test/test-openshift.yaml new file mode 120000 index 0000000..8613fbb --- /dev/null +++ b/5.38/test/test-openshift.yaml @@ -0,0 +1 @@ +../../common/test-openshift.yaml \ No newline at end of file diff --git a/5.38/test/warningonstderr b/5.38/test/warningonstderr new file mode 120000 index 0000000..902d83f --- /dev/null +++ b/5.38/test/warningonstderr @@ -0,0 +1 @@ +../../test/warningonstderr \ No newline at end of file diff --git a/Makefile b/Makefile index 5f825c6..c72af81 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ # Variables are documented in common/build.sh. BASE_IMAGE_NAME = perl -VERSIONS = 5.26-mod_fcgid 5.26 5.30-mod_fcgid 5.30 5.32 5.34 5.36 +VERSIONS = 5.26-mod_fcgid 5.26 5.30-mod_fcgid 5.30 5.32 5.34 5.36 5.38 OPENSHIFT_NAMESPACES = 5.16 # HACK: Ensure that 'git pull' for old clones doesn't cause confusion. diff --git a/README.md b/README.md index c46c05d..11cb4bd 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,7 @@ Images available on Quay are: * Fedora [perl-5.32](https://quay.io/repository/fedora/perl-532) * Fedora [perl-5.34](https://quay.io/repository/fedora/perl-534) * Fedora [perl-5.36](https://quay.io/repository/fedora/perl-536) +* Fedora [perl-5.38](https://quay.io/repository/fedora/perl-538) This repository contains the source for building various versions of the Perl application as a reproducible container image using @@ -34,6 +35,7 @@ Perl versions currently provided: * [perl-5.32](5.32) * [perl-5.34](5.34) * [perl-5.36](5.36) +* [perl-5.38](5.38) RHEL versions currently supported: * RHEL7 @@ -107,6 +109,9 @@ see [usage documentation](5.34/README.md). For information about usage of the Dockerfile for Perl 5.36 - mod_fcgid version, see [usage documentation](5.36/README.md). +For information about usage of the Dockerfile for Perl 5.38 - mod_fcgid version, +see [usage documentation](5.38/README.md). + Test ---- This repository also provides a [S2I](https://github.com/openshift/source-to-image) test framework, diff --git a/examples/from-dockerfile/5.38/Dockerfile b/examples/from-dockerfile/5.38/Dockerfile new file mode 100644 index 0000000..855986e --- /dev/null +++ b/examples/from-dockerfile/5.38/Dockerfile @@ -0,0 +1,32 @@ +FROM ubi9/perl-538 + +# Add application sources +ADD app-src . + +# Set the paths to local Perl modules +ENV PATH=/opt/app-root/src/extlib/bin:${PATH} +ENV PERL5LIB=/opt/app-root/src/extlib/lib/perl5 + +# Install the dependencies +RUN cpanm --notest -l extlib Module::CoreList && \ + cpanm --notest -l extlib --installdeps . + +# Install Plack as an FCGI server +RUN cpanm --notest -l extlib Plack::Handler::FCGI FCGI::ProcManager +RUN patch --read-only=ignore -d ./extlib/lib/perl5 -p2 < /opt/app-root/Plack-1.0047-Work-around-mod_fcgid-bogus-SCRIPT_NAME-PATH_INFO.patch +RUN printf '\ +FcgidInitialEnv MODFCGID_VIRTUAL_LOCATION /\n\ +PassEnv HOME\n\ +FcgidInitialEnv "HOME" "%s"\n\ +PassEnv PATH\n\ +FcgidInitialEnv "PATH" "%s"\n\ +PassEnv PERL5LIB\n\ +FcgidInitialEnv "PERL5LIB" "%s"\n\ +\n\ +SetHandler fcgid-script\n\ +Options +ExecCGI\n\ +FcgidWrapper "/opt/app-root/psgiwrapper /usr/bin/env plackup -s FCGI ./app.psgi" virtual\n\ +\n' "$HOME" "$PATH" "$PERL5LIB"> /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 diff --git a/examples/from-dockerfile/5.38/Dockerfile.s2i b/examples/from-dockerfile/5.38/Dockerfile.s2i new file mode 100644 index 0000000..e34647e --- /dev/null +++ b/examples/from-dockerfile/5.38/Dockerfile.s2i @@ -0,0 +1,14 @@ +FROM ubi9/perl-538 + +# Add application sources to a directory that the assemble script expects 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 diff --git a/test/run-modfcgid b/test/run-modfcgid index dc1bc40..34197f7 100755 --- a/test/run-modfcgid +++ b/test/run-modfcgid @@ -196,6 +196,8 @@ test_application() { version="5.34" elif [ x"$VERSION" == "x5.36" ]; then version="5.36" + elif [ x"$VERSION" == "x5.38" ]; then + version="5.38" fi test_scl_usage "perl --version" "v${version}." ct_check_testcase_result $?