Skip to content

Commit 4897f0f

Browse files
authored
Merge pull request opendatahub-io#2498 from atheo89/rhoaieng-974
Replace supervisord and fcgi and supervisord with httpd
2 parents d541c7f + 3e5282b commit 4897f0f

File tree

7 files changed

+93
-37
lines changed

7 files changed

+93
-37
lines changed

codeserver/ubi9-python-3.12/Dockerfile.cpu

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,8 @@ RUN mkdir -p /opt/app-root/extensions-temp && \
159159
code-server --install-extension /opt/app-root/bin/utils/ms-toolsai.jupyter-2025.2.0.vsix --extensions-dir /opt/app-root/extensions-temp
160160

161161
# Install NGINX to proxy code-server and pass probes check
162-
ENV NGINX_VERSION=1.24 \
162+
ENV APP_ROOT=/opt/app-root \
163+
NGINX_VERSION=1.24 \
163164
NGINX_SHORT_VER=124 \
164165
NGINX_CONFIGURATION_PATH=${APP_ROOT}/etc/nginx.d \
165166
NGINX_CONF_PATH=/etc/nginx/nginx.conf \
@@ -170,17 +171,23 @@ ENV NGINX_VERSION=1.24 \
170171
NGINX_PERL_MODULE_PATH=${APP_ROOT}/etc/perl
171172

172173
# Modules does not exist
173-
RUN dnf install -y https://download.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm && \
174-
INSTALL_PKGS="bind-utils nginx nginx-mod-stream nginx-mod-http-perl fcgiwrap initscripts chkconfig supervisor" && \
174+
RUN INSTALL_PKGS="bind-utils nginx nginx-mod-stream nginx-mod-http-perl httpd" && \
175175
dnf install -y --setopt=tsflags=nodocs $INSTALL_PKGS && \
176176
rpm -V $INSTALL_PKGS && \
177177
dnf -y clean all --enablerepo='*'
178178

179-
COPY --chown=1001:0 ${CODESERVER_SOURCE_CODE}/supervisord/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
179+
# Configure httpd for CGI processing
180+
COPY --chown=1001:0 ${CODESERVER_SOURCE_CODE}/httpd/httpd.conf /etc/httpd/conf/httpd.conf
181+
COPY --chown=1001:0 ${CODESERVER_SOURCE_CODE}/httpd/codeserver-cgi.conf /etc/httpd/conf.d/codeserver-cgi.conf
180182

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

186+
## Configure nginx
187+
COPY ${CODESERVER_SOURCE_CODE}/nginx/serverconf/ /opt/app-root/etc/nginx.default.d/
188+
COPY ${CODESERVER_SOURCE_CODE}/nginx/httpconf/ /opt/app-root/etc/nginx.d/
189+
COPY ${CODESERVER_SOURCE_CODE}/nginx/api/ /opt/app-root/api/
190+
184191
# Changing ownership and user rights to support following use-cases:
185192
# 1) running container on OpenShift, whose default security model
186193
# is to run the container under random UID, but GID=0
@@ -199,14 +206,20 @@ RUN sed -i -f ${NGINX_APP_ROOT}/nginxconf.sed ${NGINX_CONF_PATH} && \
199206
mkdir -p ${NGINX_CONTAINER_SCRIPTS_PATH}/nginx-start && \
200207
mkdir -p ${NGINX_LOG_PATH} && \
201208
mkdir -p ${NGINX_PERL_MODULE_PATH} && \
209+
# Create httpd directories and set permissions
210+
mkdir -p /var/log/httpd /var/run/httpd /etc/httpd/logs && \
202211
chown -R 1001:0 ${NGINX_CONF_PATH} && \
203212
chown -R 1001:0 ${NGINX_APP_ROOT}/etc && \
204213
chown -R 1001:0 ${NGINX_CONTAINER_SCRIPTS_PATH}/nginx-start && \
205214
chown -R 1001:0 /var/lib/nginx /var/log/nginx /run && \
215+
chown -R 1001:0 /var/log/httpd /var/run/httpd /etc/httpd/logs && \
206216
chmod ug+rw ${NGINX_CONF_PATH} && \
207217
chmod -R ug+rwX ${NGINX_APP_ROOT}/etc && \
208218
chmod -R ug+rwX ${NGINX_CONTAINER_SCRIPTS_PATH}/nginx-start && \
209219
chmod -R ug+rwX /var/lib/nginx /var/log/nginx /run && \
220+
chmod -R ug+rwX /var/log/httpd /var/run/httpd /etc/httpd/logs && \
221+
# Make CGI script executable
222+
chmod +x /opt/app-root/api/kernels/access.cgi && \
210223
rpm-file-permissions && \
211224
# Ensure the temporary directory and target directory have the correct permissions
212225
mkdir -p /opt/app-root/src/.local/share/code-server/extensions && \
@@ -215,11 +228,6 @@ RUN sed -i -f ${NGINX_APP_ROOT}/nginxconf.sed ${NGINX_CONF_PATH} && \
215228
chown -R 1001:0 /opt/app-root/extensions-temp && \
216229
chown -R 1001:0 /opt/app-root/src/.config/code-server
217230

218-
## Configure nginx
219-
COPY ${CODESERVER_SOURCE_CODE}/nginx/serverconf/ /opt/app-root/etc/nginx.default.d/
220-
COPY ${CODESERVER_SOURCE_CODE}/nginx/httpconf/ /opt/app-root/etc/nginx.d/
221-
COPY ${CODESERVER_SOURCE_CODE}/nginx/api/ /opt/app-root/api/
222-
223231
# Launcher
224232
COPY --chown=1001:0 ${CODESERVER_SOURCE_CODE}/run-code-server.sh ${CODESERVER_SOURCE_CODE}/run-nginx.sh ./
225233

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Code-server CGI configuration
2+
# This configuration handles the /api/kernels/ endpoint for culling
3+
4+
# Enable CGI for the kernels API endpoint
5+
<LocationMatch "^/api/kernels/">
6+
SetHandler cgi-script
7+
Options +ExecCGI
8+
Require all granted
9+
</LocationMatch>
10+
11+
# Set the CGI script path
12+
ScriptAlias /api/kernels/ /opt/app-root/api/kernels/
13+
14+
# Ensure the CGI script is executable
15+
<Directory "/opt/app-root/api/kernels">
16+
Options +ExecCGI
17+
AddHandler cgi-script .cgi
18+
Require all granted
19+
</Directory>
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Basic httpd configuration for CGI processing
2+
ServerRoot "/etc/httpd"
3+
Listen 8080
4+
5+
# Load modules
6+
LoadModule mpm_prefork_module modules/mod_mpm_prefork.so
7+
LoadModule authz_core_module modules/mod_authz_core.so
8+
LoadModule dir_module modules/mod_dir.so
9+
LoadModule cgi_module modules/mod_cgi.so
10+
LoadModule rewrite_module modules/mod_rewrite.so
11+
12+
# User and Group - run as the container user (OpenShift assigns random UIDs)
13+
# User 1001
14+
# Group 0
15+
16+
# Server configuration
17+
ServerAdmin root@localhost
18+
ServerName localhost
19+
20+
# Document root
21+
DocumentRoot "/opt/app-root"
22+
23+
# Directory configuration
24+
<Directory />
25+
AllowOverride none
26+
Require all denied
27+
</Directory>
28+
29+
<Directory "/opt/app-root">
30+
AllowOverride None
31+
Options +ExecCGI
32+
Require all granted
33+
AddHandler cgi-script .cgi
34+
</Directory>
35+
36+
# Error and access logs
37+
ErrorLog "/var/log/httpd/error_log"
38+
LogLevel warn
39+
40+
# Include additional configurations
41+
IncludeOptional conf.d/*.conf

codeserver/ubi9-python-3.12/nginx/serverconf/proxy.conf.template

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,13 @@ location = /api/kernels {
2121
}
2222

2323
location /api/kernels/ {
24-
index access.cgi;
25-
fastcgi_index access.cgi;
26-
gzip off;
27-
access_log off;
28-
root /opt/app-root;
29-
fastcgi_pass unix:/var/run/fcgiwrap.socket;
30-
include /etc/nginx/fastcgi_params;
31-
fastcgi_param SCRIPT_FILENAME /opt/app-root$fastcgi_script_name;
24+
proxy_pass http://localhost:8080;
25+
proxy_set_header Host $host;
26+
proxy_set_header X-Real-IP $remote_addr;
27+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
28+
proxy_set_header X-Forwarded-Proto $scheme;
29+
gzip off;
30+
access_log off;
3231
}
3332
###############
3433

codeserver/ubi9-python-3.12/nginx/serverconf/proxy.conf.template_nbprefix

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,13 @@ location ${NB_PREFIX}/api/kernels/ {
2626
}
2727

2828
location /api/kernels/ {
29-
index access.cgi;
30-
fastcgi_index access.cgi;
31-
gzip off;
32-
access_log off;
33-
root /opt/app-root;
34-
fastcgi_pass unix:/var/run/fcgiwrap.socket;
35-
include /etc/nginx/fastcgi_params;
36-
fastcgi_param SCRIPT_FILENAME /opt/app-root$fastcgi_script_name;
29+
proxy_pass http://localhost:8080;
30+
proxy_set_header Host $host;
31+
proxy_set_header X-Real-IP $remote_addr;
32+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
33+
proxy_set_header X-Forwarded-Proto $scheme;
34+
gzip off;
35+
access_log off;
3736
}
3837
###############
3938

codeserver/ubi9-python-3.12/run-code-server.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
SCRIPT_DIR=$(dirname -- "$0")
55
source ${SCRIPT_DIR}/utils/*.sh
66

7-
# Start nginx and supervisord
7+
# Start nginx and httpd
88
run-nginx.sh &
9-
/usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf &
9+
/usr/sbin/httpd -D FOREGROUND &
1010

1111
# Add .bashrc for custom prompt if not present
1212
if [ ! -f "/opt/app-root/src/.bashrc" ]; then

codeserver/ubi9-python-3.12/supervisord/supervisord.conf

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

0 commit comments

Comments
 (0)