Skip to content
Merged
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
2 changes: 1 addition & 1 deletion registry/coder/modules/jupyter-notebook/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ A module that adds Jupyter Notebook in your Coder template.
module "jupyter-notebook" {
count = data.coder_workspace.me.start_count
source = "registry.coder.com/coder/jupyter-notebook/coder"
version = "1.1.1"
version = "1.2.0"
agent_id = coder_agent.example.id
}
```
16 changes: 15 additions & 1 deletion registry/coder/modules/jupyter-notebook/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,27 @@ variable "group" {
default = null
}

variable "requirements_path" {
type = string
description = "The path to requirements.txt with packages to preinstall"
default = ""
}

variable "pip_install_extra_packages" {
type = string
description = "List of extra packages to preinstall (example: numpy==1.26.4 pandas matplotlib<4 scikit-learn)"
default = ""
}

resource "coder_script" "jupyter-notebook" {
agent_id = var.agent_id
display_name = "jupyter-notebook"
icon = "/icon/jupyter.svg"
script = templatefile("${path.module}/run.sh", {
LOG_PATH : var.log_path,
PORT : var.port
PORT : var.port,
REQUIREMENTS_PATH : var.requirements_path,
PIP_INSTALL_EXTRA_PACKAGES : var.pip_install_extra_packages
})
run_on_start = true
}
Expand Down
18 changes: 18 additions & 0 deletions registry/coder/modules/jupyter-notebook/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,24 @@ else
echo "🥳 jupyter-notebook is already installed\n\n"
fi

# Install packages selected with REQUIREMENTS_PATH
if [ -n "${REQUIREMENTS_PATH}" ]; then
if [ -f "${REQUIREMENTS_PATH}" ]; then
echo "📄 Installing packages from ${REQUIREMENTS_PATH}..."
pipx -q runpip notebook install -r "${REQUIREMENTS_PATH}"
echo "🥳 Packages from ${REQUIREMENTS_PATH} have been installed\n\n"
else
echo "⚠️ REQUIREMENTS_PATH is set to '${REQUIREMENTS_PATH}' but the file does not exist!\n\n"
fi
fi

# Install packages selected with PIP_INSTALL_EXTRA_PACKAGES
if [ -n "${PIP_INSTALL_EXTRA_PACKAGES}" ]; then
echo "📦 Installing additional packages: ${PIP_INSTALL_EXTRA_PACKAGES}"
pipx -q runpip notebook install ${PIP_INSTALL_EXTRA_PACKAGES}
echo "🥳 Additional packages have been installed\n\n"
fi

echo "👷 Starting jupyter-notebook in background..."
echo "check logs at ${LOG_PATH}"
$HOME/.local/bin/jupyter-notebook --NotebookApp.ip='0.0.0.0' --ServerApp.port=${PORT} --no-browser --ServerApp.token='' --ServerApp.password='' > ${LOG_PATH} 2>&1 &