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

Add Python 3.12 and 3.12-minimal with C10S #711

Merged
merged 4 commits into from
Sep 18, 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
16 changes: 16 additions & 0 deletions .github/workflows/build-and-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,14 @@ jobs:
tag: "c9s"
image_name: "python-312-minimal-c9s"

- dockerfile: "3.12-minimal/Dockerfile.c10s"
docker_context: "3.12-minimal"
registry_namespace: "sclorg"
quayio_username: "QUAY_IMAGE_SCLORG_BUILDER_USERNAME"
quayio_token: "QUAY_IMAGE_SCLORG_BUILDER_TOKEN"
tag: "c10s"
image_name: "python-312-minimal-c10s"

- dockerfile: "3.12/Dockerfile.fedora"
docker_context: "3.12"
registry_namespace: "fedora"
Expand All @@ -102,6 +110,14 @@ jobs:
tag: "c9s"
image_name: "python-312-c9s"

- dockerfile: "3.12/Dockerfile.c10s"
docker_context: "3.12"
registry_namespace: "sclorg"
quayio_username: "QUAY_IMAGE_SCLORG_BUILDER_USERNAME"
quayio_token: "QUAY_IMAGE_SCLORG_BUILDER_TOKEN"
tag: "c10s"
image_name: "python-312-c10s"

steps:
- name: Build and push to quay.io registry
uses: sclorg/build-and-push-action@v4
Expand Down
3 changes: 1 addition & 2 deletions 3.11-minimal/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ Because the minimal and full images work similarly, we document here only the di
of the minimal container image. For the documentation of common features see the [full container image docs](https://github.com/sclorg/s2i-python-container/tree/master/3.11).

The Python 3.11 minimal container image is currently considered a tech-preview and only available on quay.io.
The image is built on top of the [Red Hat Universal Base Image 8 Micro image](https://catalog.redhat.com/software/containers/ubi8-micro/601a84aadd19c7786c47c8ea)
and therefore uses the RPM packages from Red Hat Enterprise Linux, the same that are used by Python 3.9 supported container image and are part of the [UBI registry](https://www.redhat.com/en/blog/introducing-red-hat-universal-base-image).
The image is built on top of the [official CentOS Stream base containers](quay.io/centos/centos).

To pull the Python 3.11 minimal container image to build on, run

Expand Down
5 changes: 3 additions & 2 deletions 3.11/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -381,5 +381,6 @@ See also
--------
Dockerfile and other sources are available on https://github.com/sclorg/s2i-python-container.
In that repository you also can find another versions of Python 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`.
Dockerfile for RHEL8 is called `Dockerfile.rhel8`, for RHEL9 it's `Dockerfile.rhel9`,
for CentOS Stream 9 it's `Dockerfile.c9s`, for CentOS Stream 10 it's `Dockerfile.c10s`,
and the Fedora Dockerfile is called `Dockerfile.fedora`.
108 changes: 108 additions & 0 deletions 3.12-minimal/Dockerfile.c10s
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
FROM quay.io/centos/centos:stream10-development-minimal


EXPOSE 8080

ENV PYTHON_VERSION=3.12 \
PYTHONUNBUFFERED=1 \
PYTHONIOENCODING=UTF-8 \
LC_ALL=en_US.UTF-8 \
LANG=en_US.UTF-8 \
CNB_STACK_ID=com.redhat.stacks.ubi10-python-312 \
CNB_USER_ID=1001 \
CNB_GROUP_ID=0 \
PIP_NO_CACHE_DIR=off \
# 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"

# /opt/app-root/bin - the main venv
# /opt/app-root/src/bin - app-specific binaries
# /opt/app-root/src/.local/bin - tools like pipenv
ENV PATH=$APP_ROOT/bin:$HOME/bin:$HOME/.local/bin:$PATH

# RHEL7 base images automatically set these envvars to run scl_enable. RHEl8
# images, however, don't as most images don't need SCLs any more. But we want
# to run it even on RHEL8, because we set the virtualenv environment as part of
# that script
ENV BASH_ENV=${APP_ROOT}/etc/scl_enable \
ENV=${APP_ROOT}/etc/scl_enable \
PROMPT_COMMAND=". ${APP_ROOT}/etc/scl_enable"

ENV SUMMARY="Minimal platform for building and running Python $PYTHON_VERSION applications" \
DESCRIPTION="Python $PYTHON_VERSION available as container is a base platform for \
building and running various Python $PYTHON_VERSION applications and frameworks. \
Python is an easy to learn, powerful programming language. It has efficient high-level \
data structures and a simple but effective approach to object-oriented programming. \
Python's elegant syntax and dynamic typing, together with its interpreted nature, \
make it an ideal language for scripting and rapid application development in many areas \
on most platforms."

LABEL summary="$SUMMARY" \
description="$DESCRIPTION" \
io.k8s.description="$DESCRIPTION" \
io.k8s.display-name="Python 3.12" \
io.openshift.expose-services="8080:http" \
io.openshift.tags="builder,python,python312,python-312,rh-python312" \
com.redhat.component="python-312-container" \
name="sclorg/python-312-minimal-c10s" \
version="1" \
usage="s2i build https://github.com/sclorg/s2i-python-container.git --context-dir=3.12-minimal/test/setup-test-app/ ubi10/python-312-minimal python-sample-app" \
com.redhat.license_terms="https://www.redhat.com/en/about/red-hat-end-user-license-agreements#UBI" \
io.buildpacks.stack.id="com.redhat.stacks.ubi10-python-312-minimal" \
maintainer="SoftwareCollections.org <[email protected]>"

# Very minimal set of packages
# Python is obvious in the Python container :)
# glibc-langpack-en is needed to set locale to en_US and disable warning about it
# findutils - find command is needed for fix-permissions script
# nss_wrapper - used in generate_container_user script
RUN INSTALL_PKGS="python3.12 glibc-langpack-en findutils nss_wrapper" && \
microdnf -y --setopt=tsflags=nodocs --setopt=install_weak_deps=0 install $INSTALL_PKGS && \
microdnf -y clean all --enablerepo='*'

# Copy the S2I scripts from the specific language image to $STI_SCRIPTS_PATH.
COPY 3.12-minimal/s2i/bin/ $STI_SCRIPTS_PATH

# Copy extra files to the image.
COPY 3.12-minimal/root/ /

# Python 3.7+ only
# Yes, the directory below is already copied by the previous command.
# The problem here is that the wheels directory is copied as a symlink.
# Only if you specify symlink directly as a source, COPY copies all the
# files from the symlink destination.
COPY 3.12/root/opt/wheels /opt/wheels

# This command sets (and also creates if necessary)
# the home directory - it has to be done here so the latter
# fix-permissions fixes this directory as well.
WORKDIR ${HOME}

# - Create a Python virtual environment for use by any application to avoid
# potential conflicts with Python packages preinstalled in the main Python
# installation.
# - In order to drop the root user, we have to make some directories world
# writable as OpenShift default security model is to run the container
# under random UID.
RUN \
python3.12 -m venv ${APP_ROOT} && \
# We have to upgrade pip to a newer version because \
# pip < 19.3 does not support manylinux2014 wheels. Only manylinux2014 (and later) wheels \
# support platforms like ppc64le, aarch64 or armv7 \
# We are newly using wheel from one of the latest stable Fedora releases (from RPM python-pip-wheel) \
# because it's tested better then whatever version from PyPI and contains useful patches. \
# We have to do it here so the permissions are correctly fixed and pip is able \
# to reinstall itself in the next build phases in the assemble script if user wants the latest version \
${APP_ROOT}/bin/pip install /opt/wheels/pip-* && \
rm -r /opt/wheels && \
chown -R 1001:0 ${APP_ROOT} && \
fix-permissions ${APP_ROOT} -P && \
rpm-file-permissions

USER 1001

# Set the default CMD to print the usage of the language image.
CMD $STI_SCRIPTS_PATH/usage
3 changes: 1 addition & 2 deletions 3.12-minimal/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ Because the minimal and full images work similarly, we document here only the di
of the minimal container image. For the documentation of common features see the [full container image docs](https://github.com/sclorg/s2i-python-container/tree/master/3.12).

The Python 3.12 minimal container image is currently considered a tech-preview and only available on quay.io.
The image is built on top of the [Red Hat Universal Base Image 8 Micro image](https://catalog.redhat.com/software/containers/ubi8-micro/601a84aadd19c7786c47c8ea)
and therefore uses the RPM packages from Red Hat Enterprise Linux, the same that are used by Python 3.9 supported container image and are part of the [UBI registry](https://www.redhat.com/en/blog/introducing-red-hat-universal-base-image).
The image is built on top of the [official CentOS Stream base containers](quay.io/centos/centos).

To pull the Python 3.12 minimal container image to build on, run

Expand Down
93 changes: 93 additions & 0 deletions 3.12/Dockerfile.c10s
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# This image provides a Python 3.12 environment you can use to run your Python
# applications.
FROM quay.io/sclorg/s2i-base-c10s:c10s

EXPOSE 8080

ENV PYTHON_VERSION=3.12 \
PATH=$HOME/.local/bin/:$PATH \
PYTHONUNBUFFERED=1 \
PYTHONIOENCODING=UTF-8 \
LC_ALL=en_US.UTF-8 \
LANG=en_US.UTF-8 \
PIP_NO_CACHE_DIR=off

ENV NAME=python3 \
VERSION=0 \
ARCH=x86_64

ENV SUMMARY="Platform for building and running Python $PYTHON_VERSION applications" \
DESCRIPTION="Python $PYTHON_VERSION available as container is a base platform for \
building and running various Python $PYTHON_VERSION applications and frameworks. \
Python is an easy to learn, powerful programming language. It has efficient high-level \
data structures and a simple but effective approach to object-oriented programming. \
Python's elegant syntax and dynamic typing, together with its interpreted nature, \
make it an ideal language for scripting and rapid application development in many areas \
on most platforms."

LABEL summary="$SUMMARY" \
description="$DESCRIPTION" \
io.k8s.description="$DESCRIPTION" \
io.k8s.display-name="Python 3.12" \
io.openshift.expose-services="8080:http" \
io.openshift.tags="builder,python,python312,python-312,rh-python312" \
com.redhat.component="$NAME" \
name="sclorg/python-312-c10s" \
version="$VERSION" \
usage="s2i build https://github.com/sclorg/s2i-python-container.git --context-dir=3.12/test/setup-test-app/ $FGC/$NAME python-sample-app" \
maintainer="SoftwareCollections.org <[email protected]>"

RUN INSTALL_PKGS="python3 python3-devel python3-setuptools python3-pip nss_wrapper \
httpd httpd-devel mod_ssl mod_auth_gssapi mod_ldap \
mod_session gcc-gfortran libffi-devel libtool-ltdl krb5-devel" && \
yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
rpm -V $INSTALL_PKGS && \
yum -y clean all --enablerepo='*'

# Copy the S2I scripts from the specific language image to $STI_SCRIPTS_PATH.
COPY 3.12/s2i/bin/ $STI_SCRIPTS_PATH

# Copy extra files to the image.
COPY 3.12/root/ /

# Python 3.7+ only
# Yes, the directory below is already copied by the previous command.
# The problem here is that the wheels directory is copied as a symlink.
# Only if you specify symlink directly as a source, COPY copies all the
# files from the symlink destination.
COPY 3.12/root/opt/wheels /opt/wheels
# - Create a Python virtual environment for use by any application to avoid
# potential conflicts with Python packages preinstalled in the main Python
# installation.
# - In order to drop the root user, we have to make some directories world
# writable as OpenShift default security model is to run the container
# under random UID.
RUN python3.12 -m venv ${APP_ROOT} && \
# Python 3.7+ only code, Python <3.7 installs pip from PyPI in the assemble script. \
# We have to upgrade pip to a newer verison because \
# pip < 19.3 does not support manylinux2014 wheels. Only manylinux2014 (and later) wheels \
# support platforms like ppc64le, aarch64 or armv7 \
# We are newly using wheel from one of the latest stable Fedora releases (from RPM python-pip-wheel) \
# because it's tested better then whatever version from PyPI and contains useful patches. \
# We have to do it here (in the macro) so the permissions are correctly fixed and pip is able \
# to reinstall itself in the next build phases in the assemble script if user wants the latest version \
${APP_ROOT}/bin/pip install /opt/wheels/pip-* && \
rm -r /opt/wheels && \
chown -R 1001:0 ${APP_ROOT} && \
fix-permissions ${APP_ROOT} -P && \
# The following echo adds the unset command for the variables set below to the \
# venv activation script. This is inspired from scl_enable script and prevents \
# the virtual environment to be activated multiple times and also every time \
# the prompt is rendered. \
echo "unset BASH_ENV PROMPT_COMMAND ENV" >> ${APP_ROOT}/bin/activate

# For Fedora scl_enable isn't sourced automatically in s2i-core
# so virtualenv needs to be activated this way
ENV BASH_ENV="${APP_ROOT}/bin/activate" \
ENV="${APP_ROOT}/bin/activate" \
PROMPT_COMMAND=". ${APP_ROOT}/bin/activate"

USER 1001

# Set the default CMD to print the usage of the language image.
CMD $STI_SCRIPTS_PATH/usage
5 changes: 3 additions & 2 deletions 3.12/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -381,5 +381,6 @@ See also
--------
Dockerfile and other sources are available on https://github.com/sclorg/s2i-python-container.
In that repository you also can find another versions of Python 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`.
Dockerfile for RHEL8 is called `Dockerfile.rhel8`, for RHEL9 it's `Dockerfile.rhel9`,
for CentOS Stream 9 it's `Dockerfile.c9s`, for CentOS Stream 10 it's `Dockerfile.c10s`,
and the Fedora Dockerfile is called `Dockerfile.fedora`.
5 changes: 3 additions & 2 deletions 3.6/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -381,5 +381,6 @@ See also
--------
Dockerfile and other sources are available on https://github.com/sclorg/s2i-python-container.
In that repository you also can find another versions of Python 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`.
Dockerfile for RHEL8 is called `Dockerfile.rhel8`, for RHEL9 it's `Dockerfile.rhel9`,
for CentOS Stream 9 it's `Dockerfile.c9s`, for CentOS Stream 10 it's `Dockerfile.c10s`,
and the Fedora Dockerfile is called `Dockerfile.fedora`.
3 changes: 1 addition & 2 deletions 3.9-minimal/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ Because the minimal and full images work similarly, we document here only the di
of the minimal container image. For the documentation of common features see the [full container image docs](https://github.com/sclorg/s2i-python-container/tree/master/3.9).

The Python 3.9 minimal container image is currently considered a tech-preview and only available on quay.io.
The image is built on top of the [Red Hat Universal Base Image 8 Micro image](https://catalog.redhat.com/software/containers/ubi8-micro/601a84aadd19c7786c47c8ea)
and therefore uses the RPM packages from Red Hat Enterprise Linux, the same that are used by Python 3.9 supported container image and are part of the [UBI registry](https://www.redhat.com/en/blog/introducing-red-hat-universal-base-image).
The image is built on top of the [official CentOS Stream base containers](quay.io/centos/centos).

To pull the Python 3.9 minimal container image to build on, run

Expand Down
5 changes: 3 additions & 2 deletions 3.9/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -381,5 +381,6 @@ See also
--------
Dockerfile and other sources are available on https://github.com/sclorg/s2i-python-container.
In that repository you also can find another versions of Python 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`.
Dockerfile for RHEL8 is called `Dockerfile.rhel8`, for RHEL9 it's `Dockerfile.rhel9`,
for CentOS Stream 9 it's `Dockerfile.c9s`, for CentOS Stream 10 it's `Dockerfile.c10s`,
and the Fedora Dockerfile is called `Dockerfile.fedora`.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ Images available on Quay are:
* CentOS Stream 9 [python-312-minimal-c9s](https://quay.io/repository/sclorg/python-312-minimal-c9s)
* CentOS Stream 9 [python-312-c9s](https://quay.io/repository/sclorg/python-312-c9s)
* Fedora [python-312-minimal](https://quay.io/repository/fedora/python-312-minimal)
* CentOS Stream 10 [python-312-minimal-c9s](https://quay.io/repository/sclorg/python-312-minimal-c10s)
* CentOS Stream 10 [python-312-c9s](https://quay.io/repository/sclorg/python-312-c10s)
* Fedora [python-312](https://quay.io/repository/fedora/python-312)

This repository contains the source for building various versions of
Expand Down Expand Up @@ -63,8 +65,9 @@ RHEL versions currently supported are:
* RHEL 8 ([catalog.redhat.com](https://catalog.redhat.com/software/containers/search))
* RHEL 9 ([catalog.redhat.com](https://catalog.redhat.com/software/containers/search))

CentOS and CentOS Stream versions currently supported are:
CentOS Stream versions currently supported are:
* CentOS Stream 9 ([quay.io/sclorg](https://quay.io/organization/sclorg))
* CentOS Stream 10 ([quay.io/sclorg](https://quay.io/organization/sclorg))

Fedora versions currently supported are:
* Fedora 40 ([quay.io/fedora](https://quay.io/organization/fedora))
Expand Down
3 changes: 1 addition & 2 deletions examples/micropipenv-requirements-test-app/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
mod_wsgi==5.0.0; python_version >= '3.12'
mod_wsgi<5.0.0; python_version < '3.12'
Flask
# Tests that the pyenchant and gssapi packages are installable.
# Tests that gssapi package is installable.
# This test is ideal place because it's skipped for minimal containers.
pyenchant
gssapi
1 change: 0 additions & 1 deletion examples/micropipenv-requirements-test-app/wsgi.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import enchant
from flask import Flask
application = Flask(__name__)

Expand Down
2 changes: 2 additions & 0 deletions manifest-minimal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ DISTGEN_MULTI_RULES:
- src: src/Dockerfile-minimal.template
dest: Dockerfile.c9s

- src: src/Dockerfile-minimal.template
dest: Dockerfile.c10s

# Files to copy
COPY_RULES:
Expand Down
2 changes: 2 additions & 0 deletions manifest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ DISTGEN_MULTI_RULES:
- src: src/Dockerfile.template
dest: Dockerfile.c9s

- src: src/Dockerfile.template
dest: Dockerfile.c10s

# Files to copy
COPY_RULES:
Expand Down
19 changes: 19 additions & 0 deletions specs/multispec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,23 @@ specs:
"3.11": ['python3.11', 'python3.11-devel', 'python3.11-pip']
"3.12": ['python3.12', 'python3.12-devel', 'python3.12-pip']

c10s:
distros:
- centos-stream-10-x86_64
el_version: "10"
minimal_image: "quay.io/centos/centos:stream10-development-minimal"
s2i_base: quay.io/sclorg/s2i-base-c10s
img_tag: "c10s"
org: "sclorg"
prod: "c10s"
python_pkgs: []
base_pkgs: ['nss_wrapper', 'httpd', 'httpd-devel', 'mod_ssl',
'mod_auth_gssapi', 'mod_ldap', 'mod_session',
'gcc-gfortran', 'libffi-devel', 'libtool-ltdl',
'krb5-devel']
extra_pkgs:
"3.12": ['python3', 'python3-devel', 'python3-setuptools', 'python3-pip']

fedora40:
distros:
- fedora-40-x86_64
Expand Down Expand Up @@ -181,12 +198,14 @@ matrix:
version: "3.11-minimal"
- distros:
- fedora-40-x86_64
- centos-stream-10-x86_64
- centos-stream-9-x86_64
- rhel-9-x86_64
- rhel-8-x86_64
version: "3.12"
- distros:
- fedora-40-x86_64
- centos-stream-10-x86_64
- centos-stream-9-x86_64
- rhel-8-x86_64
version: "3.12-minimal"
Loading