Skip to content

Commit

Permalink
adding required files for f35-py310 S2I image to built
Browse files Browse the repository at this point in the history
  • Loading branch information
Gregory-Pereira committed Mar 10, 2022
1 parent 8946641 commit d1d3410
Show file tree
Hide file tree
Showing 8 changed files with 965 additions and 6 deletions.
31 changes: 31 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ s2i-thoth

.. |s2i-thoth-f34-py39 on Quay| image:: https://quay.io/repository/thoth-station/s2i-thoth-f34-py39/status

.. |s2i-thoth-f35-py310 on Quay| image:: https://quay.io/repository/thoth-station/s2i-thoth-f35-py310/status

Experimental Thoth container images:

* `quay.io/thoth-station/s2i-thoth-ubi8-py39 <https://quay.io/repository/thoth-station/s2i-thoth-ubi8-py39>`_ |s2i-thoth-ubi8-py39 on Quay|
Expand All @@ -19,6 +21,8 @@ Experimental Thoth container images:

* `quay.io/thoth-station/s2i-thoth-f34-py39 <https://quay.io/repository/thoth-station/s2i-thoth-f34-py39>`_ |s2i-thoth-f34-py39 on Quay|

* `quay.io/thoth-station/s2i-thoth-f35-py310 <https://quay.io/repository/thoth-station/s2i-thoth-f35-py310>`_ |s2i-thoth-f35-py310 on Quay|

Artifacts needed to build `s2i-thoth-*` container images.

These container images are complaint with OpenShift's s2i build process to
Expand Down Expand Up @@ -95,6 +99,33 @@ version of Thoth's s2i, you can do so by performing:
A subsequent pull request to this repository is needed.

-----------------------------------------
S2I Assemble Patches
-----------------------------------------

Most of the work when releasing a new container image comes from updating the ``s2i_assemble.patch`` file.
This file dictates how to change the base image's s2i assemble script, usually available at ``/usr/libexec/s2i/assemble`` of a container running the base image, to provide the new image with everything it may need.
As with any patch file, the ``s2i_assemble.patch`` can be generated manaually, however this is not recommend. The recommended methodology to create one is as follows:

1. create directories ``a`` and ``b`` in the root of the `s2i-thoth` repo.
2. find the ``assemble`` script of your base image.
- This starts by finding the base image. For instance, fedora base images are available at ``registry.fedoraproject.org/``
- Either:
-A: locate the ``s2i/assemble`` script in source from wherever the image is built. This varies depending on what type of image it is. Copy this file to ``a/assemble``.
OR
-B: create a temporary Dockerfile using the base image that will print its s2i ``assemble`` script. Then build a new image (``podman build .``) using that base image, copy that output and save it to ``a/assemble``. It is perfered that you can find it in source because any added whitespacing will not present an issue when you go to build the final image.
- Dockerfile Example for f34:
.. code-block:: console
FROM registry.fedoraproject.org/f34/python3:0-31.container
RUN cat /usr/libexec/s2i/assemble
3. Construct a new s2i ``assemble`` script in ``b/assemble``. This should reflect what you want the final patched s2i assemble script to be.
- For reference on what your final assemble script should look like refer to any image overlay in this repository. Find its base image s2i assemble script as described above, and patch it with the ``s2i_assemble.patch`` in the corresponding directory, ex: ``patch a/assemble -i <OVERLAY_NAME>/s2i_assemble.patch``. If this succeeds it will modify the base ``assemble`` script with your patch, and can serve as an example of what your final s2i assemble script should look like.
- NOTE: this may vary a lot by image, so thinnk about what the image chooses to include and remove rather than attempting to replicate it exactly for another overlay.
4. Run a diff between ``a/assemble`` and ``b/assemble``, and the output should become your ``s2i_assemble.patch``. Make sure to place it in the correct overlay. Example: ``diff a/assemble b/assemble > <OVERLAY_NAME>/s2i_assemble.patch``.
5. Verify that your image builds correctly. Navigate to your overlay directory with the new ``Dockerfile``, ``requirements.in``, ``requirements.txt``, and ``s2i_assemble.patch`` that you just generated. Run ``podman build .`` in the new overlay to verify that the image is buildable.

Importing image into OpenShift's registry
=========================================

Expand Down
46 changes: 46 additions & 0 deletions f35-py310/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Thoth's extension to OpenShift's S2I build
FROM registry.fedoraproject.org/f35/python3:0-41.container

ENV SUMMARY="Thoth's Source-to-Image for Python ${PYTHON_VERSION} applications" \
DESCRIPTION="Thoth's Source-to-Image for Python ${PYTHON_VERSION} applications. This toolchain is based on Fedora 35. It includes Pipenv." \
THOTH_S2I_NAME=quay.io/thoth-station/s2i-thoth-f35-py310 \
THOTH_S2I_VERSION=0.32.3 \
THAMOS_NO_PROGRESSBAR=1 \
THAMOS_NO_EMOJI=1 \
MICROPIPENV_NO_LOCKFILE_PRINT=0 \
MICROPIPENV_NO_LOCKFILE_WRITE=0

LABEL summary="$SUMMARY" \
description="$DESCRIPTION" \
io.k8s.description="$DESCRIPTION" \
io.k8s.display-name="Thoth Python 3.10-f35 S2I" \
io.openshift.expose-services="8080:http" \
io.openshift.tags="python,python310" \
name="$THOTH_S2I_NAME:v$THOTH_S2I_VERSION" \
vendor="AICoE at the Office of the CTO, Red Hat Inc." \
authoritative-source-url="https://quay.io/thoth-station/s2i-thoth" \
version="$THOTH_S2I_VERSION" \
release="0" \
ninja.thoth-station.version="0.7.0-dev" \
maintainer="Thoth Station <[email protected]>"

USER 0
COPY ./s2i_assemble.patch /tmp/s2i_assemble.patch
COPY ./requirements.txt $HOME/requirements.txt
RUN TMPFILE=$(mktemp) && \
TMPFILE_ASSEMBLE=$(mktemp) && \
pushd "${STI_SCRIPTS_PATH}" && patch -p 1 </tmp/s2i_assemble.patch && popd && \
pip3 --no-cache-dir --disable-pip-version-check install -U "pip==20.3.3" && \
/usr/bin/pip3 --no-cache-dir --disable-pip-version-check install -U "pip==20.3.3" && echo "$TMPFILE_ASSEMBLE" && \
curl https://raw.githubusercontent.com/thoth-station/micropipenv/master/micropipenv.py | MICROPIPENV_NO_LOCKFILE_WRITE=1 MICROPIPENV_PIP_BIN=/usr/bin/pip3 /usr/bin/python3 - install -- && \
curl "https://raw.githubusercontent.com/thoth-station/s2i-thoth/master/assemble" -o "${TMPFILE_ASSEMBLE}" && \
cp "${STI_SCRIPTS_PATH}/assemble" "${TMPFILE}" && \
head -n1 "${TMPFILE}" >"${STI_SCRIPTS_PATH}/assemble" && \
cat "${TMPFILE_ASSEMBLE}" >>"${STI_SCRIPTS_PATH}/assemble" && \
tail -n+2 "${TMPFILE}" >>"${STI_SCRIPTS_PATH}/assemble" && \
rm "${TMPFILE}" "${TMPFILE_ASSEMBLE}" /tmp/s2i_assemble.patch requirements.txt && \
sed -i '/ echo "---> Running application from .*/d' "${STI_SCRIPTS_PATH}/run" && \
chown -R 1001:0 ${APP_ROOT} && \
fix-permissions ${APP_ROOT} -P

USER 1001
2 changes: 2 additions & 0 deletions f35-py310/requirements.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
thamos
micropipenv[toml]
Loading

0 comments on commit d1d3410

Please sign in to comment.