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
535ARG SECRET_DIR=/opt/app-root/src/.sec
636ARG SERVERURL_DEFAULT=""
@@ -18,7 +48,7 @@ LABEL name="odh-notebook-rstudio-server-rhel9-python-3.11" \
1848
1949USER 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)
5181RUN 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
5585RUN 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
5888WORKDIR /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
6797RUN 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
136166WORKDIR /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
142172RUN subscription-manager remove --all && subscription-manager unregister && subscription-manager clean
143173
144- WORKDIR /opt/app-root/src
145-
146174USER 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+
148187CMD ["/opt/app-root/bin/run-rstudio.sh"]
0 commit comments