Skip to content
257 changes: 91 additions & 166 deletions rstudio/c9s-python-3.11/Dockerfile.cpu
Original file line number Diff line number Diff line change
@@ -1,172 +1,97 @@
#####################
# base #
#####################
FROM quay.io/sclorg/python-311-c9s:c9s AS base

WORKDIR /opt/app-root/bin

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

# OS Packages needs to be installed as root
USER root

# Install useful OS packages
RUN dnf install -y mesa-libGL skopeo && dnf clean all && rm -rf /var/cache/yum

# Other apps and tools installed as default user
USER 1001

# 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

WORKDIR /opt/app-root/src

#####################
# rstudio #
#####################
FROM base AS rstudio

ARG RSTUDIO_SOURCE_CODE=rstudio/c9s-python-3.11

WORKDIR /opt/app-root/bin

LABEL name="odh-notebook-rstudio-server-c9s-python-3.11" \
summary="RStudio Server image with python 3.11 based on CentOS Stream 9" \
description="RStudio server image with python 3.11 based on CentOS Stream 9" \
io.k8s.display-name="RStudio server image with python 3.11 based on CentOS Stream 9" \
io.k8s.description="RStudio server image with python 3.11 based on CentOS Stream 9" \
authoritative-source-url="https://github.com/opendatahub-io/notebooks" \
io.openshift.build.commit.ref="main" \
io.openshift.build.source-location="https://github.com/opendatahub-io/notebooks/tree/main/rstudio/c9s-python-3.11" \
io.openshift.build.image="quay.io/opendatahub/workbench-images:rstudio-c9s-python-3.11"

USER 0

ENV R_VERSION=4.4.3

# Install R
RUN yum install -y yum-utils && \
yum-config-manager --enable crb && \
yum install -y https://download.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm && \
INSTALL_PKGS="R-core R-core-devel R-java R-Rcpp R-highlight \
R-littler R-littler-examples openssl-libs compat-openssl11" && \
yum install -y --setopt=tsflags=nodocs $INSTALL_PKGS && \
echo 'options(repos = c(CRAN = "https://cran.rstudio.com/"), download.file.method = "libcurl")' >> /usr/lib64/R/etc/Rprofile.site && \
(umask 002;touch /usr/lib64/R/etc/Renviron.site) && \
yum -y clean all --enablerepo='*'

# set R library to default (used in install.r from littler)
ENV LIBLOC=/usr/lib64/R/library
ENV R_LIBS_USER=/opt/app-root/bin/Rpackages/4.4

RUN chmod -R a+w ${LIBLOC} && \
# create User R Library path
mkdir -p ${R_LIBS_USER} && \
chmod -R a+w ${R_LIBS_USER}

WORKDIR /tmp/

# Install RStudio
ARG RSTUDIO_RPM=rstudio-server-rhel-2024.12.1-563-x86_64.rpm
RUN wget --progress=dot:giga https://download2.rstudio.org/server/rhel8/x86_64/${RSTUDIO_RPM} && \
yum install -y ${RSTUDIO_RPM} && \
rm ${RSTUDIO_RPM} && \
yum -y clean all --enablerepo='*' && \
# Specific RStudio config and fixes
chmod 1777 /var/run/rstudio-server && \
mkdir -p /usr/share/doc/R && \
# package installation
# install necessary texlive-framed package to make Knit R markup to PDF rendering possible
dnf install -y libsodium-devel.x86_64 libgit2-devel.x86_64 libcurl-devel harfbuzz-devel.x86_64 fribidi-devel.x86_64 cmake "flexiblas-*" texlive-framed && \
dnf clean all && \
rm -rf /var/cache/yum























































































COPY ${RSTUDIO_SOURCE_CODE}/rsession.conf /etc/rstudio/rsession.conf

# Install R packages
ENV MAKEFLAGS="-j2"
ENV MAKEFLAGS="-j2"
ENV MAKEFLAGS="-j2"
ENV MAKEFLAGS="-j2"
# https://cran.r-project.org/web/packages
COPY ${RSTUDIO_SOURCE_CODE}/install_packages.R ./
RUN R -f ./install_packages.R && \
rm ./install_packages.R

# Install NGINX to proxy RStudio and pass probes check
ENV NGINX_VERSION=1.24 \
NGINX_SHORT_VER=124 \
NGINX_CONFIGURATION_PATH=${APP_ROOT}/etc/nginx.d \
NGINX_CONF_PATH=/etc/nginx/nginx.conf \
NGINX_DEFAULT_CONF_PATH=${APP_ROOT}/etc/nginx.default.d \
NGINX_CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/nginx \
NGINX_APP_ROOT=${APP_ROOT} \
NGINX_LOG_PATH=/var/log/nginx \
NGINX_PERL_MODULE_PATH=${APP_ROOT}/etc/perl

# Modules does not exist
RUN yum -y module enable nginx:$NGINX_VERSION && \
INSTALL_PKGS="nss_wrapper bind-utils gettext hostname nginx nginx-mod-stream nginx-mod-http-perl fcgiwrap initscripts chkconfig supervisor" && \
yum install -y --setopt=tsflags=nodocs $INSTALL_PKGS && \
rpm -V $INSTALL_PKGS && \
nginx -v 2>&1 | grep -qe "nginx/$NGINX_VERSION\." && echo "Found VERSION $NGINX_VERSION" && \
yum -y clean all --enablerepo='*'

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

# Copy extra files to the image.
COPY --chown=1001:0 ${RSTUDIO_SOURCE_CODE}/nginx/root/ /

# Changing ownership and user rights to support following use-cases:
# 1) running container on OpenShift, whose default security model
# is to run the container under random UID, but GID=0
# 2) for working root-less container with UID=1001, which does not have
# to have GID=0
# 3) for default use-case, that is running container directly on operating system,
# with default UID and GID (1001:0)
# Supported combinations of UID:GID are thus following:
# UID=1001 && GID=0
# UID=<any>&& GID=0
# UID=1001 && GID=<any>
RUN sed -i -f ${NGINX_APP_ROOT}/nginxconf.sed ${NGINX_CONF_PATH} && \
mkdir -p ${NGINX_APP_ROOT}/etc/nginx.d/ && \
mkdir -p ${NGINX_APP_ROOT}/etc/nginx.default.d/ && \
mkdir -p ${NGINX_APP_ROOT}/api/ && \
mkdir -p ${NGINX_CONTAINER_SCRIPTS_PATH}/nginx-start && \
mkdir -p ${NGINX_LOG_PATH} && \
mkdir -p ${NGINX_PERL_MODULE_PATH} && \
chown -R 1001:0 ${NGINX_CONF_PATH} && \
chown -R 1001:0 ${NGINX_APP_ROOT}/etc && \
chown -R 1001:0 ${NGINX_CONTAINER_SCRIPTS_PATH}/nginx-start && \
chown -R 1001:0 /var/lib/nginx /var/log/nginx /run && \
chmod ug+rw ${NGINX_CONF_PATH} && \
chmod -R ug+rwX ${NGINX_APP_ROOT}/etc && \
chmod -R ug+rwX ${NGINX_CONTAINER_SCRIPTS_PATH}/nginx-start && \
chmod -R ug+rwX /var/lib/nginx /var/log/nginx /run && \
rpm-file-permissions

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

# Launcher
WORKDIR /opt/app-root/bin

COPY ${RSTUDIO_SOURCE_CODE}/utils utils/
COPY ${RSTUDIO_SOURCE_CODE}/run-rstudio.sh ${RSTUDIO_SOURCE_CODE}/setup_rstudio.py ${RSTUDIO_SOURCE_CODE}/rsession.sh ${RSTUDIO_SOURCE_CODE}/run-nginx.sh ./

USER 1001

COPY ${RSTUDIO_SOURCE_CODE}/Pipfile.lock ./

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.11/site-packages && \
fix-permissions /opt/app-root -P

WORKDIR /opt/app-root/src

CMD ["/opt/app-root/bin/run-rstudio.sh"]
RUN R -f ./install_packages.R && \
Loading
Loading