Skip to content

Commit e4091b2

Browse files
authored
RHAIENG-2042: chore(base-images): use AIPCC-style scripting instead of scl base to add s390x architecture to odh-base-image-cpu-py312-c9s (#2690)
``` [2/3] STEP 1/10: FROM quay.io/opendatahub/odh-base-image-cpu-py312-c9s:latest AS cpu-base Trying to pull quay.io/opendatahub/odh-base-image-cpu-py312-c9s:latest... Error: creating build container: unable to copy from source docker://quay.io/opendatahub/odh-base-image-cpu-py312-c9s:latest: choosing an image from manifest list docker://quay.io/opendatahub/odh-base-image-cpu-py312-c9s:latest: no image found in manifest list for architecture "s390x", variant "", OS "linux" ```
1 parent 374eed5 commit e4091b2

File tree

7 files changed

+512
-11
lines changed

7 files changed

+512
-11
lines changed

.tekton/odh-base-image-cpu-py312-c9s-pull-request.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ spec:
3939
- linux/x86_64
4040
- linux/arm64
4141
- linux/ppc64le
42-
# TODO(jdanek): Enable s390x once it is supported in the base image.
43-
#- linux/s390x
42+
- linux/s390x
4443
pipelineRef:
4544
name: multiarch-pull-request-pipeline
4645
taskRunTemplate:

.tekton/odh-base-image-cpu-py312-c9s-push.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ spec:
3737
- linux/x86_64
3838
- linux/arm64
3939
- linux/ppc64le
40-
# TODO(jdanek): Enable s390x once it is supported in the base image.
41-
#- linux/s390x
40+
- linux/s390x
4241
pipelineRef:
4342
name: multiarch-push-pipeline
4443
taskRunTemplate:
Lines changed: 60 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,78 @@
11
ARG TARGETARCH
22

3-
FROM quay.io/sclorg/python-312-c9s:c9s AS buildscripts
3+
FROM quay.io/centos/centos:stream9 AS buildscripts
44
COPY base-images/utils/aipcc.sh /mnt/aipcc.sh
5+
COPY base-images/utils/fix-permissions base-images/utils/rpm-file-permissions /mnt/usr/bin/
56

67
####################
78
# base #
89
####################
9-
FROM quay.io/sclorg/python-312-c9s:c9s AS base
10+
FROM quay.io/centos/centos:stream9 AS base
11+
12+
ARG PYTHON_VERSION=3.12
13+
ENV PYTHON=python${PYTHON_VERSION}
14+
15+
ARG VARIANT=cpu
16+
ARG NAME=odh-base-image-cpu-py312-c9s
17+
ARG SUMMARY="Open Data Hub Notebooks Base Image for ${VARIANT} with Python ${PYTHON_VERSION}"
18+
# https://github.com/projectatomic/ContainerApplicationGenericLabels
19+
ARG DESCRIPTION="${SUMMARY} with Python ${PYTHON_VERSION}"
20+
21+
LABEL summary="${SUMMARY}" \
22+
description="${DESCRIPTION}" \
23+
io.k8s.display-name="${SUMMARY}" \
24+
io.k8s.description="${DESCRIPTION}"
1025

1126
USER 0
27+
ARG TARGETARCH
28+
ENV TARGETARCH=${TARGETARCH}
29+
30+
# MPI implementation (default: OpenMPI)
31+
ENV MPI_HOME=/usr/lib64/openmpi
32+
33+
ENV APP_ROOT=/opt/app-root
34+
ENV HOME=${APP_ROOT}/src
35+
ENV PATH=${HOME}/bin:${HOME}/.local/bin:${APP_ROOT}/bin:/usr/local/sbin:/usr/local/bin:${MPI_HOME}/bin:/usr/sbin:/usr/bin:/sbin:/bin
36+
37+
# Python and virtual env settings
38+
ENV VIRTUAL_ENV=${APP_ROOT} \
39+
PIP_NO_CACHE_DIR=off \
40+
UV_NO_CACHE=true \
41+
PIP_DISABLE_PIP_VERSION_CHECK=1 \
42+
PYTHONUNBUFFERED=1 \
43+
PYTHONIOENCODING=utf-8 \
44+
LANG=en_US.UTF-8 \
45+
LC_ALL=en_US.UTF-8 \
46+
PS1="(app-root) \w\$ "
47+
48+
# OpenShift s2i / Cloud Native Buildpack user
49+
ENV CNB_USER_ID=1001 \
50+
CNB_GROUP_ID=0
51+
52+
# Create home directory and XDG cache directory group-writable. $HOME
53+
# is owned by 1001:0. All directories are writable by gid 0.
54+
# hadolint ignore=DL3046
55+
RUN useradd -u ${CNB_USER_ID} -g ${CNB_GROUP_ID} -d ${HOME} -K HOME_MODE=0770 -K UMASK=0007 -m -s /bin/bash -c "Default Application User" default \
56+
&& mkdir -m 770 "${HOME}/.cache"
57+
58+
# permission fixer from github.com/sclorg
59+
COPY --from=buildscripts /mnt/usr/bin/ /usr/bin/
1260

1361
RUN \
1462
--mount=from=buildscripts,source=/mnt,target=/mnt \
1563
--mount=type=cache,sharing=locked,id=dnf-c9s,target=/var/cache/dnf \
1664
/bin/bash <<'EOF'
65+
set -Eeuxo pipefail
1766
/mnt/aipcc.sh
67+
fix-permissions ${APP_ROOT} -P
1868
EOF
1969

70+
RUN rpm-file-permissions
71+
2072
# Restore user workspace
21-
USER 1001
22-
WORKDIR /opt/app-root/src
73+
WORKDIR ${APP_ROOT}
74+
USER ${CNB_USER_ID}:${CNB_GROUP_ID}
75+
76+
# RHELAI-2417, RHELAI-1720: workaround for PyArrow
77+
# libjemalloc.so.2: cannot allocate memory in static TLS block
78+
ENV LD_PRELOAD=/usr/lib64/libjemalloc.so.2
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# AIPCC-like Python 3.12 base image
2+
3+
## Generating the list of additional packages
4+
5+
```commandline
6+
podman run --rm --pull=always quay.io/sclorg/python-312-c9s:c9s rpm -qa '*' | sort > /tmp/scl_packages.txt
7+
podman run --rm --pull=always quay.io/aipcc/base-images/cpu:3.1 rpm -qa '*' | sort > /tmp/aipcc_packages.txt
8+
```
9+
10+
```python
11+
def get_packages_from_file(filename: str) -> set[str]:
12+
"""Reads a file and returns a set of package names."""
13+
with open(filename, 'r') as f:
14+
# We strip the version info from the package names (e.g., 'bash-5.1.8-6.el9_1.x86_64')
15+
# to get just the package name ('bash').
16+
return {line.strip().rsplit('-', 2)[0] for line in f if line.strip()}
17+
18+
def main():
19+
"""
20+
Compares package lists from two files and prints the difference,
21+
formatted for inclusion in a bash script.
22+
"""
23+
scl_packages = get_packages_from_file('/tmp/scl_packages.txt')
24+
aipcc_packages = get_packages_from_file('/tmp/aipcc_packages.txt')
25+
26+
# Find packages in scl but not in aipcc
27+
difference = sorted(list(scl_packages - aipcc_packages))
28+
29+
# Format for bash array
30+
print("SCL_PACKAGES=(")
31+
for pkg in difference:
32+
print(f' "{pkg}"')
33+
print(")")
34+
35+
if __name__ == "__main__":
36+
main()
37+
```

0 commit comments

Comments
 (0)