8000 feat(jupyterlab): add support for `subdomain=false` by framctr · Pull Request #316 · coder/modules · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on May 15, 2025. It is now read-only.

feat(jupyterlab): add support for subdomain=false #316

Merged
merged 20 commits into from
Oct 21, 2024
Merged
Changes from 1 commit
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
Next Next commit
Add support for subdomain to main.tf in jupyterlab module
  • Loading branch information
framctr authored Oct 8, 2024
commit aa294c3356967cd952259d8991e8d382781f5ca5
28 changes: 25 additions & 3 deletions jupyterlab/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ terraform {
}
}

data "coder_workspace" "me" {}
data "coder_workspace_owner" "me" {}

# Add required variables for your modules and remove any unneeded variables
variable "agent_id" {
type = string
Expand Down Expand Up @@ -36,6 +39,15 @@ variable "share" {
}
}

variable "subdomain" {
type = bool
default = true
validation {
condition = var.share == "owner" || var.share == "authenticated" || var.share == "public"
error_message = "Incorrect value. Please set either 'owner', 'authenticated', or 'public'."
}
}

variable "order" {
type = number
description = "The order determines the position of app in the UI presentation. The lowest order is shown first and apps with equal order are sorted by name (ascending order)."
Expand All @@ -49,17 +61,27 @@ resource "coder_script" "jupyterlab" {
script = templatefile("${path.module}/run.sh", {
LOG_PATH : var.log_path,
PORT : var.port
BASE_URL : var.subdomain ? "http://localhost:${var.port}/@${data.coder_workspace_owner.me.name}/ 8000 ${data.coder_workspace.me.name}/apps/jupyterlab" : ""
})
run_on_start = true
}

resource "coder_app" "jupyterlab" {
agent_id = var.agent_id
slug = "jupyterlab"
slug = "jupyterlab" # sync with with end of subdomain URL
display_name = "JupyterLab"
url = "http://localhost:${var.port}"
url = var.subdomain ? "http://localhost:${var.port}/@${data.coder_workspace_owner.me.name}/${data.coder_workspace.me.name}/apps/jupyterlab" : "http://localhost:${var.port}"
icon = "/icon/jupyter.svg"
subdomain = true
subdomain = var.subdomain
share = var.share
order = var.order

dynamic "healthcheck" {
for_each = var.subdomain ? toset([true]) : toset([])
content {
url = "http://localhost:${var.port}/@${data.coder_workspace_owner.me.name}/${data.coder_workspace.me.name}/apps/jupyterlab"
interval = 6
threshold = 10
}
}
}
0