Skip to content

Commit

Permalink
feat(containers): Remove reliance on chained builds
Browse files Browse the repository at this point in the history
**warning: this is only a partial change with 2024a changes included to solicit initial feedback on approach**

Commit contains following changes:

- Refactors all `Dockerfile`s to to be "self-contained" - not rely on any "build chains" for internal images
    - please note in the final form of this PR - many intermediate stages will be combined... this current form makes it easier to understand how the `Dockerfile`s present in the "build chain" are being combined
        - long term - we'd expect the following stages: `base`, `base-<accelerator>` (if applicable), `<final>`
- `Dockerfile` file now has a file extension/suffix that indicates CPU or accelerator
- `LABEL` directives now should be consistent/accurate
    - this probably needs a little more attention
- `base/` directory removed as its no longer relevant/required
- Makefile updated to handle support better across releases
    - _read: MOWR variables_
- `wheel` / `setuptools` explicitly added to `runtime-` images `Pipfile`
- `pytorch` `Makefile` targets now contain `cuda-` prefix
- `ENV` directive in `Dockerfile` now properly uses `=` (vs. whitespace)
- change in `buildinputs` to pull file paths from the terminal layer
    - this change particularly needs refined - but its "crude yet effective" in its current form

Related-to: https://issues.redhat.com/browse/RHOAIENG-19048
  • Loading branch information
andyatmiami committed Feb 19, 2025
1 parent 5888b6c commit 5a8e91e
Show file tree
Hide file tree
Showing 54 changed files with 2,185 additions and 16,438 deletions.
40 changes: 0 additions & 40 deletions 2024a/base/c9s-python-3.9/Dockerfile

This file was deleted.

12 changes: 0 additions & 12 deletions 2024a/base/c9s-python-3.9/requirements.txt

This file was deleted.

42 changes: 0 additions & 42 deletions 2024a/base/ubi9-python-3.9/Dockerfile

This file was deleted.

14 changes: 0 additions & 14 deletions 2024a/base/ubi9-python-3.9/Pipfile

This file was deleted.

39 changes: 0 additions & 39 deletions 2024a/base/ubi9-python-3.9/Pipfile.lock

This file was deleted.

12 changes: 0 additions & 12 deletions 2024a/base/ubi9-python-3.9/requirements.txt

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,35 @@
ARG BASE_IMAGE
FROM ${BASE_IMAGE}

####################
# base #
####################
FROM registry.access.redhat.com/ubi9/python-39:latest AS base

WORKDIR /opt/app-root/bin

# 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

# Other apps and tools installed as default user
USER 1001

# Install micropipenv to deploy packages from Pipfile.lock
RUN pip install --no-cache-dir -U "micropipenv[toml]"

# Install the oc client
RUN curl -L https://mirror.openshift.com/pub/openshift-v4/$(uname -m)/clients/ocp/stable/openshift-client-linux.tar.gz \
-o /tmp/openshift-client-linux.tar.gz && \
tar -xzvf /tmp/openshift-client-linux.tar.gz oc && \
rm -f /tmp/openshift-client-linux.tar.gz

####################
# codeserver #
####################
FROM base AS codeserver

ARG CODESERVER_SOURCE_CODE=codeserver/ubi9-python-3.9
ARG CODESERVER_VERSION=v4.22.0

LABEL name="odh-notebook-code-server-ubi9-python-3.9" \
Expand All @@ -17,16 +46,6 @@ USER 0

WORKDIR /opt/app-root/bin

# Install usefull packages from Pipfile.lock
COPY Pipfile.lock ./

# Install packages and cleanup
RUN echo "Installing softwares and packages" && \
micropipenv install && \
rm -f ./Pipfile.lock && \
# Fix permissions to support pip in Openshift environments \
chmod -R g+w /opt/app-root/lib/python3.9/site-packages && \
fix-permissions /opt/app-root -P

# Install usefull OS packages
RUN dnf install -y jq git-lfs libsndfile && dnf clean all && rm -rf /var/cache/yum
Expand All @@ -35,11 +54,7 @@ RUN dnf install -y jq git-lfs libsndfile && dnf clean all && rm -rf /var/cache/y
RUN yum install -y "https://github.com/coder/code-server/releases/download/${CODESERVER_VERSION}/code-server-${CODESERVER_VERSION/v/}-amd64.rpm" && \
yum -y clean all --enablerepo='*'

# Change ownership of relevant directories
RUN chmod -R g+w /opt/app-root/lib/python3.9/site-packages && \
fix-permissions /opt/app-root -P

COPY --chown=1001:0 utils utils/
COPY --chown=1001:0 ${CODESERVER_SOURCE_CODE}/utils utils/

# Create and intall the extensions though build-time on a temporary directory. Later this directory will copied on the `/opt/app-root/src/.local/share/code-server/extensions` via run-code-server.sh file when it starts up.
RUN mkdir -p /opt/app-root/extensions-temp && \
Expand All @@ -65,10 +80,10 @@ RUN yum install -y https://download.fedoraproject.org/pub/epel/epel-release-late
rpm -V $INSTALL_PKGS && \
yum -y clean all --enablerepo='*'

COPY --chown=1001:0 supervisord/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
COPY --chown=1001:0 ${CODESERVER_SOURCE_CODE}/supervisord/supervisord.conf /etc/supervisor/conf.d/supervisord.conf

# Copy extra files to the image.
COPY nginx/root/ /
COPY ${CODESERVER_SOURCE_CODE}/nginx/root/ /

# Changing ownership and user rights to support following use-cases:
# 1) running container on OpenShift, whose default security model
Expand Down Expand Up @@ -105,19 +120,30 @@ RUN sed -i -f ${NGINX_APP_ROOT}/nginxconf.sed ${NGINX_CONF_PATH} && \
chown -R 1001:0 /opt/app-root/src/.config/code-server

## Configure nginx
COPY nginx/serverconf/ /opt/app-root/etc/nginx.default.d/
COPY nginx/httpconf/ /opt/app-root/etc/nginx.d/
COPY nginx/api/ /opt/app-root/api/
COPY ${CODESERVER_SOURCE_CODE}/nginx/serverconf/ /opt/app-root/etc/nginx.default.d/
COPY ${CODESERVER_SOURCE_CODE}/nginx/httpconf/ /opt/app-root/etc/nginx.d/
COPY ${CODESERVER_SOURCE_CODE}/nginx/api/ /opt/app-root/api/

# Launcher
COPY --chown=1001:0 run-code-server.sh run-nginx.sh ./
COPY --chown=1001:0 ${CODESERVER_SOURCE_CODE}/run-code-server.sh ${CODESERVER_SOURCE_CODE}/run-nginx.sh ./

ENV SHELL /bin/bash
ENV SHELL=/bin/bash

ENV PYTHONPATH=/opt/app-root/bin/python3

WORKDIR /opt/app-root/src

USER 1001


# Install usefull packages from Pipfile.lock
COPY ${CODESERVER_SOURCE_CODE}/Pipfile.lock ./

# Install packages and cleanup
RUN echo "Installing softwares and packages" && \
micropipenv install && \
rm -f ./Pipfile.lock && \
# Fix permissions to support pip in Openshift environments \
chmod -R g+w /opt/app-root/lib/python3.9/site-packages && \
fix-permissions /opt/app-root -P

WORKDIR /opt/app-root/src
CMD ["/opt/app-root/bin/run-code-server.sh"]
Loading

0 comments on commit 5a8e91e

Please sign in to comment.