pull/39/head
Muhammad Atif Ali 2 years ago
parent 66cf2e5455
commit 63839d4837

@ -1,64 +1,21 @@
--- ---
display_name: jupyterlab display_name: JupyterLab
description: Describe what this module does description: A module that adds JupyterLab in your Coder template.
icon: ../.icons/<A_RELEVANT_ICON>.svg icon: ../.icons/jupyter.svg
maintainer_github: GITHUB_USERNAME maintainer_github: coder
verified: false verified: true
tags: [community] tags: [jupyter, helper]
--- ---
# jupyterlab # JupyterLab
<-- Describes what this module does --> A module that adds JupyterLab in your Coder template.
<-- Add a screencast or screenshot here --> <!-- Add a screencast or screenshot here -->
```hcl
module "jupyterlab" {
source = "https://registry.coder.com/modules/jupyterlab"
}
```
## Examples
### Example 1
Install the Dracula theme from [OpenVSX](https://open-vsx.org/):
```hcl ```hcl
module "jupyterlab" { module "jupyterlab" {
source = "https://registry.coder.com/modules/jupyterlab" source = "https://registry.coder.com/modules/jupyterlab"
agent_id = coder_agent.example.id agent_id = coder_agent.example.id
extensions = [
"dracula-theme.theme-dracula"
]
} }
``` ```
Enter the `<author>.<name>` into the extensions array and code-server will automatically install on start.
### Example 2
Configure VS Code's [settings.json](https://code.visualstudio.com/docs/getstarted/settings#_settingsjson) file:
```hcl
module "jupyterlab" {
source = "https://registry.coder.com/modules/jupyterlab"
agent_id = coder_agent.example.id
extensions = [ "dracula-theme.theme-dracula" ]
settings = {
"workbench.colorTheme" = "Dracula"
}
}
```
### Example 3
Run code-server in the background, don't fetch it from GitHub:
```hcl
module "jupyterlab" {
source = "https://registry.coder.com/modules/jupyterlab"
agent_id = coder_agent.example.id
offline = true
}

@ -10,21 +10,7 @@ terraform {
} }
locals { locals {
# A built-in icon like "/icon/code.svg" or a full URL of icon icon_url = "/icon/jupyter.svg"
icon_url = "https://raw.githubusercontent.com/coder/coder/main/site/static/icon/code.svg"
# a map of all possible values
options = {
"Option 1" = {
"name" = "Option 1",
"value" = "1"
"icon" = "/emojis/1.png"
}
"Option 2" = {
"name" = "Option 2",
"value" = "2"
"icon" = "/emojis/2.png"
}
}
} }
# Add required variables for your modules and remove any unneeded variables # Add required variables for your modules and remove any unneeded variables
@ -45,20 +31,13 @@ variable "port" {
default = 19999 default = 19999
} }
variable "mutable" {
type = bool
description = "Whether the parameter is mutable."
default = true
}
# Add other variables here
resource "coder_script" "jupyterlab" { resource "coder_script" "jupyterlab" {
agent_id = var.agent_id agent_id = var.agent_id
display_name = "jupyterlab" display_name = "jupyterlab"
icon = local.icon_url icon = local.icon_url
script = templatefile("${path.module}/run.sh", { script = templatefile("${path.module}/run.sh", {
LOG_PATH : var.log_path, LOG_PATH : var.log_path,
PORT : var.port
}) })
run_on_start = true run_on_start = true
run_on_stopt = false run_on_stopt = false
@ -67,35 +46,9 @@ resource "coder_script" "jupyterlab" {
resource "coder_app" "jupyterlab" { resource "coder_app" "jupyterlab" {
agent_id = var.agent_id agent_id = var.agent_id
slug = "jupyterlab" slug = "jupyterlab"
display_name = "jupyterlab" display_name = "JupyterLab"
url = "http://localhost:${var.port}" url = "http://localhost:${var.port}"
icon = loocal.icon_url
subdomain = false
share = "owner"
# Remove if the app does not have a healthcheck endpoint
healthcheck {
url = "http://localhost:${var.port}/healthz"
interval = 5
threshold = 6
}
}
data "coder_parameter" "jupyterlab" {
type = "list(string)"
name = "jupyterlab"
display_name = "jupyterlab"
icon = local.icon_url icon = local.icon_url
mutable = var.mutable subdomain = true
default = local.options["Option 1"]["value"] share = "owner"
dynamic "option" {
for_each = local.options
content {
icon = option.value.icon
name = option.value.name
value = option.value.value
}
}
} }

@ -1,11 +1,21 @@
#!/usr/bin/env sh #!/usr/bin/env sh
echo "Instalalting ${MODULE_NAME}..." echo "Instalalting ${MODULE_NAME}..."
# Add code here
# Use varibles from the templatefile function in main.tf
# e.g. LOG_PATH, PORT, etc.
echo "Installation comlete!" # check if jupyterlab is installed
if ! command -v jupyterlab &> /dev/null then
# install jupyterlab
# check if python3 pip is installed
if ! command -v pip3 &> /dev/null then
echo "pip3 is not installed"
echo "Please install pip3 and try again"
exit 1
fi
fi
"
echo "Starting ${MODULE_NAME}..." echo "Starting ${MODULE_NAME}..."
# Start the app in here # Start the app in here

Loading…
Cancel
Save