Skip to content

Commit dafb973

Browse files
committed
Distgen generated content
1 parent 3da822f commit dafb973

File tree

1 file changed

+105
-0
lines changed

1 file changed

+105
-0
lines changed

3.12-minimal/Dockerfile.rhel8

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
FROM ubi8/ubi-minimal:latest
2+
3+
4+
EXPOSE 8080
5+
6+
ENV PYTHON_VERSION=3.12 \
7+
PYTHONUNBUFFERED=1 \
8+
PYTHONIOENCODING=UTF-8 \
9+
LC_ALL=en_US.UTF-8 \
10+
LANG=en_US.UTF-8 \
11+
CNB_STACK_ID=com.redhat.stacks.ubi8-python-312 \
12+
CNB_USER_ID=1001 \
13+
CNB_GROUP_ID=0 \
14+
PIP_NO_CACHE_DIR=off \
15+
# The following variables are usually available from parent s2i images \
16+
STI_SCRIPTS_PATH=/usr/libexec/s2i \
17+
APP_ROOT=/opt/app-root \
18+
HOME=/opt/app-root/src \
19+
PLATFORM="el8"
20+
21+
# /opt/app-root/bin - the main venv
22+
# /opt/app-root/src/bin - app-specific binaries
23+
# /opt/app-root/src/.local/bin - tools like pipenv
24+
ENV PATH=$APP_ROOT/bin:$HOME/bin:$HOME/.local/bin:$PATH
25+
26+
# Ensure the virtual environment is active in interactive shells
27+
ENV BASH_ENV=${APP_ROOT}/bin/activate \
28+
ENV=${APP_ROOT}/bin/activate \
29+
PROMPT_COMMAND=". ${APP_ROOT}/bin/activate"
30+
31+
ENV SUMMARY="Minimal platform for building and running Python $PYTHON_VERSION applications" \
32+
DESCRIPTION="Python $PYTHON_VERSION available as container is a base platform for \
33+
building and running various Python $PYTHON_VERSION applications and frameworks. \
34+
Python is an easy to learn, powerful programming language. It has efficient high-level \
35+
data structures and a simple but effective approach to object-oriented programming. \
36+
Python's elegant syntax and dynamic typing, together with its interpreted nature, \
37+
make it an ideal language for scripting and rapid application development in many areas \
38+
on most platforms."
39+
40+
LABEL summary="$SUMMARY" \
41+
description="$DESCRIPTION" \
42+
io.k8s.description="$DESCRIPTION" \
43+
io.k8s.display-name="Python 3.12" \
44+
io.openshift.expose-services="8080:http" \
45+
io.openshift.tags="builder,python,python312,python-312,rh-python312" \
46+
com.redhat.component="python-312-container" \
47+
name="ubi8/python-312-minimal" \
48+
version="1" \
49+
usage="s2i build https://github.com/sclorg/s2i-python-container.git --context-dir=3.12-minimal/test/setup-test-app/ ubi8/python-312-minimal python-sample-app" \
50+
com.redhat.license_terms="https://www.redhat.com/en/about/red-hat-end-user-license-agreements#UBI" \
51+
io.buildpacks.stack.id="com.redhat.stacks.ubi8-python-312-minimal" \
52+
maintainer="SoftwareCollections.org <sclorg@redhat.com>"
53+
54+
# Very minimal set of packages
55+
# Python is obvious in the Python container :)
56+
# glibc-langpack-en is needed to set locale to en_US and disable warning about it
57+
# findutils - find command is needed for fix-permissions script
58+
# nss_wrapper - used in generate_container_user script
59+
RUN INSTALL_PKGS="python3.12 glibc-langpack-en findutils nss_wrapper-libs" && \
60+
microdnf -y --setopt=tsflags=nodocs --setopt=install_weak_deps=0 install $INSTALL_PKGS && \
61+
microdnf -y clean all --enablerepo='*'
62+
63+
# Copy the S2I scripts from the specific language image to $STI_SCRIPTS_PATH.
64+
COPY 3.12-minimal/s2i/bin/ $STI_SCRIPTS_PATH
65+
66+
# Copy extra files to the image.
67+
COPY 3.12-minimal/root/ /
68+
69+
# Python 3.7+ only
70+
# Yes, the directory below is already copied by the previous command.
71+
# The problem here is that the wheels directory is copied as a symlink.
72+
# Only if you specify symlink directly as a source, COPY copies all the
73+
# files from the symlink destination.
74+
COPY 3.12-minimal/root/opt/wheels /opt/wheels
75+
76+
# This command sets (and also creates if necessary)
77+
# the home directory - it has to be done here so the latter
78+
# fix-permissions fixes this directory as well.
79+
WORKDIR ${HOME}
80+
81+
# - Create a Python virtual environment for use by any application to avoid
82+
# potential conflicts with Python packages preinstalled in the main Python
83+
# installation.
84+
# - In order to drop the root user, we have to make some directories world
85+
# writable as OpenShift default security model is to run the container
86+
# under random UID.
87+
RUN \
88+
python3.12 -m venv ${APP_ROOT} && \
89+
# We have to upgrade pip to a newer version because \
90+
# pip < 19.3 does not support manylinux2014 wheels. Only manylinux2014 (and later) wheels \
91+
# support platforms like ppc64le, aarch64 or armv7 \
92+
# We are newly using wheel from one of the latest stable Fedora releases (from RPM python-pip-wheel) \
93+
# because it's tested better then whatever version from PyPI and contains useful patches. \
94+
# We have to do it here so the permissions are correctly fixed and pip is able \
95+
# to reinstall itself in the next build phases in the assemble script if user wants the latest version \
96+
${APP_ROOT}/bin/pip install /opt/wheels/pip-* && \
97+
rm -r /opt/wheels && \
98+
chown -R 1001:0 ${APP_ROOT} && \
99+
fix-permissions ${APP_ROOT} -P && \
100+
rpm-file-permissions
101+
102+
USER 1001
103+
104+
# Set the default CMD to print the usage of the language image.
105+
CMD $STI_SCRIPTS_PATH/usage

0 commit comments

Comments
 (0)