Skip to content

Building and testing container on RHEL10 host #475

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 98 additions & 0 deletions 8.3/Dockerfile.rhel10
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
FROM ubi10/s2i-base

# This image provides an Apache+PHP environment for running PHP
# applications.

EXPOSE 8080
EXPOSE 8443

# Description
# This image provides an Apache 2.4 + PHP 8.3 environment for running PHP applications.
# Exposed ports:
# * 8080 - alternative port for http

ENV PHP_VERSION=8.3 \
PHP_VER_SHORT=83 \
NAME=php

ENV SUMMARY="Platform for building and running PHP $PHP_VERSION applications" \
DESCRIPTION="PHP $PHP_VERSION available as container is a base platform for \
building and running various PHP $PHP_VERSION applications and frameworks. \
PHP is an HTML-embedded scripting language. PHP attempts to make it easy for developers \
to write dynamically generated web pages. PHP also offers built-in database integration \
for several commercial and non-commercial database management systems, so writing \
a database-enabled webpage with PHP is fairly simple. The most common use of PHP coding \
is probably as a replacement for CGI scripts."

LABEL summary="${SUMMARY}" \
description="${DESCRIPTION}" \
io.k8s.description="${DESCRIPTION}" \
io.k8s.display-name="Apache 2.4 with PHP ${PHP_VERSION}" \
io.openshift.expose-services="8080:http" \
io.openshift.tags="builder,${NAME},${NAME}${PHP_VER_SHORT},${NAME}-${PHP_VER_SHORT}" \
io.openshift.s2i.scripts-url="image:///usr/libexec/s2i" \
io.s2i.scripts-url="image:///usr/libexec/s2i" \
name="ubi10/${NAME}-${PHP_VER_SHORT}" \
com.redhat.component="${NAME}-${PHP_VER_SHORT}-container" \
version="1" \
com.redhat.license_terms="https://www.redhat.com/en/about/red-hat-end-user-license-agreements#UBI" \
help="For more information visit https://github.com/sclorg/s2i-${NAME}-container" \
usage="s2i build https://github.com/sclorg/s2i-php-container.git --context-dir=${PHP_VERSION}/test/test-app ubi10/${NAME}-${PHP_VER_SHORT} sample-server" \
maintainer="SoftwareCollections.org <[email protected]>"

# Install Apache httpd and PHP
ARG INSTALL_PKGS="php php-fpm mod_ssl hostname"
ARG INSTALL_EXTS="php-json php-mysqli php-pgsql php-bcmath \
php-gd php-intl php-ldap php-mbstring php-pdo \
php-process php-soap php-opcache php-xml \
php-gmp php-apcu php-zip php-redis"

# This needs to be added for downloading packages
RUN curl -fL -o /etc/pki/ca-trust/source/anchors/2022-IT-Root-CA.pem https://certs.corp.redhat.com/certs/2022-IT-Root-CA.pem
RUN update-ca-trust extract

RUN dnf install -y --setopt=tsflags=nodocs $INSTALL_PKGS $INSTALL_EXTS && \
dnf reinstall -y tzdata && \
rpm -V $INSTALL_PKGS && \
php -v | grep -qe "v$PHP_VERSION\." && \
echo "Found VERSION $PHP_VERSION" && \
for ext in $(echo $INSTALL_EXTS | sed s/php-//g) ; do php -m | grep -qi "$ext\$"; done && \
echo "Found requested extensions" && \
dnf -y clean all --enablerepo='*'

# Remove the certs
RUN rm /etc/pki/ca-trust/source/anchors/2022-IT-Root-CA.pem
RUN update-ca-trust

ENV PHP_CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/php/ \
APP_DATA=${APP_ROOT}/src \
PHP_DEFAULT_INCLUDE_PATH=/usr/share/pear \
PHP_SYSCONF_PATH=/etc \
PHP_HTTPD_CONF_FILE=php.conf \
PHP_FPM_CONF_D_PATH=/etc/php-fpm.d \
PHP_FPM_CONF_FILE=www.conf \
PHP_FPM_RUN_DIR=/run/php-fpm \
PHP_MAIN_FPM_CONF_FILE=/etc/php-fpm.conf \
PHP_FPM_LOG_PATH=/var/log/php-fpm \
HTTPD_CONFIGURATION_PATH=${APP_ROOT}/etc/conf.d \
HTTPD_MAIN_CONF_PATH=/etc/httpd/conf \
HTTPD_MAIN_CONF_D_PATH=/etc/httpd/conf.d \
HTTPD_MODULES_CONF_D_PATH=/etc/httpd/conf.modules.d \
HTTPD_VAR_RUN=/var/run/httpd \
HTTPD_DATA_PATH=/var/www \
HTTPD_DATA_ORIG_PATH=/var/www \
HTTPD_VAR_PATH=/var

# 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/ /

# Reset permissions of filesystem to default values
RUN /usr/libexec/container-setup && rpm-file-permissions

USER 1001

# Set the default CMD to print the usage of the language image
CMD $STI_SCRIPTS_PATH/usage
1 change: 1 addition & 0 deletions 8.3/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ See also
Dockerfile and other sources are available on https://github.com/sclorg/s2i-php-container.
In that repository you also can find another versions of Python environment Dockerfiles.
Dockerfile for RHEL8 is called `Dockerfile.rhel8`, Dockerfile for RHEL9 is called `Dockerfile.rhel9`,
Dockerfile for RHEL9 is called `Dockerfile.rhel10`,
Dockerfile for CentOS Stream 10 is called `Dockerfile.c10s`,and the Fedora Dockerfile is called Dockerfile.fedora.

Security Implications
Expand Down
20 changes: 7 additions & 13 deletions 8.3/root/usr/libexec/container-setup
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,14 @@ else
rm -f /opt/app-root/etc/scl_enable
fi

if head "/etc/redhat-release" | grep -q -e "^Red Hat Enterprise Linux release 8" -e "^Red Hat Enterprise Linux release 9" -e "Fedora" -e "^CentOS Stream release 9" -e "^CentOS Stream release 10"; then
/usr/libexec/httpd-ssl-gencerts
fi
/usr/libexec/httpd-ssl-gencerts

mkdir -p ${HTTPD_CONFIGURATION_PATH}
chmod -R a+rwx ${HTTPD_MAIN_CONF_PATH}
chmod -R a+rwx ${HTTPD_MAIN_CONF_D_PATH}
chmod -R ug+r /etc/pki/tls/certs/localhost.crt
chmod -R ug+r /etc/pki/tls/private/localhost.key
chown -R 1001:0 /etc/pki/tls/certs/localhost.crt
chmod -R ug+r /etc/pki/tls/private/localhost.key
chown -R 1001:0 /etc/pki/tls/private/localhost.key
mkdir -p ${APP_ROOT}/etc
chmod -R a+rwx ${APP_ROOT}/etc
Expand All @@ -45,16 +43,12 @@ mkdir -p /tmp/sessions
chmod -R a+rwx /tmp/sessions
chown -R 1001:0 /tmp/sessions
chown -R 1001:0 ${HTTPD_DATA_PATH}
if [ "$PLATFORM" == "el7" ]; then
# Only run for el7 as this essentially becomes "chmod -R /etc" outside of SCL-based images
chmod -R a+rwx "${PHP_SYSCONF_PATH}"
else
chmod a+rwx "${PHP_SYSCONF_PATH}/php.ini"
chmod -R a+rwx "${PHP_SYSCONF_PATH}/php.d"
chmod -R a+rwx "${PHP_SYSCONF_PATH}/php-fpm.d"
fi

if [ "x$PLATFORM" == "xel9" ] || [ "x$PLATFORM" == "xel10" ] || [ "x$PLATFORM" == "xfedora" ]; then
chmod a+rwx "${PHP_SYSCONF_PATH}/php.ini"
chmod -R a+rwx "${PHP_SYSCONF_PATH}/php.d"
chmod -R a+rwx "${PHP_SYSCONF_PATH}/php-fpm.d"

if [ "x$PLATFORM" == "xel10" ] || [ "x$PLATFORM" == "xel9" ] || [ "x$PLATFORM" == "xfedora" ]; then
if [ -v PHP_FPM_RUN_DIR ]; then
mkdir -p ${PHP_FPM_RUN_DIR}
chmod -R a+rwx ${PHP_FPM_RUN_DIR}
Expand Down
2 changes: 1 addition & 1 deletion 8.3/s2i/bin/run
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ fi



if [ "x$PLATFORM" == "xel9" ] || [ "x$PLATFORM" == "xfedora" ]; then
if [ "x$PLATFORM" == "xel10" ] || [ "x$PLATFORM" == "xel9" ] || [ "x$PLATFORM" == "xfedora" ]; then
if [ -n "${PHP_FPM_RUN_DIR:-}" ]; then
/bin/ln -s /dev/stderr ${PHP_FPM_LOG_PATH}/error.log
mkdir -p ${PHP_FPM_RUN_DIR}
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ PHP versions currently supported are:
RHEL versions currently supported are:
* RHEL8
* RHEL9
* RHEL10

CenOS Stream versions currently supported are:
* CentOS Stream 9
Expand Down
2 changes: 1 addition & 1 deletion test/run
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ test_application() {
test_config_writeable
ct_check_testcase_result $?

if [ "${OS}" == "rhel9" ] && [ "${PHP_CLEAR_ENV:-ON}" == "OFF" ]; then
if [ "${OS}" == "rhel9" ] || [ "${OS}" == "rhel10" ] && [ "${PHP_CLEAR_ENV:-ON}" == "OFF" ]; then
test_clear_env_setup
ct_check_testcase_result $?
fi
Expand Down