Skip to content

Commit d01985d

Browse files
andyatmiamijiridanek
authored andcommitted
feat(containers): Remove reliance on "chained builds" architecture for rhel9 image builds
This work is a continuation of changes originally implemented in `opendatahub-io/notebooks` under opendatahub-io#924. The `red-hat-data-services/notebooks` repo has some functional differences related to the `rstudio` images which necessitates additional changes: - `rhel9` builder image is used (instead of `c9s`) - `BuildConfig` manifest is used to build the image (due to reliance on `subscription-manager`) (instead of naive `Makefile` / container build) Commit contains following changes: - Refactors all `rhel9` `rstudio` `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/rhel9-python-3.11` directory removed as its no longer relevant/required - Makefile updated to remove outdated `base-rhel9-python-3.9` target - `ENV` directive in `Dockerfile` now properly uses `=` (vs. whitespace) - `rstudio` `BuildConfig` manifests updated to accomodate changes outlined above - `Dockerfile.xxx` reference - No chained build - For `BuildConfig` manifest - this means removing the `from` attribute from `dockerStrategy`
1 parent 71d28e4 commit d01985d

File tree

8 files changed

+390
-179
lines changed

8 files changed

+390
-179
lines changed

cuda/rhel9-python-3.11/Dockerfile

Lines changed: 0 additions & 155 deletions
This file was deleted.

manifests/base/cuda-rstudio-buildconfig.yaml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,8 @@ spec:
5858
strategy:
5959
type: Docker
6060
dockerStrategy:
61-
dockerfilePath: "cuda/rhel9-python-3.11/Dockerfile"
61+
dockerfilePath: "rstudio/rhel9-python-3.11/Dockerfile.cuda"
6262
noCache: true
63-
from:
64-
kind: "DockerImage"
65-
name: "quay.io/modh/odh-base-rhel9@sha256:1d6f2e3c0ee7962d92c3b933f3bbfabeee24d314a2ce5f8ec2d9f18d5b6723d4"
6663
volumes:
6764
- name: secret-mvn
6865
source:
@@ -106,7 +103,7 @@ spec:
106103
strategy:
107104
type: Docker
108105
dockerStrategy:
109-
dockerfilePath: "rstudio/rhel9-python-3.11/Dockerfile"
106+
dockerfilePath: "rstudio/rhel9-python-3.11/Dockerfile.cuda"
110107
noCache: true
111108
from:
112109
kind: "ImageStreamTag"

manifests/base/rstudio-buildconfig.yaml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,7 @@ spec:
4343
strategy:
4444
type: Docker
4545
dockerStrategy:
46-
from:
47-
kind: "DockerImage"
48-
name: "quay.io/modh/odh-base-rhel9@sha256:1d6f2e3c0ee7962d92c3b933f3bbfabeee24d314a2ce5f8ec2d9f18d5b6723d4"
49-
dockerfilePath: "rstudio/rhel9-python-3.11/Dockerfile"
46+
dockerfilePath: "rstudio/rhel9-python-3.11/Dockerfile.cpu"
5047
volumes:
5148
- name: secret-mvn
5249
source:

rstudio/rhel9-python-3.11/Dockerfile renamed to rstudio/rhel9-python-3.11/Dockerfile.cpu

Lines changed: 54 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,36 @@
1-
ARG BASE_IMAGE
2-
FROM ${BASE_IMAGE}
1+
#####################
2+
# base #
3+
#####################
4+
FROM registry.redhat.io/rhel9/python-311:latest AS base
35

6+
WORKDIR /opt/app-root/bin
7+
8+
# Install micropipenv to deploy packages from Pipfile.lock
9+
RUN pip install --no-cache-dir -U "micropipenv[toml]"
10+
11+
# OS Packages needs to be installed as root
12+
USER root
13+
14+
# Install usefull OS packages
15+
RUN dnf install -y mesa-libGL && dnf clean all && rm -rf /var/cache/yum
16+
17+
# Other apps and tools installed as default user
18+
USER 1001
19+
20+
# Install the oc client
21+
RUN curl -L https://mirror.openshift.com/pub/openshift-v4/x86_64/clients/ocp/stable/openshift-client-linux.tar.gz \
22+
-o /tmp/openshift-client-linux.tar.gz && \
23+
tar -xzvf /tmp/openshift-client-linux.tar.gz oc && \
24+
rm -f /tmp/openshift-client-linux.tar.gz
25+
26+
WORKDIR /opt/app-root/src
27+
28+
#####################
29+
# rstudio #
30+
#####################
31+
FROM base AS rstudio
32+
33+
ARG RSTUDIO_SOURCE_CODE=rstudio/rhel9-python-3.11
434
# Access the client's secret for the subscription manager from the environment variable
535
ARG SECRET_DIR=/opt/app-root/src/.sec
636
ARG SERVERURL_DEFAULT=""
@@ -18,7 +48,7 @@ LABEL name="odh-notebook-rstudio-server-rhel9-python-3.11" \
1848

1949
USER 0
2050

21-
# uncomment the bellow line if you fall on this error: subscription-manager is disabled when running inside a container. Please refer to your host system for subscription management.
51+
# uncomment the below line if you fall on this error: subscription-manager is disabled when running inside a container. Please refer to your host system for subscription management.
2252
#RUN sed -i 's/\(def in_container():\)/\1\n return False/g' /usr/lib64/python*/*-packages/rhsm/config.py
2353

2454
# Run the subscription manager command using the provided credentials. Only include --serverurl and --baseurl if they are provided
@@ -49,11 +79,11 @@ RUN yum install -y yum-utils && \
4979

5080
# set R library to default (used in install.r from littler)
5181
RUN chmod -R a+w /usr/lib64/R/library
52-
ENV LIBLOC /usr/lib64/R/library
82+
ENV LIBLOC=/usr/lib64/R/library
5383

5484
# set User R Library path
5585
RUN mkdir -p /opt/app-root/bin/Rpackages/4.4 && chmod -R a+w /opt/app-root/bin/Rpackages/4.4
56-
ENV R_LIBS_USER /opt/app-root/bin/Rpackages/4.4
86+
ENV R_LIBS_USER=/opt/app-root/bin/Rpackages/4.4
5787

5888
WORKDIR /tmp/
5989

@@ -66,7 +96,7 @@ RUN wget --progress=dot:giga https://download2.rstudio.org/server/rhel9/x86_64/r
6696
# Specific RStudio config and fixes
6797
RUN chmod 1777 /var/run/rstudio-server && \
6898
mkdir -p /usr/share/doc/R
69-
COPY rstudio/rhel9-python-3.11/rsession.conf /etc/rstudio/rsession.conf
99+
COPY ${RSTUDIO_SOURCE_CODE}/rsession.conf /etc/rstudio/rsession.conf
70100

71101
# package installation
72102
# install necessary texlive-framed package to make Knit R markup to PDF rendering possible
@@ -94,10 +124,10 @@ RUN yum -y module enable nginx:$NGINX_VERSION && \
94124
nginx -v 2>&1 | grep -qe "nginx/$NGINX_VERSION\." && echo "Found VERSION $NGINX_VERSION" && \
95125
yum -y clean all --enablerepo='*'
96126

97-
COPY --chown=1001:0 rstudio/rhel9-python-3.11/supervisord/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
127+
COPY --chown=1001:0 ${RSTUDIO_SOURCE_CODE}/supervisord/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
98128

99129
# Copy extra files to the image.
100-
COPY rstudio/rhel9-python-3.11/nginx/root/ /
130+
COPY ${RSTUDIO_SOURCE_CODE}/nginx/root/ /
101131

102132
# Changing ownership and user rights to support following use-cases:
103133
# 1) running container on OpenShift, whose default security model
@@ -128,21 +158,30 @@ RUN sed -i -f ${NGINX_APP_ROOT}/nginxconf.sed ${NGINX_CONF_PATH} && \
128158
rpm-file-permissions
129159

130160
# Configure nginx
131-
COPY rstudio/rhel9-python-3.11/nginx/serverconf/ /opt/app-root/etc/nginx.default.d/
132-
COPY rstudio/rhel9-python-3.11/nginx/httpconf/ /opt/app-root/etc/nginx.d/
133-
COPY rstudio/rhel9-python-3.11/nginx/api/ /opt/app-root/api/
161+
COPY ${RSTUDIO_SOURCE_CODE}/nginx/serverconf/ /opt/app-root/etc/nginx.default.d/
162+
COPY ${RSTUDIO_SOURCE_CODE}/nginx/httpconf/ /opt/app-root/etc/nginx.d/
163+
COPY ${RSTUDIO_SOURCE_CODE}/nginx/api/ /opt/app-root/api/
134164

135165
# Launcher
136166
WORKDIR /opt/app-root/bin
137167

138-
COPY rstudio/rhel9-python-3.11/utils utils/
139-
COPY rstudio/rhel9-python-3.11/run-rstudio.sh rstudio/rhel9-python-3.11/setup_rstudio.py rstudio/rhel9-python-3.11/rsession.sh rstudio/rhel9-python-3.11/run-nginx.sh ./
168+
COPY ${RSTUDIO_SOURCE_CODE}/utils utils/
169+
COPY ${RSTUDIO_SOURCE_CODE}/run-rstudio.sh ${RSTUDIO_SOURCE_CODE}/setup_rstudio.py ${RSTUDIO_SOURCE_CODE}/rsession.sh ${RSTUDIO_SOURCE_CODE}/run-nginx.sh ./
140170

141171
# Unregister the system
142172
RUN subscription-manager remove --all && subscription-manager unregister && subscription-manager clean
143173

144-
WORKDIR /opt/app-root/src
145-
146174
USER 1001
147175

176+
COPY ${RSTUDIO_SOURCE_CODE}/Pipfile.lock ./
177+
178+
RUN echo "Installing softwares and packages" && \
179+
micropipenv install && \
180+
rm -f ./Pipfile.lock && \
181+
# Fix permissions to support pip in Openshift environments \
182+
chmod -R g+w /opt/app-root/lib/python3.11/site-packages && \
183+
fix-permissions /opt/app-root -P
184+
185+
WORKDIR /opt/app-root/src
186+
148187
CMD ["/opt/app-root/bin/run-rstudio.sh"]

0 commit comments

Comments
 (0)