From dca930dae03c33c6694318871599784a8461629f Mon Sep 17 00:00:00 2001 From: Pavel Valena Date: Mon, 12 Feb 2024 20:35:02 +0100 Subject: [PATCH 1/4] Add Ruby 3.3: rename 3.1 to 3.3 (3 step/commit workflow to preserve history) --- {3.1 => 3.3}/Dockerfile.c9s | 0 {3.1 => 3.3}/Dockerfile.fedora | 0 {3.1 => 3.3}/Dockerfile.rhel8 | 0 {3.1 => 3.3}/Dockerfile.rhel9 | 0 {3.1 => 3.3}/README.md | 0 {3.1 => 3.3}/root/opt/app-root/.gemrc | 0 {3.1 => 3.3}/root/opt/app-root/etc/puma.cfg | 0 {3.1 => 3.3}/s2i/bin/assemble | 0 {3.1 => 3.3}/s2i/bin/run | 0 {3.1 => 3.3}/s2i/bin/usage | 0 {3.1 => 3.3}/test/examples | 0 {3.1 => 3.3}/test/imagestreams | 0 {3.1 => 3.3}/test/puma-test-app/Gemfile | 0 {3.1 => 3.3}/test/puma-test-app/Gemfile.lock | 0 {3.1 => 3.3}/test/puma-test-app/app.rb | 0 {3.1 => 3.3}/test/puma-test-app/config.ru | 0 {3.1 => 3.3}/test/rack-test-app/Gemfile | 0 {3.1 => 3.3}/test/rack-test-app/Gemfile.lock | 0 {3.1 => 3.3}/test/rack-test-app/app.rb | 0 {3.1 => 3.3}/test/rack-test-app/config.ru | 0 {3.1 => 3.3}/test/run | 0 {3.1 => 3.3}/test/run-conu | 0 {3.1 => 3.3}/test/run-openshift | 0 {3.1 => 3.3}/test/run-openshift-remote-cluster | 0 {3.1 => 3.3}/test/test-lib-openshift.sh | 0 {3.1 => 3.3}/test/test-lib-remote-openshift.sh | 0 {3.1 => 3.3}/test/test-lib-ruby.sh | 0 {3.1 => 3.3}/test/test-lib.sh | 0 {3.1 => 3.3}/test/test-openshift.yaml | 0 {3.1 => 3.3}/test/test_s2i.py | 0 30 files changed, 0 insertions(+), 0 deletions(-) rename {3.1 => 3.3}/Dockerfile.c9s (100%) rename {3.1 => 3.3}/Dockerfile.fedora (100%) rename {3.1 => 3.3}/Dockerfile.rhel8 (100%) rename {3.1 => 3.3}/Dockerfile.rhel9 (100%) rename {3.1 => 3.3}/README.md (100%) rename {3.1 => 3.3}/root/opt/app-root/.gemrc (100%) rename {3.1 => 3.3}/root/opt/app-root/etc/puma.cfg (100%) rename {3.1 => 3.3}/s2i/bin/assemble (100%) rename {3.1 => 3.3}/s2i/bin/run (100%) rename {3.1 => 3.3}/s2i/bin/usage (100%) rename {3.1 => 3.3}/test/examples (100%) rename {3.1 => 3.3}/test/imagestreams (100%) rename {3.1 => 3.3}/test/puma-test-app/Gemfile (100%) rename {3.1 => 3.3}/test/puma-test-app/Gemfile.lock (100%) rename {3.1 => 3.3}/test/puma-test-app/app.rb (100%) rename {3.1 => 3.3}/test/puma-test-app/config.ru (100%) rename {3.1 => 3.3}/test/rack-test-app/Gemfile (100%) rename {3.1 => 3.3}/test/rack-test-app/Gemfile.lock (100%) rename {3.1 => 3.3}/test/rack-test-app/app.rb (100%) rename {3.1 => 3.3}/test/rack-test-app/config.ru (100%) rename {3.1 => 3.3}/test/run (100%) rename {3.1 => 3.3}/test/run-conu (100%) rename {3.1 => 3.3}/test/run-openshift (100%) rename {3.1 => 3.3}/test/run-openshift-remote-cluster (100%) rename {3.1 => 3.3}/test/test-lib-openshift.sh (100%) rename {3.1 => 3.3}/test/test-lib-remote-openshift.sh (100%) rename {3.1 => 3.3}/test/test-lib-ruby.sh (100%) rename {3.1 => 3.3}/test/test-lib.sh (100%) rename {3.1 => 3.3}/test/test-openshift.yaml (100%) rename {3.1 => 3.3}/test/test_s2i.py (100%) diff --git a/3.1/Dockerfile.c9s b/3.3/Dockerfile.c9s similarity index 100% rename from 3.1/Dockerfile.c9s rename to 3.3/Dockerfile.c9s diff --git a/3.1/Dockerfile.fedora b/3.3/Dockerfile.fedora similarity index 100% rename from 3.1/Dockerfile.fedora rename to 3.3/Dockerfile.fedora diff --git a/3.1/Dockerfile.rhel8 b/3.3/Dockerfile.rhel8 similarity index 100% rename from 3.1/Dockerfile.rhel8 rename to 3.3/Dockerfile.rhel8 diff --git a/3.1/Dockerfile.rhel9 b/3.3/Dockerfile.rhel9 similarity index 100% rename from 3.1/Dockerfile.rhel9 rename to 3.3/Dockerfile.rhel9 diff --git a/3.1/README.md b/3.3/README.md similarity index 100% rename from 3.1/README.md rename to 3.3/README.md diff --git a/3.1/root/opt/app-root/.gemrc b/3.3/root/opt/app-root/.gemrc similarity index 100% rename from 3.1/root/opt/app-root/.gemrc rename to 3.3/root/opt/app-root/.gemrc diff --git a/3.1/root/opt/app-root/etc/puma.cfg b/3.3/root/opt/app-root/etc/puma.cfg similarity index 100% rename from 3.1/root/opt/app-root/etc/puma.cfg rename to 3.3/root/opt/app-root/etc/puma.cfg diff --git a/3.1/s2i/bin/assemble b/3.3/s2i/bin/assemble similarity index 100% rename from 3.1/s2i/bin/assemble rename to 3.3/s2i/bin/assemble diff --git a/3.1/s2i/bin/run b/3.3/s2i/bin/run similarity index 100% rename from 3.1/s2i/bin/run rename to 3.3/s2i/bin/run diff --git a/3.1/s2i/bin/usage b/3.3/s2i/bin/usage similarity index 100% rename from 3.1/s2i/bin/usage rename to 3.3/s2i/bin/usage diff --git a/3.1/test/examples b/3.3/test/examples similarity index 100% rename from 3.1/test/examples rename to 3.3/test/examples diff --git a/3.1/test/imagestreams b/3.3/test/imagestreams similarity index 100% rename from 3.1/test/imagestreams rename to 3.3/test/imagestreams diff --git a/3.1/test/puma-test-app/Gemfile b/3.3/test/puma-test-app/Gemfile similarity index 100% rename from 3.1/test/puma-test-app/Gemfile rename to 3.3/test/puma-test-app/Gemfile diff --git a/3.1/test/puma-test-app/Gemfile.lock b/3.3/test/puma-test-app/Gemfile.lock similarity index 100% rename from 3.1/test/puma-test-app/Gemfile.lock rename to 3.3/test/puma-test-app/Gemfile.lock diff --git a/3.1/test/puma-test-app/app.rb b/3.3/test/puma-test-app/app.rb similarity index 100% rename from 3.1/test/puma-test-app/app.rb rename to 3.3/test/puma-test-app/app.rb diff --git a/3.1/test/puma-test-app/config.ru b/3.3/test/puma-test-app/config.ru similarity index 100% rename from 3.1/test/puma-test-app/config.ru rename to 3.3/test/puma-test-app/config.ru diff --git a/3.1/test/rack-test-app/Gemfile b/3.3/test/rack-test-app/Gemfile similarity index 100% rename from 3.1/test/rack-test-app/Gemfile rename to 3.3/test/rack-test-app/Gemfile diff --git a/3.1/test/rack-test-app/Gemfile.lock b/3.3/test/rack-test-app/Gemfile.lock similarity index 100% rename from 3.1/test/rack-test-app/Gemfile.lock rename to 3.3/test/rack-test-app/Gemfile.lock diff --git a/3.1/test/rack-test-app/app.rb b/3.3/test/rack-test-app/app.rb similarity index 100% rename from 3.1/test/rack-test-app/app.rb rename to 3.3/test/rack-test-app/app.rb diff --git a/3.1/test/rack-test-app/config.ru b/3.3/test/rack-test-app/config.ru similarity index 100% rename from 3.1/test/rack-test-app/config.ru rename to 3.3/test/rack-test-app/config.ru diff --git a/3.1/test/run b/3.3/test/run similarity index 100% rename from 3.1/test/run rename to 3.3/test/run diff --git a/3.1/test/run-conu b/3.3/test/run-conu similarity index 100% rename from 3.1/test/run-conu rename to 3.3/test/run-conu diff --git a/3.1/test/run-openshift b/3.3/test/run-openshift similarity index 100% rename from 3.1/test/run-openshift rename to 3.3/test/run-openshift diff --git a/3.1/test/run-openshift-remote-cluster b/3.3/test/run-openshift-remote-cluster similarity index 100% rename from 3.1/test/run-openshift-remote-cluster rename to 3.3/test/run-openshift-remote-cluster diff --git a/3.1/test/test-lib-openshift.sh b/3.3/test/test-lib-openshift.sh similarity index 100% rename from 3.1/test/test-lib-openshift.sh rename to 3.3/test/test-lib-openshift.sh diff --git a/3.1/test/test-lib-remote-openshift.sh b/3.3/test/test-lib-remote-openshift.sh similarity index 100% rename from 3.1/test/test-lib-remote-openshift.sh rename to 3.3/test/test-lib-remote-openshift.sh diff --git a/3.1/test/test-lib-ruby.sh b/3.3/test/test-lib-ruby.sh similarity index 100% rename from 3.1/test/test-lib-ruby.sh rename to 3.3/test/test-lib-ruby.sh diff --git a/3.1/test/test-lib.sh b/3.3/test/test-lib.sh similarity index 100% rename from 3.1/test/test-lib.sh rename to 3.3/test/test-lib.sh diff --git a/3.1/test/test-openshift.yaml b/3.3/test/test-openshift.yaml similarity index 100% rename from 3.1/test/test-openshift.yaml rename to 3.3/test/test-openshift.yaml diff --git a/3.1/test/test_s2i.py b/3.3/test/test_s2i.py similarity index 100% rename from 3.1/test/test_s2i.py rename to 3.3/test/test_s2i.py From 0558d3dbc95a784e05dfefa1bedc23429e96b53d Mon Sep 17 00:00:00 2001 From: Pavel Valena Date: Mon, 12 Feb 2024 20:39:17 +0100 Subject: [PATCH 2/4] Add Ruby 3.3: re-add 3.1 (3 step/commit workflow to preserve history) --- 3.1/Dockerfile.c9s | 66 ++++++++ 3.1/Dockerfile.fedora | 52 ++++++ 3.1/Dockerfile.rhel8 | 65 ++++++++ 3.1/Dockerfile.rhel9 | 65 ++++++++ 3.1/README.md | 229 ++++++++++++++++++++++++++ 3.1/root/opt/app-root/.gemrc | 9 + 3.1/root/opt/app-root/etc/puma.cfg | 50 ++++++ 3.1/s2i/bin/assemble | 68 ++++++++ 3.1/s2i/bin/run | 39 +++++ 3.1/s2i/bin/usage | 18 ++ 3.1/test/examples | 1 + 3.1/test/imagestreams | 1 + 3.1/test/puma-test-app/Gemfile | 4 + 3.1/test/puma-test-app/Gemfile.lock | 25 +++ 3.1/test/puma-test-app/app.rb | 5 + 3.1/test/puma-test-app/config.ru | 2 + 3.1/test/rack-test-app/Gemfile | 4 + 3.1/test/rack-test-app/Gemfile.lock | 23 +++ 3.1/test/rack-test-app/app.rb | 5 + 3.1/test/rack-test-app/config.ru | 2 + 3.1/test/run | 1 + 3.1/test/run-conu | 1 + 3.1/test/run-openshift | 1 + 3.1/test/run-openshift-remote-cluster | 1 + 3.1/test/test-lib-openshift.sh | 1 + 3.1/test/test-lib-remote-openshift.sh | 1 + 3.1/test/test-lib-ruby.sh | 1 + 3.1/test/test-lib.sh | 1 + 3.1/test/test-openshift.yaml | 1 + 3.1/test/test_s2i.py | 1 + 30 files changed, 743 insertions(+) create mode 100644 3.1/Dockerfile.c9s create mode 100644 3.1/Dockerfile.fedora create mode 100644 3.1/Dockerfile.rhel8 create mode 100644 3.1/Dockerfile.rhel9 create mode 100644 3.1/README.md create mode 100644 3.1/root/opt/app-root/.gemrc create mode 100644 3.1/root/opt/app-root/etc/puma.cfg create mode 100755 3.1/s2i/bin/assemble create mode 100755 3.1/s2i/bin/run create mode 100755 3.1/s2i/bin/usage create mode 120000 3.1/test/examples create mode 120000 3.1/test/imagestreams create mode 100755 3.1/test/puma-test-app/Gemfile create mode 100644 3.1/test/puma-test-app/Gemfile.lock create mode 100755 3.1/test/puma-test-app/app.rb create mode 100755 3.1/test/puma-test-app/config.ru create mode 100755 3.1/test/rack-test-app/Gemfile create mode 100644 3.1/test/rack-test-app/Gemfile.lock create mode 100755 3.1/test/rack-test-app/app.rb create mode 100755 3.1/test/rack-test-app/config.ru create mode 120000 3.1/test/run create mode 120000 3.1/test/run-conu create mode 120000 3.1/test/run-openshift create mode 120000 3.1/test/run-openshift-remote-cluster create mode 120000 3.1/test/test-lib-openshift.sh create mode 120000 3.1/test/test-lib-remote-openshift.sh create mode 120000 3.1/test/test-lib-ruby.sh create mode 120000 3.1/test/test-lib.sh create mode 120000 3.1/test/test-openshift.yaml create mode 120000 3.1/test/test_s2i.py diff --git a/3.1/Dockerfile.c9s b/3.1/Dockerfile.c9s new file mode 100644 index 00000000..0a81b662 --- /dev/null +++ b/3.1/Dockerfile.c9s @@ -0,0 +1,66 @@ +FROM quay.io/sclorg/s2i-base-c9s:c9s + +# This image provides a Ruby environment you can use to run your Ruby +# applications. + +EXPOSE 8080 + +ENV RUBY_MAJOR_VERSION=3 \ + RUBY_MINOR_VERSION=1 + +ENV RUBY_VERSION="${RUBY_MAJOR_VERSION}.${RUBY_MINOR_VERSION}" \ + RUBY_SCL_NAME_VERSION="${RUBY_MAJOR_VERSION}${RUBY_MINOR_VERSION}" + +ENV RUBY_SCL="ruby-${RUBY_SCL_NAME_VERSION}" \ + IMAGE_NAME="ubi8/ruby-${RUBY_SCL_NAME_VERSION}" \ + SUMMARY="Platform for building and running Ruby $RUBY_VERSION applications" \ + DESCRIPTION="Ruby $RUBY_VERSION available as container is a base platform for \ +building and running various Ruby $RUBY_VERSION applications and frameworks. \ +Ruby is the interpreted scripting language for quick and easy object-oriented programming. \ +It has many features to process text files and to do system management tasks (as in Perl). \ +It is simple, straight-forward, and extensible." + +LABEL summary="$SUMMARY" \ + description="$DESCRIPTION" \ + io.k8s.description="$DESCRIPTION" \ + io.k8s.display-name="Ruby ${RUBY_VERSION}" \ + io.openshift.expose-services="8080:http" \ + io.openshift.tags="builder,ruby,ruby${RUBY_SCL_NAME_VERSION},${RUBY_SCL}" \ + com.redhat.component="${RUBY_SCL}-container" \ + name="${IMAGE_NAME}" \ + version="1" \ + com.redhat.license_terms="https://www.redhat.com/en/about/red-hat-end-user-license-agreements#UBI" \ + usage="s2i build https://github.com/sclorg/s2i-ruby-container.git \ +--context-dir=${RUBY_VERSION}/test/puma-test-app/ ${IMAGE_NAME} ruby-sample-app" \ + maintainer="SoftwareCollections.org " + +RUN yum -y module enable ruby:$RUBY_VERSION && \ + INSTALL_PKGS=" \ + libffi-devel \ + ruby \ + ruby-devel \ + rubygem-rake \ + rubygem-bundler \ + ruby-bundled-gems \ + redhat-rpm-config \ + " && \ + yum install -y --setopt=tsflags=nodocs ${INSTALL_PKGS} && \ + yum reinstall -y --setopt=tsflags=nodocs tzdata && \ + yum -y clean all --enablerepo='*' && \ + ruby -v | grep -qe "^ruby $RUBY_VERSION\." && echo "Found VERSION $RUBY_VERSION" && \ + rpm -V ${INSTALL_PKGS} + +# 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/ / + +# Drop the root user and make the content of /opt/app-root owned by user 1001 +RUN 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/3.1/Dockerfile.fedora b/3.1/Dockerfile.fedora new file mode 100644 index 00000000..6823e01d --- /dev/null +++ b/3.1/Dockerfile.fedora @@ -0,0 +1,52 @@ +FROM quay.io/fedora/s2i-base:37 + +# This image provides a Ruby environment you can use to run your Ruby +# applications. + +EXPOSE 8080 + +ENV NAME=ruby \ + RUBY_VERSION=3.1 \ + RUBY_SHORT_VER=31 \ + VERSION=0 + +ENV SUMMARY="Platform for building and running Ruby $RUBY_VERSION applications" \ + DESCRIPTION="Ruby $RUBY_VERSION available as container is a base platform for \ +building and running various Ruby $RUBY_VERSION applications and frameworks. \ +Ruby is the interpreted scripting language for quick and easy object-oriented programming. \ +It has many features to process text files and to do system management tasks (as in Perl). \ +It is simple, straight-forward, and extensible." + +LABEL summary="$SUMMARY" \ + description="$DESCRIPTION" \ + io.k8s.description="$DESCRIPTION" \ + io.k8s.display-name="Ruby ${RUBY_VERSION}" \ + io.openshift.expose-services="8080:http" \ + io.openshift.tags="builder,ruby,ruby${RUBY_SHORT_VER}" \ + com.redhat.component="$NAME" \ + name="fedora/$NAME-$RUBY_SHORT_VER" \ + version="$VERSION" \ + usage="s2i build https://github.com/sclorg/s2i-ruby-container.git --context-dir=${RUBY_VERSION}/test/puma-test-app/ quay.io/fedora/$NAME-$RUBY_SHORT_VER ruby-sample-app" \ + maintainer="SoftwareCollections.org " + +# Install required packages +RUN INSTALL_PKGS="ruby ruby-devel rubygem-bundler ruby-bundled-gems rubygem-rake rubygems-devel redhat-rpm-config libffi-devel" && \ + dnf install -y --setopt=tsflags=nodocs $INSTALL_PKGS && \ + rpm -V $INSTALL_PKGS && \ + ruby -v | grep -qe "^ruby $RUBY_VERSION\." && echo "Found VERSION $RUBY_VERSION" && \ + dnf clean all + +# 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/ / + +# Drop the root user and make the content of /opt/app-root owned by user 1001 +RUN 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/3.1/Dockerfile.rhel8 b/3.1/Dockerfile.rhel8 new file mode 100644 index 00000000..b650d92a --- /dev/null +++ b/3.1/Dockerfile.rhel8 @@ -0,0 +1,65 @@ +FROM ubi8/s2i-base + +# This image provides a Ruby environment you can use to run your Ruby +# applications. + +EXPOSE 8080 + +ENV RUBY_MAJOR_VERSION=3 \ + RUBY_MINOR_VERSION=1 + +ENV RUBY_VERSION="${RUBY_MAJOR_VERSION}.${RUBY_MINOR_VERSION}" \ + RUBY_SCL_NAME_VERSION="${RUBY_MAJOR_VERSION}${RUBY_MINOR_VERSION}" + +ENV RUBY_SCL="ruby-${RUBY_SCL_NAME_VERSION}" \ + IMAGE_NAME="ubi8/ruby-${RUBY_SCL_NAME_VERSION}" \ + SUMMARY="Platform for building and running Ruby $RUBY_VERSION applications" \ + DESCRIPTION="Ruby $RUBY_VERSION available as container is a base platform for \ +building and running various Ruby $RUBY_VERSION applications and frameworks. \ +Ruby is the interpreted scripting language for quick and easy object-oriented programming. \ +It has many features to process text files and to do system management tasks (as in Perl). \ +It is simple, straight-forward, and extensible." + +LABEL summary="$SUMMARY" \ + description="$DESCRIPTION" \ + io.k8s.description="$DESCRIPTION" \ + io.k8s.display-name="Ruby ${RUBY_VERSION}" \ + io.openshift.expose-services="8080:http" \ + io.openshift.tags="builder,ruby,ruby${RUBY_SCL_NAME_VERSION},${RUBY_SCL}" \ + com.redhat.component="${RUBY_SCL}-container" \ + name="${IMAGE_NAME}" \ + version="1" \ + com.redhat.license_terms="https://www.redhat.com/en/about/red-hat-end-user-license-agreements#UBI" \ + usage="s2i build https://github.com/sclorg/s2i-ruby-container.git \ +--context-dir=${RUBY_VERSION}/test/puma-test-app/ ${IMAGE_NAME} ruby-sample-app" \ + maintainer="SoftwareCollections.org " + +RUN yum -y module enable ruby:$RUBY_VERSION && \ + INSTALL_PKGS=" \ + libffi-devel \ + ruby \ + ruby-devel \ + rubygem-rake \ + rubygem-bundler \ + ruby-bundled-gems \ + redhat-rpm-config \ + " && \ + yum install -y --setopt=tsflags=nodocs ${INSTALL_PKGS} && \ + yum -y clean all --enablerepo='*' && \ + ruby -v | grep -qe "^ruby $RUBY_VERSION\." && echo "Found VERSION $RUBY_VERSION" && \ + rpm -V ${INSTALL_PKGS} + +# 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/ / + +# Drop the root user and make the content of /opt/app-root owned by user 1001 +RUN 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/3.1/Dockerfile.rhel9 b/3.1/Dockerfile.rhel9 new file mode 100644 index 00000000..969fe2a5 --- /dev/null +++ b/3.1/Dockerfile.rhel9 @@ -0,0 +1,65 @@ +FROM ubi9/s2i-base + +# This image provides a Ruby environment you can use to run your Ruby +# applications. + +EXPOSE 8080 + +ENV RUBY_MAJOR_VERSION=3 \ + RUBY_MINOR_VERSION=1 + +ENV RUBY_VERSION="${RUBY_MAJOR_VERSION}.${RUBY_MINOR_VERSION}" \ + RUBY_SCL_NAME_VERSION="${RUBY_MAJOR_VERSION}${RUBY_MINOR_VERSION}" + +ENV RUBY_SCL="ruby-${RUBY_SCL_NAME_VERSION}" \ + IMAGE_NAME="ubi9/ruby-${RUBY_SCL_NAME_VERSION}" \ + SUMMARY="Platform for building and running Ruby $RUBY_VERSION applications" \ + DESCRIPTION="Ruby $RUBY_VERSION available as container is a base platform for \ +building and running various Ruby $RUBY_VERSION applications and frameworks. \ +Ruby is the interpreted scripting language for quick and easy object-oriented programming. \ +It has many features to process text files and to do system management tasks (as in Perl). \ +It is simple, straight-forward, and extensible." + +LABEL summary="$SUMMARY" \ + description="$DESCRIPTION" \ + io.k8s.description="$DESCRIPTION" \ + io.k8s.display-name="Ruby ${RUBY_VERSION}" \ + io.openshift.expose-services="8080:http" \ + io.openshift.tags="builder,ruby,ruby${RUBY_SCL_NAME_VERSION},${RUBY_SCL}" \ + com.redhat.component="${RUBY_SCL}-container" \ + name="${IMAGE_NAME}" \ + version="1" \ + com.redhat.license_terms="https://www.redhat.com/en/about/red-hat-end-user-license-agreements#UBI" \ + usage="s2i build https://github.com/sclorg/s2i-ruby-container.git \ +--context-dir=${RUBY_VERSION}/test/puma-test-app/ ${IMAGE_NAME} ruby-sample-app" \ + maintainer="SoftwareCollections.org " + +RUN yum -y module enable ruby:$RUBY_VERSION && \ + INSTALL_PKGS=" \ + libffi-devel \ + ruby \ + ruby-devel \ + rubygem-rake \ + rubygem-bundler \ + ruby-bundled-gems \ + redhat-rpm-config \ + " && \ + yum install -y --setopt=tsflags=nodocs ${INSTALL_PKGS} && \ + yum -y clean all --enablerepo='*' && \ + ruby -v | grep -qe "^ruby $RUBY_VERSION\." && echo "Found VERSION $RUBY_VERSION" && \ + rpm -V ${INSTALL_PKGS} + +# 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/ / + +# Drop the root user and make the content of /opt/app-root owned by user 1001 +RUN 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/3.1/README.md b/3.1/README.md new file mode 100644 index 00000000..6e8d6a50 --- /dev/null +++ b/3.1/README.md @@ -0,0 +1,229 @@ +Ruby 3.1 container image +======================== +This container image includes Ruby 3.1 as a [S2I](https://github.com/openshift/source-to-image) base image for your Ruby 3.1 applications. +Users can choose between RHEL, CentOS and Fedora based builder images. +The RHEL images are available in the [Red Hat Container Catalog](https://access.redhat.com/containers/), +the CentOS images are available on [Quay.io](https://quay.io/organization/centos7), +and the Fedora images are available in [Quay.io](https://quay.io/organization/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 +----------- + +Ruby 3.1 available as container is a base platform for +building and running various Ruby 3.1 applications and frameworks. +Ruby is the interpreted scripting language for quick and easy object-oriented programming. +It has many features to process text files and to do system management tasks (as in Perl). +It is simple, straight-forward, and extensible. + +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. + +Usage in Openshift +------------------ +For this, we will assume that you are using the `ubi8/ruby-31 image`, available via `ruby:3.1` imagestream tag in Openshift. +Building a simple [ruby-sample-app](https://github.com/sclorg/s2i-ruby-container/tree/master/3.1/test/puma-test-app) application +in Openshift can be achieved with the following step: + + ``` + oc new-app ruby:3.1~https://github.com/sclorg/rails-ex.git + ``` + +**Accessing 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/4.4/builds/build-strategies.html#images-create-s2i_build-strategies) +(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 Ruby 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 Ruby 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 configures web server and runs this server on port 8080. + +Building an application using a Dockerfile +------------------------------------------ +Compared to the Source-to-Image strategy, using a Dockerfile is a more +flexible way to build a Ruby 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 Ruby image in a Dockerfile, follow these steps: + +#### 1. Pull a base builder image to build on + +``` +podman pull ubi8/ruby-31 +``` + +An RHEL8 image `ubi8/ruby-31` is used in this example. + +#### 2. Pull and application code + + An example application available at https://github.com/sclorg/rails-ex.git is used here. Feel free to clone the repository for further experiments. + +``` +git clone https://github.com/sclorg/rails-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 use the Source-to-Image scripts inside the image ([3.1.](#31-to-use-the-source-to-image-scripts-and-build-an-image-using-a-dockerfile-create-a-dockerfile-with-this-content)), or users can either setup all manually and use commands `ruby`, `bundle` and `rackup` explicitly in the Dockerfile ([3.2.](#32-to-use-your-own-setup-create-a-dockerfile-with-this-content)) + +##### 3.1 To use the Source-to-Image scripts and build an image using a Dockerfile, create a Dockerfile with this content: +``` +FROM ubi8/ruby-31 + +# 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 + +# Set up development mode +ENV RAILS_ENV=development + +# Install the dependencies +RUN /usr/libexec/s2i/assemble + +# Set the default command for the resulting image +CMD /usr/libexec/s2i/run +``` +The s2i scripts are used to set-up and run common Ruby applications. More information about the scripts can be found in [Source-to-Image](#source-to-image-framework-and-scripts) section. +##### 3.2 To use your own setup, create a Dockerfile with this content: +``` +FROM ubi8/ruby-31 + +USER 0 +ADD app-src ./ +RUN bundle install --path ./bundle + +CMD bundle exec "rackup -P /tmp/rack.pid --host 0.0.0.0 --port 8080" +``` +#### 4. Build a new image from a Dockerfile prepared in the previous step + +``` +podman build -t ruby-app . +``` + +#### 5. Run the resulting image with final application +``` +podman run -d ruby-app +``` +Environment variables +--------------------- + +To set these environment variables, you can place them as a key value pair into a `.s2i/environment` +file inside your source code repository. + +* **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, etc. + + **Note**: 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. Since this only takes place + when the application is run in the `production` environment, it should only be used 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](https://github.com/puma/puma)'s thread pool. + +* **PUMA_WORKERS** + + This variable indicate the number of worker processes that will be launched. See documentation on Puma's [clustered mode](https://github.com/puma/puma#clustered-mode). + +* **RUBYGEM_MIRROR** + + Set this variable to use a custom RubyGems mirror URL to download required gem packages during build process. + +Hot deploy +---------- +In order to dynamically pick up changes made in your application source code, you need to make following steps: + +* **For Ruby on Rails applications** + + Run the built Rails image with the `RAILS_ENV=development` environment variable passed to the [podman](https://github.com/containers/libpod) `-e` run flag: + ``` + $ podman run -e RAILS_ENV=development -p 8080:8080 rails-app + ``` +* **For other types of Ruby applications (Sinatra, Padrino, etc.)** + + Your application needs to be built with one of gems that reloads the server every time changes in source code are done inside the running container. Those gems are: + * [Shotgun](https://github.com/rtomayko/shotgun) + * [Rerun](https://github.com/alexch/rerun) + * [Rack-livereload](https://github.com/johnbintz/rack-livereload) + + Please note that in order to be able to run your application in development mode, you need to modify the [S2I run script](https://github.com/openshift/source-to-image#anatomy-of-a-builder-image), so the web server is launched by the chosen gem, which checks for changes in the source code. + + After you built your application image with your version of [S2I run script](https://github.com/openshift/source-to-image#anatomy-of-a-builder-image), run the image with the RACK_ENV=development environment variable passed to the [podman](https://github.com/containers/libpod) -e run flag: + ``` + $ podman run -e RACK_ENV=development -p 8080:8080 sinatra-app + ``` + +To change your source code in running container, use Podman's [exec](https://github.com/containers/libpod) command: +``` +$ podman exec -it /bin/bash +``` + +After you [podman exec](https://github.com/containers/libpod) into the running container, your current +directory is set to `/opt/app-root/src`, where the source code is located. + +Performance tuning +------------------ +You can tune the number of threads per worker using the +`PUMA_MIN_THREADS` and `PUMA_MAX_THREADS` environment variables. +Additionally, the number of worker processes is determined by the number of CPU +cores that the container has available, as recommended by +[Puma](https://github.com/puma/puma)'s documentation. This is determined using +the cgroup [cpusets](https://www.kernel.org/doc/Documentation/cgroup-v1/cpusets.txt) +subsystem. You can specify the cores that the container is allowed to use by passing +the `--cpuset-cpus` parameter to the [podman](https://github.com/containers/libpod) run command: +``` +$ podman run -e PUMA_MAX_THREADS=32 --cpuset-cpus='0-2,3,5' -p 8080:8080 sinatra-app +``` +The number of workers is also limited by the memory limit that is enforced using +cgroups. The builder image assumes that you will need 50 MiB as a base and +another 15 MiB for every worker process plus 128 KiB for each thread. Note that +each worker has its own threads, so the total memory required for the whole +container is computed using the following formula: + +``` +50 + 15 * WORKERS + 0.125 * WORKERS * PUMA_MAX_THREADS +``` +You can specify a memory limit using the `--memory` flag: +``` +$ podman run -e PUMA_MAX_THREADS=32 --memory=300m -p 8080:8080 sinatra-app +``` +If memory is more limiting then the number of available cores, the number of +workers is scaled down accordingly to fit the above formula. The number of +workers can also be set explicitly by setting `PUMA_WORKERS`. + + +See also +-------- +Dockerfile and other sources are available on https://github.com/sclorg/s2i-ruby-container. +In that repository you also can find another versions of Ruby environment Dockerfiles. +Dockerfile for CentOS is called `Dockerfile`, Dockerfile for RHEL7 is called `Dockerfile.rhel7`, +for RHEL8 it's `Dockerfile.rhel8`, for RHEL9 it's `Dockerfile.rhel9` and the Fedora Dockerfile is called Dockerfile.fedora. diff --git a/3.1/root/opt/app-root/.gemrc b/3.1/root/opt/app-root/.gemrc new file mode 100644 index 00000000..2422bea3 --- /dev/null +++ b/3.1/root/opt/app-root/.gemrc @@ -0,0 +1,9 @@ +--- +install: --no-document +update: --no-document +:benchmark: false +:update_sources: true +:bulk_threshold: 1000 +:backtrace: true +:sources: +- https://rubygems.org/ diff --git a/3.1/root/opt/app-root/etc/puma.cfg b/3.1/root/opt/app-root/etc/puma.cfg new file mode 100644 index 00000000..a52d26dc --- /dev/null +++ b/3.1/root/opt/app-root/etc/puma.cfg @@ -0,0 +1,50 @@ +def get_max_memory() + return ENV['MEMORY_LIMIT_IN_BYTES'].to_i if ENV.has_key? 'MEMORY_LIMIT_IN_BYTES' + + # Assume unlimited memory. 0.size is the number of bytes a Ruby + # Fixnum class can hold. One bit is used for sign and one is used + # by Ruby to determine whether it's a number or pointer to an object. + # That's why we subtract two bits. This expresion should therefore be + # the largest signed Fixnum possible. + (2 ** (8*0.size - 2) - 1) +end + +def get_memory_per_worker() + bytes = ENV.fetch('MEMORY_BYTES_PER_WORKER', '0').to_i + if bytes == 0 + # Comment describing rationale for choosing default of 256MiB/worker is below. + bytes = 256 * (2**20) + end + bytes +end + +def get_min_threads() + ENV.fetch('PUMA_MIN_THREADS', '0').to_i +end + +def get_max_threads() + ENV.fetch('PUMA_MAX_THREADS', '16').to_i +end + +# Determine the maximum number of workers that are allowed by the available +# memory. Puma documentation recommends the maximum number of workers to be +# set to the number of cores. +# Unless we're specifically tuned otherwise, allow one worker process per 256MiB +# memory, to a maximum of 1 worker / core. Hopefully that'll be a reasonable +# starting point for average apps; if not, it's all tunable. The simple +# OpenShift ruby/rails sample app currently requires approx. 60MiB + +# 70MiB/worker before taking its first request, so hopefully a default of +# 256MiB/worker will give other simple apps reasonable default headroom. +def get_workers() + return ENV['PUMA_WORKERS'].to_i if ENV.has_key? 'PUMA_WORKERS' + + cores = ENV.fetch('NUMBER_OF_CORES', '1').to_i + max_workers = get_max_memory() / get_memory_per_worker() + + [cores, max_workers].min +end + +environment ENV['RACK_ENV'] || ENV['RAILS_ENV'] || 'production' +threads get_min_threads(), get_max_threads() +workers get_workers() +bind 'tcp://0.0.0.0:8080' diff --git a/3.1/s2i/bin/assemble b/3.1/s2i/bin/assemble new file mode 100755 index 00000000..5c9d32d4 --- /dev/null +++ b/3.1/s2i/bin/assemble @@ -0,0 +1,68 @@ +#!/bin/bash + +function rake_assets_precompile() { + [[ "$DISABLE_ASSET_COMPILATION" == "true" ]] && return + [ ! -f Gemfile ] && return + [ ! -f Rakefile ] && return + ! grep " rake " Gemfile.lock >/dev/null && return + ! bundle exec 'rake -T' | grep "assets:precompile" >/dev/null && return + + echo "---> Starting asset compilation ..." + bundle exec "rake assets:precompile" +} + +set -e + +export RACK_ENV=${RACK_ENV:-"production"} + +if [ -n "$RUBYGEM_MIRROR" ]; then + bundle config mirror.https://rubygems.org $RUBYGEM_MIRROR +fi + +shopt -s dotglob +echo "---> Installing application source ..." +mv /tmp/src/* ./ + +# Change the npm registry mirror if provided +if [ -n "$NPM_MIRROR" ]; then + npm config set registry $NPM_MIRROR +fi + +echo "---> Building your Ruby application from source ..." +if [ -f Gemfile ]; then + ADDTL_BUNDLE_ARGS="--retry 2" + if [ -f Gemfile.lock ]; then + bundle config set --local deployment "true" + fi + + if [[ "$RAILS_ENV" == "development" || "$RACK_ENV" == "development" ]]; then + BUNDLE_WITHOUT=${BUNDLE_WITHOUT:-"test"} + elif [[ "$RAILS_ENV" == "test" || "$RACK_ENV" == "test" ]]; then + BUNDLE_WITHOUT=${BUNDLE_WITHOUT:-"development"} + else + BUNDLE_WITHOUT=${BUNDLE_WITHOUT:-"development:test"} + fi + + if [ -n "$BUNDLE_WITHOUT" ]; then + bundle config set --local without "$BUNDLE_WITHOUT" + fi + + echo "---> Running 'bundle install ${ADDTL_BUNDLE_ARGS}' ..." + bundle config set --local path "./bundle" + bundle install ${ADDTL_BUNDLE_ARGS} + + echo "---> Cleaning up unused ruby gems ..." + bundle clean --verbose +fi + +if ! bundle exec rackup -h &>/dev/null; then + echo "WARNING: Rubygem Rack is not installed in the present image." + echo " Add rack to your Gemfile in order to start the web server." +fi + +if [[ "$RAILS_ENV" == "production" || "$RACK_ENV" == "production" ]]; then + rake_assets_precompile +fi + +# Fix source directory permissions +fix-permissions ./ diff --git a/3.1/s2i/bin/run b/3.1/s2i/bin/run new file mode 100755 index 00000000..1614ec3b --- /dev/null +++ b/3.1/s2i/bin/run @@ -0,0 +1,39 @@ +#!/bin/bash + +function is_puma_installed() { + [ ! -f Gemfile.lock ] && return 1 + grep ' puma ' Gemfile.lock >/dev/null +} + +set -e + +function check_number() { + if [[ ! "$2" =~ ^[0-9]+$ ]]; then + echo "$1 needs to be a non-negative number" + exit 1 + fi +} +check_number PUMA_WORKERS "${PUMA_WORKERS:-0}" +check_number PUMA_MIN_THREADS "${PUMA_MIN_THREADS:-0}" +check_number PUMA_MAX_THREADS "${PUMA_MAX_THREADS:-0}" + +export RACK_ENV=${RACK_ENV:-"production"} + +if is_puma_installed; then + export_vars=$(cgroup-limits) ; export $export_vars + + exec bundle exec "puma --config ../etc/puma.cfg" +else + echo "You might consider adding 'puma' into your Gemfile." + + if bundle exec rackup -h &>/dev/null; then + if [ -f Gemfile ]; then + exec bundle exec "rackup -E ${RAILS_ENV:-$RACK_ENV} -P /tmp/rack.pid --host 0.0.0.0 --port 8080" + else + exec rackup -E "${RAILS_ENV:-$RACK_ENV}" -P /tmp/rack.pid --host 0.0.0.0 --port 8080 + fi + else + echo "ERROR: Rubygem Rack is not installed in the present image." + echo " Add rack to your Gemfile in order to start the web server." + fi +fi diff --git a/3.1/s2i/bin/usage b/3.1/s2i/bin/usage new file mode 100755 index 00000000..76b9beb1 --- /dev/null +++ b/3.1/s2i/bin/usage @@ -0,0 +1,18 @@ +#!/bin/sh + +DISTRO="`grep ^ID= /etc/*-release | cut -d'"' -f2`" + +cat < -- curl 127.0.0.1:8080 + +Alternatively, to run the image directly using podman or docker, or how to use it as a parent image in a Dockerfile, see documentation at + +https://github.com/sclorg/s2i-ruby-container/blob/master/${RUBY_VERSION}/README.md +EOF diff --git a/3.1/test/examples b/3.1/test/examples new file mode 120000 index 00000000..d15735c1 --- /dev/null +++ b/3.1/test/examples @@ -0,0 +1 @@ +../../examples \ No newline at end of file diff --git a/3.1/test/imagestreams b/3.1/test/imagestreams new file mode 120000 index 00000000..7a0aee9c --- /dev/null +++ b/3.1/test/imagestreams @@ -0,0 +1 @@ +../../imagestreams \ No newline at end of file diff --git a/3.1/test/puma-test-app/Gemfile b/3.1/test/puma-test-app/Gemfile new file mode 100755 index 00000000..a98e5e1c --- /dev/null +++ b/3.1/test/puma-test-app/Gemfile @@ -0,0 +1,4 @@ +source 'https://rubygems.org' + +gem 'sinatra' +gem 'puma' diff --git a/3.1/test/puma-test-app/Gemfile.lock b/3.1/test/puma-test-app/Gemfile.lock new file mode 100644 index 00000000..052f5933 --- /dev/null +++ b/3.1/test/puma-test-app/Gemfile.lock @@ -0,0 +1,25 @@ +GEM + remote: https://rubygems.org/ + specs: + mustermann (1.1.1) + ruby2_keywords (~> 0.0.1) + nio4r (2.5.7) + puma (5.2.2) + nio4r (~> 2.0) + rack (2.2.3) + rack-protection (2.1.0) + rack + ruby2_keywords (0.0.4) + sinatra (2.1.0) + mustermann (~> 1.0) + rack (~> 2.2) + rack-protection (= 2.1.0) + tilt (~> 2.0) + tilt (2.0.10) + +PLATFORMS + ruby + +DEPENDENCIES + puma + sinatra diff --git a/3.1/test/puma-test-app/app.rb b/3.1/test/puma-test-app/app.rb new file mode 100755 index 00000000..cd7e87d7 --- /dev/null +++ b/3.1/test/puma-test-app/app.rb @@ -0,0 +1,5 @@ +require 'sinatra' + +get '/' do + 'Hello world!' +end diff --git a/3.1/test/puma-test-app/config.ru b/3.1/test/puma-test-app/config.ru new file mode 100755 index 00000000..76a6edff --- /dev/null +++ b/3.1/test/puma-test-app/config.ru @@ -0,0 +1,2 @@ +require './app' +run Sinatra::Application diff --git a/3.1/test/rack-test-app/Gemfile b/3.1/test/rack-test-app/Gemfile new file mode 100755 index 00000000..d89e792e --- /dev/null +++ b/3.1/test/rack-test-app/Gemfile @@ -0,0 +1,4 @@ +source 'https://rubygems.org' + +gem 'sinatra' +gem 'webrick' diff --git a/3.1/test/rack-test-app/Gemfile.lock b/3.1/test/rack-test-app/Gemfile.lock new file mode 100644 index 00000000..883bfb2b --- /dev/null +++ b/3.1/test/rack-test-app/Gemfile.lock @@ -0,0 +1,23 @@ +GEM + remote: https://rubygems.org/ + specs: + mustermann (1.1.1) + ruby2_keywords (~> 0.0.1) + rack (2.2.3) + rack-protection (2.1.0) + rack + ruby2_keywords (0.0.4) + sinatra (2.1.0) + mustermann (~> 1.0) + rack (~> 2.2) + rack-protection (= 2.1.0) + tilt (~> 2.0) + tilt (2.0.10) + webrick (1.7.0) + +PLATFORMS + ruby + +DEPENDENCIES + sinatra + webrick diff --git a/3.1/test/rack-test-app/app.rb b/3.1/test/rack-test-app/app.rb new file mode 100755 index 00000000..cd7e87d7 --- /dev/null +++ b/3.1/test/rack-test-app/app.rb @@ -0,0 +1,5 @@ +require 'sinatra' + +get '/' do + 'Hello world!' +end diff --git a/3.1/test/rack-test-app/config.ru b/3.1/test/rack-test-app/config.ru new file mode 100755 index 00000000..76a6edff --- /dev/null +++ b/3.1/test/rack-test-app/config.ru @@ -0,0 +1,2 @@ +require './app' +run Sinatra::Application diff --git a/3.1/test/run b/3.1/test/run new file mode 120000 index 00000000..44977d63 --- /dev/null +++ b/3.1/test/run @@ -0,0 +1 @@ +../../test/run \ No newline at end of file diff --git a/3.1/test/run-conu b/3.1/test/run-conu new file mode 120000 index 00000000..deed6574 --- /dev/null +++ b/3.1/test/run-conu @@ -0,0 +1 @@ +../../test/run-conu \ No newline at end of file diff --git a/3.1/test/run-openshift b/3.1/test/run-openshift new file mode 120000 index 00000000..ec13e4a1 --- /dev/null +++ b/3.1/test/run-openshift @@ -0,0 +1 @@ +../../test/run-openshift \ No newline at end of file diff --git a/3.1/test/run-openshift-remote-cluster b/3.1/test/run-openshift-remote-cluster new file mode 120000 index 00000000..1bffcba8 --- /dev/null +++ b/3.1/test/run-openshift-remote-cluster @@ -0,0 +1 @@ +../../test/run-openshift-remote-cluster \ No newline at end of file diff --git a/3.1/test/test-lib-openshift.sh b/3.1/test/test-lib-openshift.sh new file mode 120000 index 00000000..4f9f2996 --- /dev/null +++ b/3.1/test/test-lib-openshift.sh @@ -0,0 +1 @@ +../../common/test-lib-openshift.sh \ No newline at end of file diff --git a/3.1/test/test-lib-remote-openshift.sh b/3.1/test/test-lib-remote-openshift.sh new file mode 120000 index 00000000..92ad2f4d --- /dev/null +++ b/3.1/test/test-lib-remote-openshift.sh @@ -0,0 +1 @@ +../../common/test-lib-remote-openshift.sh \ No newline at end of file diff --git a/3.1/test/test-lib-ruby.sh b/3.1/test/test-lib-ruby.sh new file mode 120000 index 00000000..ea235094 --- /dev/null +++ b/3.1/test/test-lib-ruby.sh @@ -0,0 +1 @@ +../../test/test-lib-ruby.sh \ No newline at end of file diff --git a/3.1/test/test-lib.sh b/3.1/test/test-lib.sh new file mode 120000 index 00000000..1ac99b93 --- /dev/null +++ b/3.1/test/test-lib.sh @@ -0,0 +1 @@ +../../common/test-lib.sh \ No newline at end of file diff --git a/3.1/test/test-openshift.yaml b/3.1/test/test-openshift.yaml new file mode 120000 index 00000000..8613fbba --- /dev/null +++ b/3.1/test/test-openshift.yaml @@ -0,0 +1 @@ +../../common/test-openshift.yaml \ No newline at end of file diff --git a/3.1/test/test_s2i.py b/3.1/test/test_s2i.py new file mode 120000 index 00000000..54807341 --- /dev/null +++ b/3.1/test/test_s2i.py @@ -0,0 +1 @@ +../../test/test_s2i.py \ No newline at end of file From 0c466603ea715c13fce5c5786aedddbc37a14c17 Mon Sep 17 00:00:00 2001 From: Pavel Valena Date: Mon, 12 Feb 2024 20:47:27 +0100 Subject: [PATCH 3/4] Add Ruby 3.3: changes for Ruby 3.3 (3 step/commit workflow to preserve history) --- 3.3/.exclude-c8s | 0 3.3/.exclude-c9s | 0 3.3/Dockerfile.c8s | 66 +++++++++++++++++++++++++++++++++++++++++++ 3.3/Dockerfile.c9s | 2 +- 3.3/Dockerfile.fedora | 6 ++-- 3.3/Dockerfile.rhel8 | 2 +- 3.3/Dockerfile.rhel9 | 2 +- 3.3/README.md | 28 +++++++++--------- Makefile | 2 +- 9 files changed, 87 insertions(+), 21 deletions(-) create mode 100644 3.3/.exclude-c8s create mode 100644 3.3/.exclude-c9s create mode 100644 3.3/Dockerfile.c8s diff --git a/3.3/.exclude-c8s b/3.3/.exclude-c8s new file mode 100644 index 00000000..e69de29b diff --git a/3.3/.exclude-c9s b/3.3/.exclude-c9s new file mode 100644 index 00000000..e69de29b diff --git a/3.3/Dockerfile.c8s b/3.3/Dockerfile.c8s new file mode 100644 index 00000000..a5853b28 --- /dev/null +++ b/3.3/Dockerfile.c8s @@ -0,0 +1,66 @@ +FROM quay.io/sclorg/s2i-base-c8s:c8s + +# This image provides a Ruby environment you can use to run your Ruby +# applications. + +EXPOSE 8080 + +ENV RUBY_MAJOR_VERSION=3 \ + RUBY_MINOR_VERSION=3 + +ENV RUBY_VERSION="${RUBY_MAJOR_VERSION}.${RUBY_MINOR_VERSION}" \ + RUBY_SCL_NAME_VERSION="${RUBY_MAJOR_VERSION}${RUBY_MINOR_VERSION}" + +ENV RUBY_SCL="ruby-${RUBY_SCL_NAME_VERSION}" \ + IMAGE_NAME="ubi8/ruby-${RUBY_SCL_NAME_VERSION}" \ + SUMMARY="Platform for building and running Ruby $RUBY_VERSION applications" \ + DESCRIPTION="Ruby $RUBY_VERSION available as container is a base platform for \ +building and running various Ruby $RUBY_VERSION applications and frameworks. \ +Ruby is the interpreted scripting language for quick and easy object-oriented programming. \ +It has many features to process text files and to do system management tasks (as in Perl). \ +It is simple, straight-forward, and extensible." + +LABEL summary="$SUMMARY" \ + description="$DESCRIPTION" \ + io.k8s.description="$DESCRIPTION" \ + io.k8s.display-name="Ruby ${RUBY_VERSION}" \ + io.openshift.expose-services="8080:http" \ + io.openshift.tags="builder,ruby,ruby${RUBY_SCL_NAME_VERSION},${RUBY_SCL}" \ + com.redhat.component="${RUBY_SCL}-container" \ + name="${IMAGE_NAME}" \ + version="1" \ + com.redhat.license_terms="https://www.redhat.com/en/about/red-hat-end-user-license-agreements#UBI" \ + usage="s2i build https://github.com/sclorg/s2i-ruby-container.git \ +--context-dir=${RUBY_VERSION}/test/puma-test-app/ ${IMAGE_NAME} ruby-sample-app" \ + maintainer="SoftwareCollections.org " + +RUN yum -y module enable ruby:$RUBY_VERSION && \ + INSTALL_PKGS=" \ + libffi-devel \ + ruby \ + ruby-devel \ + rubygem-rake \ + rubygem-bundler \ + ruby-bundled-gems \ + redhat-rpm-config \ + " && \ + yum install -y --setopt=tsflags=nodocs ${INSTALL_PKGS} && \ + yum reinstall -y --setopt=tsflags=nodocs tzdata && \ + yum -y clean all --enablerepo='*' && \ + ruby -v | grep -qe "^ruby $RUBY_VERSION\." && echo "Found VERSION $RUBY_VERSION" && \ + rpm -V ${INSTALL_PKGS} + +# 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/ / + +# Drop the root user and make the content of /opt/app-root owned by user 1001 +RUN 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/3.3/Dockerfile.c9s b/3.3/Dockerfile.c9s index 0a81b662..6ba4aa51 100644 --- a/3.3/Dockerfile.c9s +++ b/3.3/Dockerfile.c9s @@ -6,7 +6,7 @@ FROM quay.io/sclorg/s2i-base-c9s:c9s EXPOSE 8080 ENV RUBY_MAJOR_VERSION=3 \ - RUBY_MINOR_VERSION=1 + RUBY_MINOR_VERSION=3 ENV RUBY_VERSION="${RUBY_MAJOR_VERSION}.${RUBY_MINOR_VERSION}" \ RUBY_SCL_NAME_VERSION="${RUBY_MAJOR_VERSION}${RUBY_MINOR_VERSION}" diff --git a/3.3/Dockerfile.fedora b/3.3/Dockerfile.fedora index 6823e01d..1369c559 100644 --- a/3.3/Dockerfile.fedora +++ b/3.3/Dockerfile.fedora @@ -1,4 +1,4 @@ -FROM quay.io/fedora/s2i-base:37 +FROM quay.io/fedora/s2i-base:40 # This image provides a Ruby environment you can use to run your Ruby # applications. @@ -6,8 +6,8 @@ FROM quay.io/fedora/s2i-base:37 EXPOSE 8080 ENV NAME=ruby \ - RUBY_VERSION=3.1 \ - RUBY_SHORT_VER=31 \ + RUBY_VERSION=3.3 \ + RUBY_SHORT_VER=33 \ VERSION=0 ENV SUMMARY="Platform for building and running Ruby $RUBY_VERSION applications" \ diff --git a/3.3/Dockerfile.rhel8 b/3.3/Dockerfile.rhel8 index b650d92a..930bf782 100644 --- a/3.3/Dockerfile.rhel8 +++ b/3.3/Dockerfile.rhel8 @@ -6,7 +6,7 @@ FROM ubi8/s2i-base EXPOSE 8080 ENV RUBY_MAJOR_VERSION=3 \ - RUBY_MINOR_VERSION=1 + RUBY_MINOR_VERSION=3 ENV RUBY_VERSION="${RUBY_MAJOR_VERSION}.${RUBY_MINOR_VERSION}" \ RUBY_SCL_NAME_VERSION="${RUBY_MAJOR_VERSION}${RUBY_MINOR_VERSION}" diff --git a/3.3/Dockerfile.rhel9 b/3.3/Dockerfile.rhel9 index 969fe2a5..08c51850 100644 --- a/3.3/Dockerfile.rhel9 +++ b/3.3/Dockerfile.rhel9 @@ -6,7 +6,7 @@ FROM ubi9/s2i-base EXPOSE 8080 ENV RUBY_MAJOR_VERSION=3 \ - RUBY_MINOR_VERSION=1 + RUBY_MINOR_VERSION=3 ENV RUBY_VERSION="${RUBY_MAJOR_VERSION}.${RUBY_MINOR_VERSION}" \ RUBY_SCL_NAME_VERSION="${RUBY_MAJOR_VERSION}${RUBY_MINOR_VERSION}" diff --git a/3.3/README.md b/3.3/README.md index 6e8d6a50..a7a0e370 100644 --- a/3.3/README.md +++ b/3.3/README.md @@ -1,6 +1,6 @@ -Ruby 3.1 container image +Ruby 3.3 container image ======================== -This container image includes Ruby 3.1 as a [S2I](https://github.com/openshift/source-to-image) base image for your Ruby 3.1 applications. +This container image includes Ruby 3.3 as a [S2I](https://github.com/openshift/source-to-image) base image for your Ruby 3.3 applications. Users can choose between RHEL, CentOS and Fedora based builder images. The RHEL images are available in the [Red Hat Container Catalog](https://access.redhat.com/containers/), the CentOS images are available on [Quay.io](https://quay.io/organization/centos7), @@ -12,8 +12,8 @@ Note: while the examples in this README are calling `podman`, you can replace an Description ----------- -Ruby 3.1 available as container is a base platform for -building and running various Ruby 3.1 applications and frameworks. +Ruby 3.3 available as container is a base platform for +building and running various Ruby 3.3 applications and frameworks. Ruby is the interpreted scripting language for quick and easy object-oriented programming. It has many features to process text files and to do system management tasks (as in Perl). It is simple, straight-forward, and extensible. @@ -25,12 +25,12 @@ the nodejs itself is included just to make the npm work. Usage in Openshift ------------------ -For this, we will assume that you are using the `ubi8/ruby-31 image`, available via `ruby:3.1` imagestream tag in Openshift. -Building a simple [ruby-sample-app](https://github.com/sclorg/s2i-ruby-container/tree/master/3.1/test/puma-test-app) application +For this, we will assume that you are using the `ubi8/ruby-33 image`, available via `ruby:3.3` imagestream tag in Openshift. +Building a simple [ruby-sample-app](https://github.com/sclorg/s2i-ruby-container/tree/master/3.3/test/puma-test-app) application in Openshift can be achieved with the following step: ``` - oc new-app ruby:3.1~https://github.com/sclorg/rails-ex.git + oc new-app ruby:3.3~https://github.com/sclorg/rails-ex.git ``` **Accessing the application:** @@ -64,10 +64,10 @@ To use the Ruby image in a Dockerfile, follow these steps: #### 1. Pull a base builder image to build on ``` -podman pull ubi8/ruby-31 +podman pull ubi8/ruby-33 ``` -An RHEL8 image `ubi8/ruby-31` is used in this example. +An RHEL8 image `ubi8/ruby-33` is used in this example. #### 2. Pull and application code @@ -85,11 +85,11 @@ This step usually consists of at least these parts: * installing the dependencies * setting the default command in the resulting image -For all these three parts, users can use the Source-to-Image scripts inside the image ([3.1.](#31-to-use-the-source-to-image-scripts-and-build-an-image-using-a-dockerfile-create-a-dockerfile-with-this-content)), or users can either setup all manually and use commands `ruby`, `bundle` and `rackup` explicitly in the Dockerfile ([3.2.](#32-to-use-your-own-setup-create-a-dockerfile-with-this-content)) +For all these three parts, users can use the Source-to-Image scripts inside the image ([3.3.](#33-to-use-the-source-to-image-scripts-and-build-an-image-using-a-dockerfile-create-a-dockerfile-with-this-content)), or users can either setup all manually and use commands `ruby`, `bundle` and `rackup` explicitly in the Dockerfile ([3.3.](#33-to-use-your-own-setup-create-a-dockerfile-with-this-content)) -##### 3.1 To use the Source-to-Image scripts and build an image using a Dockerfile, create a Dockerfile with this content: +##### 3.3 To use the Source-to-Image scripts and build an image using a Dockerfile, create a Dockerfile with this content: ``` -FROM ubi8/ruby-31 +FROM ubi8/ruby-33 # Add application sources to a directory that the assemble scriptexpects them # and set permissions so that the container runs without root access @@ -108,9 +108,9 @@ RUN /usr/libexec/s2i/assemble CMD /usr/libexec/s2i/run ``` The s2i scripts are used to set-up and run common Ruby applications. More information about the scripts can be found in [Source-to-Image](#source-to-image-framework-and-scripts) section. -##### 3.2 To use your own setup, create a Dockerfile with this content: +##### 3.3 To use your own setup, create a Dockerfile with this content: ``` -FROM ubi8/ruby-31 +FROM ubi8/ruby-33 USER 0 ADD app-src ./ diff --git a/Makefile b/Makefile index afd2c1b2..4076f290 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ # Variables are documented in common/build.sh. BASE_IMAGE_NAME = ruby -VERSIONS = 2.5 3.0 3.1 +VERSIONS = 2.5 3.0 3.1 3.3 OPENSHIFT_NAMESPACES = 2.0 CONU_IMAGE := docker.io/usercont/conu:0.6.2 From 8aaba1009882ee9c70333e663c0832484744e773 Mon Sep 17 00:00:00 2001 From: "Petr \"Stone\" Hracek" Date: Mon, 13 May 2024 11:59:51 +0200 Subject: [PATCH 4/4] Check proper version. VERSION is defined RUBY_VERSION not Signed-off-by: Petr "Stone" Hracek --- test/run | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/run b/test/run index de313dbb..f77ccc75 100755 --- a/test/run +++ b/test/run @@ -118,7 +118,7 @@ scl_usage() { } function test_scl_usage() { - scl_usage "ruby --version" "ruby ${RUBY_VERSION}." + scl_usage "ruby --version" "ruby ${VERSION}." ct_check_testcase_result "$?" }