Skip to content
Snippets Groups Projects
Verified Commit 536a918a authored by Olivier Benz's avatar Olivier Benz
Browse files

base: Update JupyterLab to v4.0.9

parent 946b3fe9
No related branches found
No related tags found
No related merge requests found
......@@ -4,7 +4,7 @@ Topmost entry = Tag `latest`
| Python | Jupyter Hub | Jupyter Lab | code‑server (Code) | Git | Git LFS | Pandoc | CTAN date[^2] | Quarto[^2] | Linux distro |
|:-----------|:------------|:------------|:-------------------|:-------|:--------|:-------|:--------------|:------------|:-------------|
| 3.11.6 | 4.0.2 | 3.6.6 | 4.19.0 (1.84.2) | 2.43.0 | 3.4.0 | 3.1.1 | | 1.3.450 | Debian 12 |
| 3.11.6 | 4.0.2 | 4.0.9 | 4.19.0 (1.84.2) | 2.43.0 | 3.4.0 | 3.1.1 | | 1.3.450 | Debian 12 |
| 3.11.5 | 4.0.2 | 3.6.6 | 4.17.1 (1.82.2) | 2.42.0 | 3.4.0 | 3.1.1 | 2023‑10‑02 | 1.3.450 | Debian 12 |
| 3.11.4 | 4.0.2 | 3.6.5 | 4.16.1 (1.80.2) | 2.42.0 | 3.4.0 | 3.1.1 | 2023‑08‑24 | 1.3.450 | Debian 12 |
| 3.10.13 | 4.0.2 | 3.6.5 | 4.16.1 (1.80.2) | 2.42.0 | 3.4.0 | 3.1.1 | 2023‑08‑24 | 1.3.450 | Debian 12 |
......
# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
import os
import shutil
import stat
import subprocess
from jupyter_core.paths import jupyter_data_dir
c = get_config()
c.NotebookApp.ip = "0.0.0.0"
c.NotebookApp.port = 8888
#c.NotebookApp.open_browser = False
# https://github.com/jupyter/notebook/issues/3130
c.FileContentsManager.delete_to_trash = False
def _codeserver_command(port):
full_path = shutil.which("code-server")
if not full_path:
raise FileNotFoundError("Can not find code-server in $PATH")
work_dir = os.getenv("CODE_WORKDIR", None)
if work_dir is None:
work_dir = os.getenv("JUPYTER_SERVER_ROOT", ".")
elif os.path.isdir(work_dir) is False:
os.mkdir(work_dir)
data_dir = os.getenv("CODE_USER_DATA_DIR", "")
if data_dir != "":
data_dir = "--user-data-dir=" + str(data_dir)
extensions_dir = os.getenv("CODE_EXTENSIONS_DIR", "")
if extensions_dir != "":
extensions_dir = "--extensions-dir=" + str(extensions_dir)
return [
full_path,
"--bind-addr=0.0.0.0:" + str(port),
"--auth",
"none",
data_dir,
extensions_dir,
work_dir,
]
c.ServerProxy.servers = {
"code-server": {
"command": _codeserver_command,
"timeout": 20,
"launcher_entry": {
"title": "code-server",
"icon_path": "/opt/code-server/vscode.svg"
},
"new_browser_tab": True
}
}
# Generate a self-signed certificate
OPENSSL_CONFIG = """\
[req]
distinguished_name = req_distinguished_name
[req_distinguished_name]
"""
if "GEN_CERT" in os.environ:
dir_name = jupyter_data_dir()
pem_file = os.path.join(dir_name, "notebook.pem")
os.makedirs(dir_name, exist_ok=True)
# Generate an openssl.cnf file to set the distinguished name
cnf_file = os.path.join(os.getenv("CONDA_DIR", "/usr/lib"), "ssl", "openssl.cnf")
if not os.path.isfile(cnf_file):
with open(cnf_file, "w") as fh:
fh.write(OPENSSL_CONFIG)
# Generate a certificate if one doesn't exist on disk
subprocess.check_call(
[
"openssl",
"req",
"-new",
"-newkey=rsa:2048",
"-days=365",
"-nodes",
"-x509",
"-subj=/C=XX/ST=XX/L=XX/O=generated/CN=generated",
f"-keyout={pem_file}",
f"-out={pem_file}",
]
)
# Restrict access to the file
os.chmod(pem_file, stat.S_IRUSR | stat.S_IWUSR)
c.NotebookApp.certfile = pem_file
# Change default umask for all subprocesses of the notebook server if set in
# the environment
if "NB_UMASK" in os.environ:
os.umask(int(os.environ["NB_UMASK"], 8))
# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
# mypy: ignore-errors
import os
import shutil
import stat
import subprocess
from pathlib import Path
from jupyter_core.paths import jupyter_data_dir
c = get_config()
c = get_config() # noqa: F821
c.ServerApp.ip = "0.0.0.0"
c.ServerApp.port = 8888
#c.ServerApp.open_browser = False
......@@ -61,15 +62,14 @@ distinguished_name = req_distinguished_name
[req_distinguished_name]
"""
if "GEN_CERT" in os.environ:
dir_name = jupyter_data_dir()
pem_file = os.path.join(dir_name, "notebook.pem")
os.makedirs(dir_name, exist_ok=True)
dir_name = Path(jupyter_data_dir())
dir_name.mkdir(parents=True, exist_ok=True)
pem_file = dir_name / "notebook.pem"
# Generate an openssl.cnf file to set the distinguished name
cnf_file = os.path.join(os.getenv("CONDA_DIR", "/usr/lib"), "ssl", "openssl.cnf")
if not os.path.isfile(cnf_file):
with open(cnf_file, "w") as fh:
fh.write(OPENSSL_CONFIG)
cnf_file = Path("/usr/lib/ssl/openssl.cnf")
if not cnf_file.exists():
cnf_file.write_text(OPENSSL_CONFIG)
# Generate a certificate if one doesn't exist on disk
subprocess.check_call(
......@@ -87,10 +87,9 @@ if "GEN_CERT" in os.environ:
]
)
# Restrict access to the file
os.chmod(pem_file, stat.S_IRUSR | stat.S_IWUSR)
c.ServerApp.certfile = pem_file
pem_file.chmod(stat.S_IRUSR | stat.S_IWUSR)
c.ServerApp.certfile = str(pem_file)
# Change default umask for all subprocesses of the notebook server if set in
# the environment
# Change default umask for all subprocesses of the notebook server if set in the environment
if "NB_UMASK" in os.environ:
os.umask(int(os.environ["NB_UMASK"], 8))
......@@ -7,7 +7,7 @@ ARG CUDA_IMAGE_FLAVOR
ARG NB_USER=jovyan
ARG NB_UID=1000
ARG JUPYTERHUB_VERSION=4.0.2
ARG JUPYTERLAB_VERSION=3.6.6
ARG JUPYTERLAB_VERSION=4.0.9
ARG CODE_BUILTIN_EXTENSIONS_DIR=/opt/code-server/lib/vscode/extensions
ARG CODE_SERVER_VERSION=4.19.0
ARG GIT_VERSION=2.43.0
......@@ -235,6 +235,7 @@ RUN export PIP_BREAK_SYSTEM_PACKAGES=1 \
jupyterlab-git \
jupyterlab-lsp \
notebook \
nbclassic \
nbconvert \
python-lsp-server[all] \
## Include custom fonts
......
......@@ -12,12 +12,12 @@ if [ "$(id -u)" == 0 ] ; then
# Update timezone if needed
if [ "$TZ" != "Etc/UTC" ]; then
echo "Setting TZ to $TZ"
ln -snf /usr/share/zoneinfo/$TZ /etc/localtime \
&& echo $TZ > /etc/timezone
ln -snf "/usr/share/zoneinfo/$TZ" /etc/localtime \
&& echo "$TZ" > /etc/timezone
fi
# Add/Update locale if needed
if [ ! -z "$LANGS" ]; then
if [ -n "$LANGS" ]; then
for i in $LANGS; do
sed -i "s/# $i/$i/g" /etc/locale.gen
done
......@@ -25,30 +25,36 @@ if [ "$(id -u)" == 0 ] ; then
if [ "$LANG" != "en_US.UTF-8" ]; then
sed -i "s/# $LANG/$LANG/g" /etc/locale.gen
fi
if [[ "$LANG" != "en_US.UTF-8" || ! -z "$LANGS" ]]; then
if [[ "$LANG" != "en_US.UTF-8" || -n "$LANGS" ]]; then
locale-gen
fi
if [ "$LANG" != "en_US.UTF-8" ]; then
echo "Setting LANG to $LANG"
update-locale --reset LANG=$LANG
update-locale --reset LANG="$LANG"
fi
CS_USD="/home/$NB_USER/.local/share/code-server/User"
# Update code-server settings
su $NB_USER -c "mkdir -p /home/$NB_USER/.local/share/code-server/User"
if [[ ! -f "/home/$NB_USER/.local/share/code-server/User/settings.json" ]]; then
su $NB_USER -c "cp ${CP_OPTS:--a} /var/backups/skel/.local/share/code-server/User/settings.json \
/home/$NB_USER/.local/share/code-server/User/settings.json"
chown :$NB_GID "/home/$NB_USER/.local/share/code-server/User/settings.json"
su "$NB_USER" -c "mkdir -p $CS_USD"
if [[ ! -f "$CS_USD/settings.json" ]]; then
su "$NB_USER" -c "cp ${CP_OPTS:--a} /var/backups/skel/.local/share/code-server/User/settings.json \
$CS_USD/settings.json"
chown :"$NB_GID" "$CS_USD/settings.json"
fi
# Update code-server settings
su "$NB_USER" -c "mv $CS_USD/settings.json $CS_USD/settings.json.bak"
su "$NB_USER" -c "sed -i ':a;N;\$!ba;s/,\n\}/\n}/g' $CS_USD/settings.json.bak"
if [[ $(jq . "$CS_USD/settings.json.bak" 2> /dev/null) ]]; then
su "$NB_USER" -c "jq -s '.[0] * .[1]' \
/var/backups/skel/.local/share/code-server/User/settings.json \
$CS_USD/settings.json.bak > \
$CS_USD/settings.json"
else
su "$NB_USER" -c "mv $CS_USD/settings.json.bak $CS_USD/settings.json"
fi
su $NB_USER -c "mv /home/$NB_USER/.local/share/code-server/User/settings.json \
/home/$NB_USER/.local/share/code-server/User/settings.json.bak"
su $NB_USER -c "sed -i ':a;N;\$!ba;s/,\n\}/\n}/g' \
/home/$NB_USER/.local/share/code-server/User/settings.json.bak"
su $NB_USER -c "jq -s '.[0] * .[1]' \
/var/backups/skel/.local/share/code-server/User/settings.json \
/home/$NB_USER/.local/share/code-server/User/settings.json.bak > \
/home/$NB_USER/.local/share/code-server/User/settings.json"
# Remove old .zcompdump files
rm -f "/home/$NB_USER/.zcompdump"*
else
# Warn if the user wants to change the timezone but hasn't started the
# container as root.
......@@ -58,7 +64,7 @@ else
# Warn if the user wants to change the locale but hasn't started the
# container as root.
if [[ ! -z "$LANGS" ]]; then
if [[ -n "$LANGS" ]]; then
echo "WARNING: Container must be started as root to add locale(s)!"
fi
if [[ "$LANG" != "en_US.UTF-8" ]]; then
......@@ -67,22 +73,25 @@ else
LANG=en_US.UTF-8
fi
CS_USD="$HOME/.local/share/code-server/User"
# Update code-server settings
mkdir -p /home/$NB_USER/.local/share/code-server/User
if [[ ! -f "/home/$NB_USER/.local/share/code-server/User/settings.json" ]]; then
mkdir -p "$CS_USD"
if [[ ! -f "$CS_USD/settings.json" ]]; then
cp -a /var/backups/skel/.local/share/code-server/User/settings.json \
/home/$NB_USER/.local/share/code-server/User/settings.json
"$CS_USD/settings.json"
fi
# Update code-server settings
mv "$CS_USD/settings.json" "$CS_USD/settings.json.bak"
sed -i ':a;N;$!ba;s/,\n\}/\n}/g' "$CS_USD/settings.json.bak"
if [[ $(jq . "$CS_USD/settings.json.bak" 2> /dev/null) ]]; then
jq -s '.[0] * .[1]' \
/var/backups/skel/.local/share/code-server/User/settings.json \
"$CS_USD/settings.json.bak" > \
"$CS_USD/settings.json"
else
mv "$CS_USD/settings.json.bak" "$CS_USD/settings.json"
fi
mv /home/$NB_USER/.local/share/code-server/User/settings.json \
/home/$NB_USER/.local/share/code-server/User/settings.json.bak
sed -i ':a;N;$!ba;s/,\n\}/\n}/g' \
/home/$NB_USER/.local/share/code-server/User/settings.json.bak
jq -s '.[0] * .[1]' \
/var/backups/skel/.local/share/code-server/User/settings.json \
/home/$NB_USER/.local/share/code-server/User/settings.json.bak > \
/home/$NB_USER/.local/share/code-server/User/settings.json
# Remove old .zcompdump files
rm -f "$HOME/.zcompdump"*
fi
# Remove old .zcompdump files
rm -f /home/$NB_USER/.zcompdump*
......@@ -6,13 +6,13 @@ set -e
DIVISOR=1024
if [[ "${SWAP_ENABLE}" == "1" || "${SWAP_ENABLE}" == "yes" ]]; then
FACTOR=$(echo 1 ${SWAP_FACTOR:-1} | awk '{ printf "%.1f", $1 + $2 }')
if [[ "$SWAP_ENABLE" == "1" || "$SWAP_ENABLE" == "yes" ]]; then
FACTOR=$(echo 1 "${SWAP_FACTOR:-1}" | awk '{ printf "%.1f", $1 + $2 }')
else
FACTOR=1
fi
if [ ! -z "${MEM_LIMIT}" ]; then
ulimit -Sv $(echo $MEM_LIMIT $DIVISOR $FACTOR |
awk '{ printf "%.0f", $1 / $2 * $3 }')
if [ -n "$MEM_LIMIT" ]; then
ulimit -Sv "$(echo "$MEM_LIMIT" "$DIVISOR $FACTOR" |
awk '{ printf "%.0f", $1 / $2 * $3 }')"
fi
......@@ -2,10 +2,10 @@
# Copyright (c) 2022 b-data GmbH.
# Distributed under the terms of the MIT License.
while [ ! -z $JUPYTERHUB_API_TOKEN ]; do
while [ -n "$JUPYTERHUB_API_TOKEN" ]; do
t=$(date -Iseconds)
curl -s \
$JUPYTERHUB_ACTIVITY_URL -H \
"$JUPYTERHUB_ACTIVITY_URL" -H \
"Authorization: token $JUPYTERHUB_API_TOKEN" -d \
"{\"servers\":{\"$JUPYTERHUB_SERVER_NAME\":{\"last_activity\":\"$t\"}},\"last_activity\":\"$t\"}" \
> /dev/null 2>&1
......
......@@ -24,11 +24,19 @@ for f in "${1}/"*; do
echo "Sourcing shell script: ${f}"
# shellcheck disable=SC1090
source "${f}"
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "${f} has failed, continuing execution"
fi
;;
*)
if [ -x "${f}" ] ; then
echo "Running executable: ${f}"
"${f}"
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "${f} has failed, continuing execution"
fi
else
echo "Ignoring non-executable: ${f}"
fi
......
......@@ -121,7 +121,7 @@ RUN dpkgArch="$(dpkg --print-architecture)" \
## Install facets
&& cd /tmp \
&& git clone https://github.com/PAIR-code/facets.git \
&& jupyter nbextension install facets/facets-dist/ --sys-prefix \
&& jupyter nbclassic-extension install facets/facets-dist/ --sys-prefix \
&& cd / \
## Install code-server extensions
&& code-server --extensions-dir ${CODE_BUILTIN_EXTENSIONS_DIR} --install-extension quarto.quarto \
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment