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

RHOAIENG-10350 feat(Dockerfiles): switch from s2i python images to plain ubi/c9s bases #641

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open
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
25 changes: 23 additions & 2 deletions base/c9s-python-3.11/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,21 @@
FROM quay.io/sclorg/python-311-c9s:c9s
FROM quay.io/centos/centos:stream9

# perform the setup that python image used to do for us
# but this way it uses a lot less disk space (hundreds of megabytes less)
ENV APP_ROOT="/opt/app-root"
ENV HOME="${APP_ROOT}/src"
ENV VIRTUAL_ENV="${APP_ROOT}"
ENV PATH="${VIRTUAL_ENV}/bin:${PATH}"
ENV PYTHON_VERSION=3.11
ENV PIP_NO_CACHE_DIR=off
RUN mkdir --parents "${HOME}" && chmod --recursive 0771 ${APP_ROOT} && chown --recursive 1001:0 ${APP_ROOT} && \
useradd --uid 1001 --gid 0 --no-create-home --home-dir "${HOME}" \
--comment "Default Application User" --shell /bin/bash default && \
dnf install -y python${PYTHON_VERSION}-pip && dnf clean all && rm -rf /var/cache/yum/*
COPY --from=quay.io/sclorg/s2i-core-c9s:latest /usr/bin/fix-permissions /usr/bin/rpm-file-permissions /usr/bin/

USER 1001
RUN python${PYTHON_VERSION} -m venv "${VIRTUAL_ENV}"

LABEL name="odh-notebook-base-centos-stream9-python-3.11" \
summary="Python 3.11 CentOS Stream 9 base image for ODH notebooks" \
Expand All @@ -22,7 +39,11 @@ COPY Pipfile.lock ./
USER root

# Install usefull OS packages
RUN dnf install -y mesa-libGL && dnf clean all && rm -rf /var/cache/yum
RUN dnf install -y \
mesa-libGL \
patch \
wget \
&& dnf clean all && rm -rf /var/cache/yum

# Other apps and tools installed as default user
USER 1001
Expand Down
27 changes: 24 additions & 3 deletions base/c9s-python-3.9/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,21 @@
FROM quay.io/sclorg/python-39-c9s:c9s
FROM quay.io/centos/centos:stream9

# perform the setup that python image used to do for us
# but this way it uses a lot less disk space (hundreds of megabytes less)
ENV APP_ROOT="/opt/app-root"
ENV HOME="${APP_ROOT}/src"
ENV VIRTUAL_ENV="${APP_ROOT}"
ENV PATH="${VIRTUAL_ENV}/bin:${PATH}"
ENV PYTHON_VERSION=3.9
ENV PIP_NO_CACHE_DIR=off
RUN mkdir --parents "${HOME}" && chmod --recursive 0771 ${APP_ROOT} && chown --recursive 1001:0 ${APP_ROOT} && \
useradd --uid 1001 --gid 0 --no-create-home --home-dir "${HOME}" \
--comment "Default Application User" --shell /bin/bash default && \
dnf install -y python3-pip && dnf clean all && rm -rf /var/cache/yum/*
COPY --from=quay.io/sclorg/s2i-core-c9s:latest /usr/bin/fix-permissions /usr/bin/rpm-file-permissions /usr/bin/

USER 1001
RUN python${PYTHON_VERSION} -m venv "${VIRTUAL_ENV}"

LABEL name="odh-notebook-base-centos-stream9-python-3.9" \
summary="Python 3.9 CentOS Stream 9 base image for ODH notebooks" \
Expand All @@ -22,7 +39,11 @@ COPY Pipfile.lock ./
USER root

# Install usefull OS packages
RUN dnf install -y mesa-libGL && dnf clean all && rm -rf /var/cache/yum
RUN dnf install -y \
mesa-libGL \
patch \
wget \
&& dnf clean all && rm -rf /var/cache/yum

# Other apps and tools installed as default user
USER 1001
Expand All @@ -34,7 +55,7 @@ RUN echo "Installing softwares and packages" && micropipenv install && rm -f ./P
tar -xzvf /tmp/openshift-client-linux.tar.gz oc && \
rm -f /tmp/openshift-client-linux.tar.gz && \
# Fix permissions to support pip in Openshift environments \
chmod -R g+w /opt/app-root/lib/python3.9/site-packages && \
chmod -R g+w /opt/app-root/lib/python${PYTHON_VERSION}/site-packages && \
fix-permissions /opt/app-root -P

WORKDIR /opt/app-root/src
29 changes: 25 additions & 4 deletions base/ubi9-python-3.11/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,21 @@
FROM registry.access.redhat.com/ubi9/python-311:latest
FROM registry.access.redhat.com/ubi9/ubi:latest

# perform the setup that python s2i image used to do for us
# but this way it uses a lot less disk space (hundreds of megabytes less)
ENV APP_ROOT="/opt/app-root"
ENV HOME="${APP_ROOT}/src"
ENV VIRTUAL_ENV="${APP_ROOT}"
ENV PATH="${VIRTUAL_ENV}/bin:${PATH}"
ENV PYTHON_VERSION=3.11
ENV PIP_NO_CACHE_DIR=off
RUN mkdir --parents "${HOME}" && chmod --recursive 0771 ${APP_ROOT} && chown --recursive 1001:0 ${APP_ROOT} && \
useradd --uid 1001 --gid 0 --no-create-home --home-dir "${HOME}" \
--comment "Default Application User" --shell /bin/bash default && \
dnf install -y python${PYTHON_VERSION}-pip && dnf clean all && rm -rf /var/cache/yum/*
COPY --from=quay.io/sclorg/s2i-core-c9s:latest /usr/bin/fix-permissions /usr/bin/rpm-file-permissions /usr/bin/

USER 1001
RUN python${PYTHON_VERSION} -m venv "${VIRTUAL_ENV}"

LABEL name="odh-notebook-base-ubi9-python-3.11" \
summary="Python 3.11 base image for ODH notebooks" \
Expand All @@ -18,13 +35,17 @@ RUN pip install --no-cache-dir -U "micropipenv[toml]"
# Install Python dependencies from Pipfile.lock file
COPY Pipfile.lock ./

RUN echo "Installing softwares and packages" && micropipenv install && rm -f ./Pipfile.lock
RUN echo "Installing software and packages" && micropipenv install && rm -f ./Pipfile.lock

# OS Packages needs to be installed as root
USER root

# Install usefull OS packages
RUN dnf install -y mesa-libGL && dnf clean all && rm -rf /var/cache/yum
RUN dnf install -y \
mesa-libGL \
patch \
wget \
&& dnf clean all && rm -rf /var/cache/yum

# Other apps and tools installed as default user
USER 1001
Expand All @@ -36,7 +57,7 @@ RUN curl -L https://mirror.openshift.com/pub/openshift-v4/$(uname -m)/clients/oc
rm -f /tmp/openshift-client-linux.tar.gz

# Fix permissions to support pip in Openshift environments
RUN chmod -R g+w /opt/app-root/lib/python3.11/site-packages && \
RUN chmod -R g+w /opt/app-root/lib/python${PYTHON_VERSION}/site-packages && \
fix-permissions /opt/app-root -P

WORKDIR /opt/app-root/src
29 changes: 25 additions & 4 deletions base/ubi9-python-3.9/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,21 @@
FROM registry.access.redhat.com/ubi9/python-39:latest
FROM registry.access.redhat.com/ubi9/ubi:latest

# perform the setup that python s2i image used to do for us
# but this way it uses a lot less disk space (hundreds of megabytes less)
ENV APP_ROOT="/opt/app-root"
ENV HOME="${APP_ROOT}/src"
ENV VIRTUAL_ENV="${APP_ROOT}"
ENV PATH="${VIRTUAL_ENV}/bin:${PATH}"
ENV PYTHON_VERSION=3.9
ENV PIP_NO_CACHE_DIR=off
RUN mkdir --parents "${HOME}" && chmod --recursive 0771 ${APP_ROOT} && chown --recursive 1001:0 ${APP_ROOT} && \
useradd --uid 1001 --gid 0 --no-create-home --home-dir "${HOME}" \
--comment "Default Application User" --shell /bin/bash default && \
dnf install -y python3-pip && dnf clean all && rm -rf /var/cache/yum/*
COPY --from=quay.io/sclorg/s2i-core-c9s:latest /usr/bin/fix-permissions /usr/bin/rpm-file-permissions /usr/bin/

USER 1001
RUN python${PYTHON_VERSION} -m venv "${VIRTUAL_ENV}"

LABEL name="odh-notebook-base-ubi9-python-3.9" \
summary="Python 3.9 base image for ODH notebooks" \
Expand All @@ -18,13 +35,17 @@ RUN pip install --no-cache-dir -U "micropipenv[toml]"
# Install Python dependencies from Pipfile.lock file
COPY Pipfile.lock ./

RUN echo "Installing softwares and packages" && micropipenv install && rm -f ./Pipfile.lock
RUN echo "Installing software and packages" && micropipenv install && rm -f ./Pipfile.lock

# OS Packages needs to be installed as root
USER root

# Install usefull OS packages
RUN dnf install -y mesa-libGL && dnf clean all && rm -rf /var/cache/yum
RUN dnf install -y \
mesa-libGL \
patch \
wget \
&& dnf clean all && rm -rf /var/cache/yum

# Other apps and tools installed as default user
USER 1001
Expand All @@ -36,7 +57,7 @@ RUN curl -L https://mirror.openshift.com/pub/openshift-v4/$(uname -m)/clients/oc
rm -f /tmp/openshift-client-linux.tar.gz

# Fix permissions to support pip in Openshift environments
RUN chmod -R g+w /opt/app-root/lib/python3.9/site-packages && \
RUN chmod -R g+w /opt/app-root/lib/python${PYTHON_VERSION}/site-packages && \
fix-permissions /opt/app-root -P

WORKDIR /opt/app-root/src