Skip to content

Commit 9b3afc2

Browse files
committed
Modify run.sh
1 parent 06cedcf commit 9b3afc2

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

registry/coder/modules/jupyter-notebook/main.tf

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@ resource "coder_script" "jupyter-notebook" {
6666
icon = "/icon/jupyter.svg"
6767
script = templatefile("${path.module}/run.sh", {
6868
LOG_PATH : var.log_path,
69-
PORT : var.port
69+
PORT : var.port,
70+
REQUIREMENTS_PATH : var.requirements_path,
71+
PIP_INSTALL_PACKAGES : var.pip_install_packages
7072
})
7173
run_on_start = true
7274
}

registry/coder/modules/jupyter-notebook/run.sh

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,30 @@ if ! command -v jupyter-notebook > /dev/null 2>&1; then
1414
exit 1
1515
fi
1616
# install jupyter notebook
17-
pipx install -q notebook
17+
pipx install --no-cache-dir -q notebook
1818
echo "🥳 jupyter-notebook has been installed\n\n"
1919
else
2020
echo "🥳 jupyter-notebook is already installed\n\n"
2121
fi
2222

23+
# Install packages selected with REQUIREMENTS_PATH
24+
if [ -n "$REQUIREMENTS_PATH" ]; then
25+
if [ -f "$REQUIREMENTS_PATH" ]; then
26+
echo "📄 Installing packages from $REQUIREMENTS_PATH..."
27+
pip install --no-cache-dir -r "$REQUIREMENTS_PATH"
28+
echo "🥳 Requirements installed\n\n"
29+
else
30+
echo "⚠️ REQUIREMENTS_PATH is set to '$REQUIREMENTS_PATH' but the file does not exist!\n\n"
31+
fi
32+
fi
33+
34+
# Install packages selected with PIP_INSTALL_PACKAGES
35+
if [ -n "$PIP_INSTALL_PACKAGES" ]; then
36+
echo "📦 Installing extra pip packages: $PIP_INSTALL_PACKAGES"
37+
pip install --no-cache-dir $PIP_INSTALL_PACKAGES
38+
echo "🥳 Extra packages installed\n\n"
39+
fi
40+
2341
echo "👷 Starting jupyter-notebook in background..."
2442
echo "check logs at ${LOG_PATH}"
2543
$HOME/.local/bin/jupyter-notebook --NotebookApp.ip='0.0.0.0' --ServerApp.port=${PORT} --no-browser --ServerApp.token='' --ServerApp.password='' > ${LOG_PATH} 2>&1 &

0 commit comments

Comments
 (0)