Skip to content
Open
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
75 changes: 62 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,31 +1,80 @@
FROM rockylinux/rockylinux:9
# =========================
# Stage 1: base (OOD + Lmod)
# =========================
FROM rockylinux/rockylinux:9 AS base
LABEL maintainer="[email protected]; [email protected]"

RUN dnf install -y https://yum.osc.edu/ondemand/4.0/ondemand-release-web-4.0-1.el9.noarch.rpm && \
dnf clean all && rm -rf /var/cache/dnf/*

RUN dnf -y update && \
dnf -y update && \
dnf install -y dnf-utils && \
dnf config-manager --set-enabled crb && \
dnf -y module enable nodejs:20 ruby:3.3 && \
dnf install -y epel-release && \
dnf install -y procps libffi-devel python3-devel gcc && \
dnf install -y ondemand ondemand-dex && \
dnf install -y procps libffi-devel python3-devel gcc libstdc++ zlib openssl && \
dnf install -y --nogpgcheck ondemand ondemand-dex && \
dnf install -y Lmod && \
dnf clean all && rm -rf /var/cache/dnf/*

# RUN pip3 install 'setuptools_scm<7' && \
RUN pip3 install jupyter
# Patch OOD’s httpd config
RUN sed -i 's|--rpm|--rpm -f --insecure|g' /etc/systemd/system/httpd.service.d/ood-portal.conf && \
systemctl enable httpd ondemand-dex

# Create dev user
RUN useradd jesse && chmod 600 /etc/shadow && \
echo 'jesse:password' | chpasswd

# =========================
# Stage 2: wheels (cached Python deps)
# =========================
FROM rockylinux/rockylinux:9 AS builder
RUN dnf install -y python3 python3-pip gcc libffi-devel zlib-devel bzip2 bzip2-devel xz xz-devel
WORKDIR /wheels

RUN python3 -m pip install --upgrade pip wheel setuptools
RUN pip wheel jupyterlab==3.6.3 -w /wheels
RUN pip wheel jupyterlab==4.0.9 -w /wheels

# =========================
# Stage 3: apps layer
# =========================
FROM base AS apps

# Bring in built wheels
COPY --from=builder /wheels /tmp/wheels

# Install into isolated venvs using wheels (no re-download)
RUN python3 -m venv /opt/apps/jupyter/3.6.3 && \
/opt/apps/jupyter/3.6.3/bin/pip install --no-index --find-links /tmp/wheels jupyterlab==3.6.3 && \
python3 -m venv /opt/apps/jupyter/4.0.9 && \
/opt/apps/jupyter/4.0.9/bin/pip install --no-index --find-links /tmp/wheels jupyterlab==4.0.9

# Modulefiles for Lmod
COPY files/modulefiles /opt/modulefiles

# Smoke test modules
RUN bash -lc 'module use /opt/modulefiles && \
module load jupyter/3.6.3 && jupyter-lab --version && \
module swap jupyter/4.0.9 && jupyter-lab --version'

RUN sed -i 's|--rpm|--rpm -f --insecure|g' /etc/systemd/system/httpd.service.d/ood-portal.conf
RUN systemctl enable httpd ondemand-dex
# Generate spider JSON for OOD auto_modules
RUN bash -lc 'module use /opt/modulefiles && \
tmp=$(mktemp) && \
$LMOD_DIR/spider -o spider-json "$MODULEPATH" > "$tmp" && \
mkdir -p /etc/ood/config/modules && \
mv "$tmp" /etc/ood/config/modules/localhost.json && \
chmod 644 /etc/ood/config/modules/localhost.json && \
chmod 755 /etc/ood/config/modules'
Comment on lines +60 to +66
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just write directly into /etc/ood/config/modules/localhost.json?


RUN useradd jesse
RUN chmod 600 /etc/shadow
# =========================
# Stage 4: final image (volatile files last)
# =========================
FROM apps

# Put frequently changed configs at the end so edits don’t bust cache
COPY files/ood_portal.yml /etc/ood/config/ood_portal.yml
COPY files/clusters.d /etc/ood/config/clusters.d
COPY files/apps /var/www/ood/apps/sys/
COPY files/config /etc/ood/config/apps/
COPY files/motd.md /etc/motd.md

CMD [ "/sbin/init" ]
CMD ["/sbin/init"]
12 changes: 10 additions & 2 deletions files/apps/jupyter/form.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
cluster: localhost

---
cluster: "localhost"

form:
- bc_num_hours
- auto_modules_jupyter

attributes:
auto_modules_jupyter:
widget: "select"
label: "Jupyter Version"
help: "Select which JupyterLab module to load"
default: false
2 changes: 1 addition & 1 deletion files/apps/jupyter/manifest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ category: Interactive Apps
subcategory: Servers
role: batch_connect
description: |
This app will launch a JupyterLab.
This app will launch a JupyterLab session with selectable versions.
6 changes: 4 additions & 2 deletions files/apps/jupyter/submit.yml.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Job submission configuration file
#
---
batch_connect:
template: "basic"

script:
native:
- "--ntasks=1"
Comment on lines +4 to +7
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't have any affect on the localhost adapter.

20 changes: 20 additions & 0 deletions files/apps/jupyter/template/after.sh.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Wait for the Jupyter server to start
echo "Waiting for Jupyter server to open port ${port}..."
if wait_until_port_used "${host}:${port}" 600; then
echo "Discovered Jupyter server listening on port ${port}!"
else
echo "Timed out waiting for Jupyter server to open port ${port}!"
clean_up 1
fi
sleep 2

# Write connection.yml so OOD can display the session
(
umask 077
cat > connection.yml << EOL
---
host: "${host}"
port: "${port}"
password: "${password}"
EOL
)
Comment on lines +11 to +20
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be done automatically by our wrapper scripts. Did it not work for you automatically?

10 changes: 10 additions & 0 deletions files/apps/jupyter/template/before.sh.erb
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,13 @@ c.NotebookApp.notebook_dir = '${HOME}'
c.NotebookApp.disable_check_xsrf = True
EOL
)

if [ -f /usr/share/lmod/lmod/init/bash ]; then
source /usr/share/lmod/lmod/init/bash
fi

module purge
module use /opt/modulefiles
Comment on lines +59 to +65
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think instead of the source and module use commands, we probably need to add something to /etc/profile.d from lmod.

module load <%= context.auto_modules_jupyter %>

which jupyter || echo "Jupyter not found!"
4 changes: 0 additions & 4 deletions files/apps/jupyter/template/script.sh.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ echo "TIMING - Starting main script at: $(date)"
# Set working directory to home directory
cd "${HOME}"

#
# Start Jupyter Notebook Server
#

# Benchmark info
echo "TIMING - Starting jupyter at: $(date)"

Expand Down
3 changes: 3 additions & 0 deletions files/clusters.d/localhost.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ v2:
host: localhost
metadata:
title: Localhost
batch_connect:
basic:
module_file_dir: "/etc/ood/config/modules"
Comment on lines +8 to +10
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not have any affect.

4 changes: 3 additions & 1 deletion files/config/dashboard/env
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
MOTD_PATH=/etc/motd.md
MOTD_FORMAT='markdown'
MOTD_FORMAT='markdown'
OOD_BC_DYNAMIC_JS=TRUE
OOD_MODULE_FILE_DIR=/etc/ood/config/modules
10 changes: 5 additions & 5 deletions files/config/dashboard/initializers/localhost.rb
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try not to add unnecessary file modifications like the ones in this file.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Rails.application.config.after_initialize do
require 'ood_core'

class OodCore::Job::Adapters::Localhost < OodCore::Job::Adapter

def submit(script, after: [], afterok: [], afternotok: [], afterany: [])
Expand All @@ -13,7 +13,7 @@ def submit(script, after: [], afterok: [], afternotok: [], afterany: [])

File.open(file, 'w') { |f| f.write(content) }
FileUtils.chmod(0755, file)

pid = spawn(file, [:out, :err] => [script.output_path, 'w'])
Process.detach(pid)
pid
Expand All @@ -36,13 +36,13 @@ def info(id)

def delete(id)
pinfo = Process.getpgid(id.to_i)
Process.kill('TERM', id.to_i)
Process.kill('TERM', id.to_i)
end

def info_all(attrs: nil)
[]
end
end
end

class OodCore::Job::Factory
def self.build_localhost(config = {})
Expand Down Expand Up @@ -72,4 +72,4 @@ def self.build(config)
send(adapter_method, c)
end
end
end
end
9 changes: 9 additions & 0 deletions files/modulefiles/jupyter/3.6.3.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
help([[
JupyterLab 3.6.3
]])
whatis("Name: JupyterLab")
whatis("Version: 3.6.3")
family("jupyter")

local root = "/opt/apps/jupyter/3.6.3"
prepend_path("PATH", pathJoin(root, "bin"))
9 changes: 9 additions & 0 deletions files/modulefiles/jupyter/4.0.9.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
help([[
JupyterLab 4.0.9
]])
whatis("Name: JupyterLab")
whatis("Version: 4.0.9")
family("jupyter")

local root = "/opt/apps/jupyter/4.0.9"
prepend_path("PATH", pathJoin(root, "bin"))
16 changes: 8 additions & 8 deletions files/ood_portal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ listen_addr_port: 8080
oidc_remote_user_claim: email
dex:
static_passwords:
- email: jesse@localhost
password: owens
username: jesse
userID: 7e3146ab-83fb-4642-ad0d-3120a76bfd9a
- email: jesse@localhost
password: owens
username: jesse
userID: 7e3146ab-83fb-4642-ad0d-3120a76bfd9a
frontend:
extra:
loginLogo: '/public/login.png'
loginLogo: "/public/login.png"

rnode_uri: '/rnode'
node_uri: '/node'
host_regex: 'ood\.demo'
rnode_uri: "/rnode"
node_uri: "/node"
host_regex: 'ood\.demo'
2 changes: 1 addition & 1 deletion lib/utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ def build_cmd
else
docker_build_cmd
end
end
end