Skip to content
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

Support c10s in httpd-container #224

Merged
merged 5 commits into from
Aug 13, 2024
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
82 changes: 82 additions & 0 deletions 2.4-micro/Dockerfile.c10s
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
FROM quay.io/centos/centos:stream10-development AS build

RUN mkdir -p /mnt/rootfs
RUN MICRO_PKGS="coreutils-single glibc-minimal-langpack" && \
INSTALL_PKGS="$MICRO_PKGS httpd-core mod_ssl findutils hostname nss_wrapper-libs redhat-logos-httpd" && \
dnf install --installroot /mnt/rootfs $INSTALL_PKGS --releasever 9 --setopt install_weak_deps=false --nodocs -y && \
dnf -y --installroot /mnt/rootfs clean all && \
rm -rf /mnt/rootfs/var/cache/* /mnt/rootfs/var/log/dnf* /mnt/rootfs/var/log/yum.*

FROM scratch
# Apache HTTP Server image.
#
# Volumes:
# * /var/www - Datastore for httpd
# * /var/log/httpd24 - Storage for logs when $HTTPD_LOG_TO_VOLUME is set
# Environment:
# * $HTTPD_LOG_TO_VOLUME (optional) - When set, httpd will log into /var/log/httpd24

ENV HTTPD_VERSION=2.4 \
HTTPD_SHORT_VERSION=24 \
NAME=httpd

ENV SUMMARY="Platform for running Apache httpd $HTTPD_VERSION or building httpd-based application" \
DESCRIPTION="Apache httpd $HTTPD_VERSION available as container, is a powerful, efficient, \
and extensible web server. Apache supports a variety of features, many implemented as compiled modules \
which extend the core functionality. \
These can range from server-side programming language support to authentication schemes. \
Virtual hosting allows one Apache installation to serve many different Web sites." \
# The following variables are usually available from parent s2i images \
STI_SCRIPTS_PATH=/usr/libexec/s2i \
APP_ROOT=/opt/app-root \
HOME=/opt/app-root/src \
PLATFORM="el10"

LABEL summary="$SUMMARY" \
description="$DESCRIPTION" \
io.k8s.description="$DESCRIPTION" \
io.k8s.display-name="Apache httpd $HTTPD_VERSION" \
io.openshift.expose-services="8080:http,8443:https" \
io.openshift.tags="builder,httpd,httpd-$HTTPD_SHORT_VERSION" \
name="sclorg/$NAME-$HTTPD_SHORT_VERSION-micro-c10s" \
version="1" \
usage="s2i build https://github.com/sclorg/httpd-container.git --context-dir=examples/sample-test-app/ sclorg/$NAME-$HTTPD_SHORT_VERSION-micro-c10s sample-server" \
maintainer="SoftwareCollections.org <[email protected]>"

EXPOSE 8080
EXPOSE 8443

COPY --from=build /mnt/rootfs/ /

ENV HTTPD_CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/httpd/ \
HTTPD_APP_ROOT=${APP_ROOT} \
HTTPD_CONFIGURATION_PATH=${APP_ROOT}/etc/httpd.d \
HTTPD_MAIN_CONF_PATH=/etc/httpd/conf \
HTTPD_MAIN_CONF_MODULES_D_PATH=/etc/httpd/conf.modules.d \
HTTPD_MAIN_CONF_D_PATH=/etc/httpd/conf.d \
HTTPD_TLS_CERT_PATH=/etc/httpd/tls \
HTTPD_VAR_RUN=/var/run/httpd \
HTTPD_DATA_PATH=/var/www \
HTTPD_DATA_ORIG_PATH=/var/www \
HTTPD_LOG_PATH=/var/log/httpd

COPY 2.4-micro/s2i/bin/ $STI_SCRIPTS_PATH
COPY 2.4-micro/root /
COPY 2.4-micro/core-scripts/usr /usr

WORKDIR ${HOME}

# Add default user and prepare httpd
RUN useradd -u 1001 -r -g 0 -d ${HOME} -c "Default Application User" default && \
chown -R 1001:0 ${APP_ROOT} && \
httpd -v | grep -qe "Apache/$HTTPD_VERSION" && echo "Found VERSION $HTTPD_VERSION" && \
/usr/libexec/httpd-prepare

USER 1001

# Not using VOLUME statement since it's not working in OpenShift Online:
# https://github.com/sclorg/httpd-container/issues/30
# VOLUME ["${HTTPD_DATA_PATH}"]
# VOLUME ["${HTTPD_LOG_PATH}"]

CMD ["/usr/bin/run-httpd"]
1 change: 1 addition & 0 deletions 2.4-micro/root/usr/share/container-scripts/httpd/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -246,4 +246,5 @@ See also
Dockerfile and other sources for this container image are available on
https://github.com/sclorg/httpd-container.
In that repository, the Dockerfile for RHEL8 is called Dockerfile.rhel8,
the Dockerfile for CentOS Stream 10 is called Dockerfile.c10s,
and the Dockerfile for Fedora is called Dockerfile.fedora.
70 changes: 70 additions & 0 deletions 2.4/Dockerfile.c10s
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
FROM quay.io/sclorg/s2i-core-c10s:c10s

# Apache HTTP Server image.
#
# Volumes:
# * /var/www - Datastore for httpd
# * /var/log/httpd24 - Storage for logs when $HTTPD_LOG_TO_VOLUME is set
# Environment:
# * $HTTPD_LOG_TO_VOLUME (optional) - When set, httpd will log into /var/log/httpd24

ENV HTTPD_VERSION=2.4 \
HTTPD_SHORT_VERSION=24 \
NAME=httpd \
ARCH=x86_64

ENV SUMMARY="Platform for running Apache httpd $HTTPD_VERSION or building httpd-based application" \
DESCRIPTION="Apache httpd $HTTPD_VERSION available as container, is a powerful, efficient, \
and extensible web server. Apache supports a variety of features, many implemented as compiled modules \
which extend the core functionality. \
These can range from server-side programming language support to authentication schemes. \
Virtual hosting allows one Apache installation to serve many different Web sites."

LABEL summary="$SUMMARY" \
description="$DESCRIPTION" \
io.k8s.description="$DESCRIPTION" \
io.k8s.display-name="Apache httpd $HTTPD_VERSION" \
io.openshift.expose-services="8080:http,8443:https" \
io.openshift.tags="builder,$NAME,$NAME-$HTTPD_SHORT_VERSION" \
name="sclorg/$NAME-$HTTPD_SHORT_VERSION-c10s" \
version="1" \
com.redhat.license_terms="https://www.redhat.com/en/about/red-hat-end-user-license-agreements#rhel" \
com.redhat.component="httpd-24-container" \
usage="s2i build https://github.com/sclorg/httpd-container.git --context-dir=examples/sample-test-app/ quay.io/sclorg/$NAME-$HTTPD_SHORT_VERSION-c10s sample-server" \
maintainer="SoftwareCollections.org <[email protected]>"

EXPOSE 8080
EXPOSE 8443

RUN INSTALL_PKGS="gettext hostname nss_wrapper bind-utils httpd mod_ssl mod_ldap mod_session sscg" && \
dnf install -y --setopt=tsflags=nodocs $INSTALL_PKGS && \
rpm -V $INSTALL_PKGS && \
httpd -v | grep -qe "Apache/$HTTPD_VERSION" && echo "Found VERSION $HTTPD_VERSION" && \
dnf -y clean all --enablerepo='*'

ENV HTTPD_CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/httpd/ \
HTTPD_APP_ROOT=${APP_ROOT} \
HTTPD_CONFIGURATION_PATH=${APP_ROOT}/etc/httpd.d \
HTTPD_MAIN_CONF_PATH=/etc/httpd/conf \
HTTPD_MAIN_CONF_MODULES_D_PATH=/etc/httpd/conf.modules.d \
HTTPD_MAIN_CONF_D_PATH=/etc/httpd/conf.d \
HTTPD_TLS_CERT_PATH=/etc/httpd/tls \
HTTPD_VAR_RUN=/var/run/httpd \
HTTPD_DATA_PATH=/var/www \
HTTPD_DATA_ORIG_PATH=/var/www \
HTTPD_LOG_PATH=/var/log/httpd

COPY 2.4/s2i/bin/ $STI_SCRIPTS_PATH
COPY 2.4/root /

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

USER 1001

# Not using VOLUME statement since it's not working in OpenShift Online:
# https://github.com/sclorg/httpd-container/issues/30
# VOLUME ["${HTTPD_DATA_PATH}"]
# VOLUME ["${HTTPD_LOG_PATH}"]

CMD ["/usr/bin/run-httpd"]
9 changes: 5 additions & 4 deletions 2.4/Dockerfile.fedora
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM quay.io/fedora/s2i-core:38
FROM quay.io/fedora/s2i-core:40

# Apache HTTP Server image.
#
Expand All @@ -9,6 +9,7 @@ FROM quay.io/fedora/s2i-core:38
# * $HTTPD_LOG_TO_VOLUME (optional) - When set, httpd will log into /var/log/httpd

ENV HTTPD_VERSION=2.4 \
HTTPD_SHORT_VERSION=24 \
NAME=httpd \
ARCH=x86_64

Expand All @@ -24,11 +25,11 @@ LABEL summary="$SUMMARY" \
io.k8s.description="$SUMMARY" \
io.k8s.display-name="Apache httpd $HTTPD_VERSION" \
io.openshift.expose-services="8080:http,8443:https" \
io.openshift.tags="builder,httpd,httpd24" \
io.openshift.tags="builder,$NAME,$NAME24" \
com.redhat.component="$NAME" \
name="fedora/$NAME-24" \
name="fedora/$NAME-$HTTPD_SHORT_VERSION" \
version="$HTTPD_VERSION" \
usage="s2i build https://github.com/sclorg/httpd-container.git --context-dir=examples/sample-test-app/ quya.io/fedora/$NAME-24 sample-server" \
usage="s2i build https://github.com/sclorg/httpd-container.git --context-dir=examples/sample-test-app/ quya.io/fedora/$NAME-$HTTPD_SHORT_VERSION sample-server" \
maintainer="SoftwareCollections.org <[email protected]>"

EXPOSE 8080
Expand Down
12 changes: 7 additions & 5 deletions 2.4/Dockerfile.rhel9
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ FROM ubi9/s2i-core:1
# Environment:
# * $HTTPD_LOG_TO_VOLUME (optional) - When set, httpd will log into /var/log/httpd24

ENV HTTPD_VERSION=2.4
ENV HTTPD_VERSION=2.4 \
HTTPD_SHORT_VERSION=24 \
NAME=httpd

ENV SUMMARY="Platform for running Apache httpd $HTTPD_VERSION or building httpd-based application" \
DESCRIPTION="Apache httpd $HTTPD_VERSION available as container, is a powerful, efficient, \
Expand All @@ -22,12 +24,12 @@ LABEL summary="$SUMMARY" \
io.k8s.description="$DESCRIPTION" \
io.k8s.display-name="Apache httpd $HTTPD_VERSION" \
io.openshift.expose-services="8080:http,8443:https" \
io.openshift.tags="builder,httpd,httpd-24" \
name="rhel9/httpd-24" \
io.openshift.tags="builder,$NAME,$NAME-$HTTPD_SHORT_VERSION" \
name="rhel9/$NAME-$HTTPD_SHORT_VERSION" \
version="1" \
com.redhat.license_terms="https://www.redhat.com/en/about/red-hat-end-user-license-agreements#UBI" \
com.redhat.component="httpd-24-container" \
usage="s2i build https://github.com/sclorg/httpd-container.git --context-dir=examples/sample-test-app/ rhel9/httpd-24 sample-server" \
com.redhat.component="$NAME-$HTTPD_SHORT_VERSION-container" \
usage="s2i build https://github.com/sclorg/httpd-container.git --context-dir=examples/sample-test-app/ rhel9/$NAME-$HTTPD_SHORT_VERSION sample-server" \
maintainer="SoftwareCollections.org <[email protected]>"

EXPOSE 8080
Expand Down
1 change: 1 addition & 0 deletions 2.4/root/usr/share/container-scripts/httpd/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -246,4 +246,5 @@ https://github.com/sclorg/httpd-container.
In that repository, the Dockerfile for RHEL8 is called Dockerfile.rhel8,
the Dockerfile for RHEL9 is called Dockerfile.rhel9,
the Dockerfile for CentOS Stream 9 is called Dockerfile.c9s,
the Dockerfile for CentOS Stream 10 is called Dockerfile.c10s,
and the Dockerfile for Fedora is called Dockerfile.fedora.
6 changes: 4 additions & 2 deletions 2.4/root/usr/share/container-scripts/httpd/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@

if head "/etc/redhat-release" | grep -q "^Red Hat Enterprise Linux release 8"; then
HTTPCONF_LINENO=154
elif head "/etc/redhat-release" | grep -q "^CentOS Stream release 8"; then
HTTPCONF_LINENO=154
elif head "/etc/redhat-release" | grep -q "^CentOS Stream release 10"; then
HTTPCONF_LINENO=156
elif head "/etc/redhat-release" | grep -q "^Fedora"; then
HTTPCONF_LINENO=156
elif [ "x$PLATFORM" == "xel9" ]; then
HTTPCONF_LINENO=156
elif [ "x$PLATFORM" == "xel10" ]; then
HTTPCONF_LINENO=156
else
HTTPCONF_LINENO=151
fi
Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,12 @@ RHEL versions currently supported are:

CentOS Stream versions currently supported are:
* CentOS Stream 9
* CentOS Stream 10


Installation
------------
Choose either the CentOS Stream 9 or RHEL8 based image:
Choose either the CentOS Stream 9, CentOS Stream 10 or RHEL8 based image:

* **RHEL8 based image**

Expand Down Expand Up @@ -92,7 +93,7 @@ Test
This repository also provides a test framework, which checks basic functionality
of the Apache HTTP Server image.

Users can choose between testing Apache HTTP Server based on a RHEL or CentOS image.
Users can choose between testing Apache HTTP Server based on a RHEL or CentOS Stream image.

* **RHEL based image**

Expand All @@ -105,7 +106,7 @@ Users can choose between testing Apache HTTP Server based on a RHEL or CentOS im
$ make test TARGET=rhel8 VERSIONS=2.4
```

* **CentOS based image**
* **CentOS Stream based image**

```
$ cd httpd-container
Expand Down
4 changes: 2 additions & 2 deletions test/run
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function run_default_page_test() {
# Check default page
run "ct_create_container test_default_page"
cip=$(ct_get_cip 'test_default_page')
if [[ "${OS}" == "c9s" ]] || [[ "${OS}" == "c8s" ]]; then
if [[ "${OS}" == "c9s" ]] || [[ "${OS}" == "c10s" ]]; then
run "ct_test_response '${cip}':8080 403 'HTTP Server Test Page' 50"
else
run "ct_test_response '${cip}':8080 403 'Test Page for the (Apache )?HTTP Server on' 50"
Expand All @@ -39,7 +39,7 @@ function run_as_root_test() {
# Try running as root
CONTAINER_ARGS="--user 0" run "ct_create_container test_run_as_root"
cip=$(ct_get_cip 'test_run_as_root')
if [[ "${OS}" == "c9s" ]] || [[ "${OS}" == "c8s" ]]; then
if [[ "${OS}" == "c9s" ]] || [[ "${OS}" == "c10s" ]]; then
run "ct_test_response '${cip}':8080 403 'HTTP Server Test Page'"
else
run "ct_test_response '${cip}':8080 403 'Test Page for the (Apache )?HTTP Server on'"
Expand Down