Skip to content
Closed
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
29 changes: 20 additions & 9 deletions rstudio/c9s-python-3.11/Dockerfile.cpu
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ USER 1001
WORKDIR /opt/app-root/src

#####################
# rstudio #
# rstudio #
#####################
FROM cpu-base AS rstudio

Expand Down Expand Up @@ -105,7 +105,8 @@ RUN R -f ./install_packages.R && \
rm ./install_packages.R

# Install NGINX to proxy RStudio and pass probes check
ENV NGINX_VERSION=1.24 \
ENV APP_ROOT=/opt/app-root \
NGINX_VERSION=1.24 \
NGINX_SHORT_VER=124 \
NGINX_CONFIGURATION_PATH=${APP_ROOT}/etc/nginx.d \
NGINX_CONF_PATH=/etc/nginx/nginx.conf \
Expand All @@ -117,17 +118,24 @@ ENV NGINX_VERSION=1.24 \

# Modules does not exist
RUN dnf -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" && \
INSTALL_PKGS="nss_wrapper bind-utils gettext hostname nginx nginx-mod-stream nginx-mod-http-perl httpd" && \
dnf 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" && \
dnf -y clean all --enablerepo='*'

COPY --chown=1001:0 ${RSTUDIO_SOURCE_CODE}/supervisord/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
# Configure httpd for CGI processing
COPY --chown=1001:0 ${RSTUDIO_SOURCE_CODE}/httpd/httpd.conf /etc/httpd/conf/httpd.conf
COPY --chown=1001:0 ${RSTUDIO_SOURCE_CODE}/httpd/rstudio-cgi.conf /etc/httpd/conf.d/rstudio-cgi.conf

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

# 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/

# 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
Expand All @@ -146,21 +154,24 @@ RUN sed -i -f ${NGINX_APP_ROOT}/nginxconf.sed ${NGINX_CONF_PATH} && \
mkdir -p ${NGINX_CONTAINER_SCRIPTS_PATH}/nginx-start && \
mkdir -p ${NGINX_LOG_PATH} && \
mkdir -p ${NGINX_PERL_MODULE_PATH} && \
# Create httpd directories and set permissions
mkdir -p /var/log/httpd /var/run/httpd /etc/httpd/logs && \
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 && \
chown -R 1001:0 /var/log/httpd /var/run/httpd /etc/httpd/logs && \
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 && \
chmod -R ug+rwX /var/log/httpd /var/run/httpd /etc/httpd/logs && \
# Make CGI scripts executable and set proper ownership
chmod +x /opt/app-root/api/kernels/access.cgi && \
chmod +x /opt/app-root/api/probe.cgi && \
chown -R 1001:0 /opt/app-root/api && \
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

Expand Down
27 changes: 19 additions & 8 deletions rstudio/c9s-python-3.11/Dockerfile.cuda
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ RUN R -f ./install_packages.R && \
rm ./install_packages.R

# Install NGINX to proxy RStudio and pass probes check
ENV NGINX_VERSION=1.24 \
ENV APP_ROOT=/opt/app-root \
NGINX_VERSION=1.24 \
NGINX_SHORT_VER=124 \
NGINX_CONFIGURATION_PATH=${APP_ROOT}/etc/nginx.d \
NGINX_CONF_PATH=/etc/nginx/nginx.conf \
Expand All @@ -119,17 +120,24 @@ ENV NGINX_VERSION=1.24 \

# Modules does not exist
RUN dnf -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" && \
INSTALL_PKGS="nss_wrapper bind-utils gettext hostname nginx nginx-mod-stream nginx-mod-http-perl httpd" && \
dnf 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" && \
dnf -y clean all --enablerepo='*'

COPY --chown=1001:0 ${RSTUDIO_SOURCE_CODE}/supervisord/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
# Configure httpd for CGI processing
COPY --chown=1001:0 ${RSTUDIO_SOURCE_CODE}/httpd/httpd.conf /etc/httpd/conf/httpd.conf
COPY --chown=1001:0 ${RSTUDIO_SOURCE_CODE}/httpd/rstudio-cgi.conf /etc/httpd/conf.d/rstudio-cgi.conf

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

# 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/

# 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
Expand All @@ -148,21 +156,24 @@ RUN sed -i -f ${NGINX_APP_ROOT}/nginxconf.sed ${NGINX_CONF_PATH} && \
mkdir -p ${NGINX_CONTAINER_SCRIPTS_PATH}/nginx-start && \
mkdir -p ${NGINX_LOG_PATH} && \
mkdir -p ${NGINX_PERL_MODULE_PATH} && \
# Create httpd directories and set permissions
mkdir -p /var/log/httpd /var/run/httpd /etc/httpd/logs && \
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 && \
chown -R 1001:0 /var/log/httpd /var/run/httpd /etc/httpd/logs && \
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 && \
chmod -R ug+rwX /var/log/httpd /var/run/httpd /etc/httpd/logs && \
# Make CGI scripts executable and set proper ownership
chmod +x /opt/app-root/api/kernels/access.cgi && \
chmod +x /opt/app-root/api/probe.cgi && \
chown -R 1001:0 /opt/app-root/api && \
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

Expand Down
54 changes: 54 additions & 0 deletions rstudio/c9s-python-3.11/httpd/httpd.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Basic httpd configuration for CGI processing
ServerRoot "/etc/httpd"
Listen 8080

# Load modules
LoadModule mpm_prefork_module modules/mod_mpm_prefork.so
LoadModule unixd_module modules/mod_unixd.so
LoadModule authz_core_module modules/mod_authz_core.so
LoadModule mime_module modules/mod_mime.so
LoadModule alias_module modules/mod_alias.so
LoadModule dir_module modules/mod_dir.so
LoadModule autoindex_module modules/mod_autoindex.so
LoadModule cgi_module modules/mod_cgi.so
LoadModule rewrite_module modules/mod_rewrite.so

# User and Group - run as the container user (OpenShift assigns random UIDs)
User default
Group root

# PidFile for process management
PidFile /var/run/httpd/httpd.pid

# Server configuration
ServerAdmin root@localhost
ServerName localhost

# Document root
DocumentRoot "/opt/app-root"

# Directory configuration
<Directory />
AllowOverride none
Require all denied
</Directory>

<Directory "/opt/app-root">
AllowOverride None
Options +ExecCGI
Require all granted
AddHandler cgi-script .cgi
</Directory>

# Error and access logs
ErrorLog "/var/log/httpd/error_log"
LogLevel warn

# Types configuration
TypesConfig /etc/mime.types

# Include additional configurations (exclude SSL)
IncludeOptional conf.d/autoindex.conf
IncludeOptional conf.d/userdir.conf
IncludeOptional conf.d/welcome.conf
IncludeOptional conf.d/rstudio-cgi.conf
27 changes: 27 additions & 0 deletions rstudio/c9s-python-3.11/httpd/rstudio-cgi.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# RStudio-server CGI configuration
# This configuration handles the /api/ endpoints for culling and health checks

# Set the CGI script paths
ScriptAlias /api/kernels/ /opt/app-root/api/kernels/access.cgi
ScriptAlias /api/probe /opt/app-root/api/probe.cgi
ScriptAlias /api /opt/app-root/api/probe.cgi

# Enable CGI for the API endpoints
<LocationMatch "^/api/?">
SetHandler cgi-script
Options +ExecCGI
Require all granted
</LocationMatch>

# Ensure the CGI scripts are executable
<Directory "/opt/app-root/api">
Options +ExecCGI
AddHandler cgi-script .cgi
Require all granted
</Directory>

<Directory "/opt/app-root/api/kernels">
Options +ExecCGI
AddHandler cgi-script .cgi
Require all granted
</Directory>
40 changes: 24 additions & 16 deletions rstudio/c9s-python-3.11/nginx/serverconf/proxy.conf.template
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,16 @@ rewrite ^/auth-sign-out(.*) "$custom_scheme://$http_host/rstudio/auth-sign-out$1
###############

###############
# api calls from probes get to CGI processing
# api calls from probes get to CGI processing via Apache
###############
location /api/ {
index probe.cgi;
fastcgi_index probe.cgi;
proxy_pass http://localhost:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
gzip off;
access_log off;
root /opt/app-root;
fastcgi_pass unix:/var/run/fcgiwrap.socket;
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_FILENAME /opt/app-root$fastcgi_script_name;
access_log off;
}

location = /api/kernels {
Expand All @@ -25,14 +24,23 @@ location = /api/kernels {
}

location /api/kernels/ {
index access.cgi;
fastcgi_index access.cgi;
gzip off;
access_log off;
root /opt/app-root;
fastcgi_pass unix:/var/run/fcgiwrap.socket;
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_FILENAME /opt/app-root$fastcgi_script_name;
proxy_pass http://localhost:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
gzip off;
access_log off;
}

location = /api/probe {
proxy_pass http://localhost:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
gzip off;
access_log off;
}
###############

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,23 @@ location ${NB_PREFIX}/api/ {
}

location /api/ {
index probe.cgi;
fastcgi_index probe.cgi;
proxy_pass http://localhost:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
gzip off;
access_log off;
root /opt/app-root;
fastcgi_pass unix:/var/run/fcgiwrap.socket;
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_FILENAME /opt/app-root$fastcgi_script_name;
access_log off;
}

location = /api/probe {
proxy_pass http://localhost:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
gzip off;
access_log off;
}
###############

Expand All @@ -44,14 +53,13 @@ location ${NB_PREFIX}/api/kernels/ {
}

location /api/kernels/ {
index access.cgi;
fastcgi_index access.cgi;
gzip off;
access_log off;
root /opt/app-root;
fastcgi_pass unix:/var/run/fcgiwrap.socket;
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_FILENAME /opt/app-root$fastcgi_script_name;
proxy_pass http://localhost:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
gzip off;
access_log off;
}
###############

Expand Down
21 changes: 18 additions & 3 deletions rstudio/c9s-python-3.11/run-rstudio.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,24 @@
SCRIPT_DIR=$(dirname -- "$0")
source ${SCRIPT_DIR}/utils/*.sh

# Start nginx and supervisord
# Start nginx and httpd
run-nginx.sh &
/usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf &

# Start Apache httpd with error checking
echo "Starting Apache httpd..."
/usr/sbin/httpd -D FOREGROUND &
HTTPD_PID=$!
sleep 2

# Check if Apache started successfully
if ! kill -0 $HTTPD_PID 2>/dev/null; then
echo "ERROR: Apache httpd failed to start"
echo "Checking Apache configuration..."
/usr/sbin/httpd -t
exit 1
else
echo "Apache httpd started successfully (PID: $HTTPD_PID)"
fi


# Add .bashrc for custom promt if not present
Expand All @@ -22,7 +37,7 @@ do
if [ ! -d "/opt/app-root/src/Rpackages/4.4/$package_folder" ]; then
cp -r /opt/app-root/bin/Rpackages/4.4/$package_folder /opt/app-root/src/Rpackages/4.4/
fi
done
done
# rstudio terminal can't see environment variables set by the container runtime;
# so we set all env variables to the Renviron.site config file. For kubectl, we need the KUBERNETES_* env vars at least.
# Also, we store proxy-related env vars lowercased by key so RStudio projects work with proxy by default
Expand Down
10 changes: 0 additions & 10 deletions rstudio/c9s-python-3.11/supervisord/supervisord.conf

This file was deleted.

Loading
Loading