|
| 1 | +{% import "src/common.tpl" as common with context %} |
| 2 | +{% import "src/" + config.os.id + "/macros.tpl" as macros with context %} |
| 3 | +{% set ns = namespace(extra_pkgs=[]) %} |
| 4 | +{% for item in spec.extra_pkgs %} |
| 5 | +{% if spec.version == item.version %} |
| 6 | +{% set ns.extra_pkgs = item.value %} |
| 7 | +{% endif %} |
| 8 | +{% endfor %} |
| 9 | +{% if config.os.id == 'rhel' and spec.base_img_version %} |
| 10 | +{% set img_tag = spec.base_img_version %} |
| 11 | +{% elif spec.img_tag %} |
| 12 | +{% set img_tag = spec.img_tag %} |
| 13 | +{% endif %} |
| 14 | +# This image provides a Python {{ spec.version }} environment you can use to run your Python |
| 15 | +# applications. |
| 16 | +FROM {{ spec.s2i_base}}{% if img_tag %}:{{ img_tag }}{% endif %} |
| 17 | + |
| 18 | + |
| 19 | +EXPOSE 8080 |
| 20 | + |
| 21 | +ENV PYTHON_VERSION={{ spec.version }} \ |
| 22 | + PATH=$HOME/.local/bin/:$PATH \ |
| 23 | + PYTHONUNBUFFERED=1 \ |
| 24 | + PYTHONIOENCODING=UTF-8 \ |
| 25 | + LC_ALL=en_US.UTF-8 \ |
| 26 | + LANG=en_US.UTF-8 \ |
| 27 | + PIP_NO_CACHE_DIR=off |
| 28 | + |
| 29 | +{{ macros.env_metadata() -}} |
| 30 | +ENV SUMMARY="Platform for building and running Python $PYTHON_VERSION applications" \ |
| 31 | + DESCRIPTION="Python $PYTHON_VERSION available as container is a base platform for \ |
| 32 | +building and running various Python $PYTHON_VERSION applications and frameworks. \ |
| 33 | +Python is an easy to learn, powerful programming language. It has efficient high-level \ |
| 34 | +data structures and a simple but effective approach to object-oriented programming. \ |
| 35 | +Python's elegant syntax and dynamic typing, together with its interpreted nature, \ |
| 36 | +make it an ideal language for scripting and rapid application development in many areas \ |
| 37 | +on most platforms." |
| 38 | + |
| 39 | +LABEL summary="$SUMMARY" \ |
| 40 | + description="$DESCRIPTION" \ |
| 41 | + io.k8s.description="$DESCRIPTION" \ |
| 42 | + io.k8s.display-name="Python {{ spec.version }}" \ |
| 43 | + io.openshift.expose-services="8080:http" \ |
| 44 | + io.openshift.tags="builder,python,python{{ spec.short_ver }},rh-python{{ spec.short_ver }}" \ |
| 45 | +{{ macros.labels(spec) }} |
| 46 | +RUN INSTALL_PKGS="{{ common.list_pkgs(ns.extra_pkgs + spec.python_pkgs + spec.base_pkgs) -}} |
| 47 | + {% if spec.preinstall_cmd %} |
| 48 | +{{ common.preinstall_cmd(spec) -}} |
| 49 | + {% endif %} |
| 50 | + {{ commands.pkginstaller.install([], {'docs': False}) }}{{ common.enablerepo(spec) }} $INSTALL_PKGS && \ |
| 51 | + rpm -V $INSTALL_PKGS && \ |
| 52 | + {% if spec.logos %} |
| 53 | + # Remove {{ spec.logos }} (httpd dependency) to keep image size smaller. |
| 54 | + rpm -e --nodeps {{ spec.logos }} && \ |
| 55 | + {% endif %} |
| 56 | + {{ commands.pkginstaller.cleancache() }} |
| 57 | + |
| 58 | +# Copy the S2I scripts from the specific language image to $STI_SCRIPTS_PATH. |
| 59 | +COPY ./s2i/bin/ $STI_SCRIPTS_PATH |
| 60 | + |
| 61 | +# Copy extra files to the image. |
| 62 | +COPY ./root/ / |
| 63 | + |
| 64 | +# - Create a Python virtual environment for use by any application to avoid |
| 65 | +# potential conflicts with Python packages preinstalled in the main Python |
| 66 | +# installation. |
| 67 | +# - In order to drop the root user, we have to make some directories world |
| 68 | +# writable as OpenShift default security model is to run the container |
| 69 | +# under random UID. |
| 70 | +{{ macros.permissions_setup(spec) }} |
| 71 | +USER 1001 |
| 72 | + |
| 73 | +# Set the default CMD to print the usage of the language image. |
| 74 | +CMD $STI_SCRIPTS_PATH/usage |
0 commit comments