From 20d97a25dd832256c1deee2b66c141ae02d79520 Mon Sep 17 00:00:00 2001 From: Yves ANDOLFATTO <145037627+yandolfat@users.noreply.github.com> Date: Fri, 18 Oct 2024 14:21:36 +0200 Subject: [PATCH 1/4] fix(filebrowser): support custom base_url in case of custom db path (#320) Co-authored-by: Muhammad Atif Ali Co-authored-by: Muhammad Atif Ali --- filebrowser/README.md | 6 +++--- filebrowser/run.sh | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/filebrowser/README.md b/filebrowser/README.md index 8665d828..1b53ffaa 100644 --- a/filebrowser/README.md +++ b/filebrowser/README.md @@ -14,7 +14,7 @@ A file browser for your workspace. ```tf module "filebrowser" { source = "registry.coder.com/modules/filebrowser/coder" - version = "1.0.19" + version = "1.0.22" agent_id = coder_agent.example.id } ``` @@ -28,7 +28,7 @@ module "filebrowser" { ```tf module "filebrowser" { source = "registry.coder.com/modules/filebrowser/coder" - version = "1.0.19" + version = "1.0.22" agent_id = coder_agent.example.id folder = "/home/coder/project" } @@ -39,7 +39,7 @@ module "filebrowser" { ```tf module "filebrowser" { source = "registry.coder.com/modules/filebrowser/coder" - version = "1.0.19" + version = "1.0.22" agent_id = coder_agent.example.id database_path = ".config/filebrowser.db" } diff --git a/filebrowser/run.sh b/filebrowser/run.sh index 22f13ed1..8a31d4db 100644 --- a/filebrowser/run.sh +++ b/filebrowser/run.sh @@ -18,7 +18,7 @@ if [ "${DB_PATH}" != "filebrowser.db" ]; then fi # set baseurl to be able to run if sudomain=false; if subdomain=true the SERVER_BASE_PATH value will be "" -filebrowser config set --baseurl "${SERVER_BASE_PATH}" > ${LOG_PATH} 2>&1 +filebrowser config set --baseurl "${SERVER_BASE_PATH}"$${DB_FLAG} > ${LOG_PATH} 2>&1 printf "📂 Serving $${ROOT_DIR} at http://localhost:${PORT} \n\n" From 7992d9d2652bc9714a22e93fdf35f61672d4c366 Mon Sep 17 00:00:00 2001 From: djarbz <30350993+djarbz@users.noreply.github.com> Date: Sun, 20 Oct 2024 22:04:59 -0500 Subject: [PATCH 2/4] fix(kasmVNC): fix debian installation and improve logging (#326) --- kasmvnc/README.md | 2 +- kasmvnc/run.sh | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/kasmvnc/README.md b/kasmvnc/README.md index 845cbc23..3b7fe507 100644 --- a/kasmvnc/README.md +++ b/kasmvnc/README.md @@ -14,7 +14,7 @@ Automatically install [KasmVNC](https://kasmweb.com/kasmvnc) in a workspace, and ```tf module "kasmvnc" { source = "registry.coder.com/modules/kasmvnc/coder" - version = "1.0.21" + version = "1.0.22" agent_id = coder_agent.example.id desktop_environment = "xfce" } diff --git a/kasmvnc/run.sh b/kasmvnc/run.sh index 47fe571c..b8315376 100644 --- a/kasmvnc/run.sh +++ b/kasmvnc/run.sh @@ -19,7 +19,7 @@ download_file() { if command -v wget &> /dev/null; then wget $url -O $output elif command -v curl &> /dev/null; then - curl -L $url -o $output + curl -fsSL $url -o $output elif command -v busybox &> /dev/null; then busybox wget -O $output $url else @@ -32,7 +32,8 @@ download_file() { install_deb() { local url=$1 download_file $url /tmp/kasmvncserver.deb - sudo apt-get install --yes --no-install-recommends --no-install-suggests /tmp/kasmvncserver.deb + sudo apt-get update + DEBIAN_FRONTEND=noninteractive sudo apt-get install --yes -qq --no-install-recommends --no-install-suggests /tmp/kasmvncserver.deb sudo adduser $USER ssl-cert rm /tmp/kasmvncserver.deb } @@ -103,6 +104,7 @@ fi # Check if vncserver is installed, and install if not if ! check_installed; then + echo "Installing KASM version: ${VERSION}" case $distro in ubuntu | debian | kali) case $version in From 1b147ae90dcb1e861751a808a68f68c449c128b6 Mon Sep 17 00:00:00 2001 From: framctr <35109437+framctr@users.noreply.github.com> Date: Mon, 21 Oct 2024 09:06:10 +0200 Subject: [PATCH 3/4] feat(jupyterlab): add support for `subdomain=false` (#316) Co-authored-by: Muhammad Atif Ali Co-authored-by: Asher --- jupyterlab/README.md | 2 +- jupyterlab/main.tf | 16 +++++++++++++--- jupyterlab/run.sh | 20 +++++++++++++++----- 3 files changed, 29 insertions(+), 9 deletions(-) diff --git a/jupyterlab/README.md b/jupyterlab/README.md index ed73b56e..52d5a502 100644 --- a/jupyterlab/README.md +++ b/jupyterlab/README.md @@ -16,7 +16,7 @@ A module that adds JupyterLab in your Coder template. ```tf module "jupyterlab" { source = "registry.coder.com/modules/jupyterlab/coder" - version = "1.0.19" + version = "1.0.22" agent_id = coder_agent.example.id } ``` diff --git a/jupyterlab/main.tf b/jupyterlab/main.tf index d7928f0d..d66edb1c 100644 --- a/jupyterlab/main.tf +++ b/jupyterlab/main.tf @@ -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 @@ -36,6 +39,12 @@ variable "share" { } } +variable "subdomain" { + type = bool + description = "Determines whether JupyterLab will be accessed via its own subdomain or whether it will be accessed via a path on Coder." + default = true +} + 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)." @@ -49,17 +58,18 @@ resource "coder_script" "jupyterlab" { script = templatefile("${path.module}/run.sh", { LOG_PATH : var.log_path, PORT : var.port + BASE_URL : var.subdomain ? "" : "/@${data.coder_workspace_owner.me.name}/${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 the usage in URL display_name = "JupyterLab" - url = "http://localhost:${var.port}" + url = var.subdomain ? "http://localhost:${var.port}" : "http://localhost:${var.port}/@${data.coder_workspace_owner.me.name}/${data.coder_workspace.me.name}/apps/jupyterlab" icon = "/icon/jupyter.svg" - subdomain = true + subdomain = var.subdomain share = var.share order = var.order } diff --git a/jupyterlab/run.sh b/jupyterlab/run.sh index 0245b069..aff21b72 100755 --- a/jupyterlab/run.sh +++ b/jupyterlab/run.sh @@ -1,5 +1,9 @@ #!/usr/bin/env sh +if [ -n "${BASE_URL}" ]; then + BASE_URL_FLAG="--ServerApp.base_url=${BASE_URL}" +fi + BOLD='\033[0;1m' printf "$${BOLD}Installing jupyterlab!\n" @@ -15,11 +19,17 @@ if ! command -v jupyterlab > /dev/null 2>&1; then fi # install jupyterlab pipx install -q jupyterlab - echo "🥳 jupyterlab has been installed\n\n" + printf "%s\n\n" "🥳 jupyterlab has been installed" else - echo "🥳 jupyterlab is already installed\n\n" + printf "%s\n\n" "🥳 jupyterlab is already installed" fi -echo "👷 Starting jupyterlab in background..." -echo "check logs at ${LOG_PATH}" -$HOME/.local/bin/jupyter-lab --ServerApp.ip='0.0.0.0' --ServerApp.port=${PORT} --no-browser --ServerApp.token='' --ServerApp.password='' > ${LOG_PATH} 2>&1 & +printf "👷 Starting jupyterlab in background..." +printf "check logs at ${LOG_PATH}" +$HOME/.local/bin/jupyter-lab --no-browser \ + "$BASE_URL_FLAG" \ + --ServerApp.ip='*' \ + --ServerApp.port="${PORT}" \ + --ServerApp.token='' \ + --ServerApp.password='' \ + > "${LOG_PATH}" 2>&1 & From ce5a5b383afe279aa6b4bcc8ca1836537bf6875f Mon Sep 17 00:00:00 2001 From: Steven Masley Date: Mon, 21 Oct 2024 03:46:19 -0500 Subject: [PATCH 4/4] feat(vscode-web): support hosting on a subpath with `subdomain=false` (#288) Co-authored-by: Muhammad Atif Ali Co-authored-by: Muhammad Atif Ali --- CONTRIBUTING.md | 1 + vscode-web/README.md | 8 ++++---- vscode-web/main.tf | 25 ++++++++++++++++++++++--- vscode-web/run.sh | 10 ++++++++-- 4 files changed, 35 insertions(+), 9 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c0a9c0fa..60b1260b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -47,6 +47,7 @@ You can test a module locally by updating the source as follows ```tf module "example" { source = "git::https://github.com//.git//?ref=" + # You may need to remove the 'version' field, it is incompatible with some sources. } ``` diff --git a/vscode-web/README.md b/vscode-web/README.md index 821d5182..8b5fa688 100644 --- a/vscode-web/README.md +++ b/vscode-web/README.md @@ -14,7 +14,7 @@ Automatically install [Visual Studio Code Server](https://code.visualstudio.com/ ```tf module "vscode-web" { source = "registry.coder.com/modules/vscode-web/coder" - version = "1.0.20" + version = "1.0.22" agent_id = coder_agent.example.id accept_license = true } @@ -29,7 +29,7 @@ module "vscode-web" { ```tf module "vscode-web" { source = "registry.coder.com/modules/vscode-web/coder" - version = "1.0.20" + version = "1.0.22" agent_id = coder_agent.example.id install_prefix = "/home/coder/.vscode-web" folder = "/home/coder" @@ -42,7 +42,7 @@ module "vscode-web" { ```tf module "vscode-web" { source = "registry.coder.com/modules/vscode-web/coder" - version = "1.0.20" + version = "1.0.22" agent_id = coder_agent.example.id extensions = ["github.copilot", "ms-python.python", "ms-toolsai.jupyter"] accept_license = true @@ -56,7 +56,7 @@ Configure VS Code's [settings.json](https://code.visualstudio.com/docs/getstarte ```tf module "vscode-web" { source = "registry.coder.com/modules/vscode-web/coder" - version = "1.0.20" + version = "1.0.22" agent_id = coder_agent.example.id extensions = ["dracula-theme.theme-dracula"] settings = { diff --git a/vscode-web/main.tf b/vscode-web/main.tf index 084f8306..207450e5 100644 --- a/vscode-web/main.tf +++ b/vscode-web/main.tf @@ -121,6 +121,18 @@ variable "auto_install_extensions" { default = false } +variable "subdomain" { + type = bool + description = <<-EOT + Determines whether the app will be accessed via it's own subdomain or whether it will be accessed via a path on Coder. + If wildcards have not been setup by the administrator then apps with "subdomain" set to true will not be accessible. + EOT + default = true +} + +data "coder_workspace_owner" "me" {} +data "coder_workspace" "me" {} + resource "coder_script" "vscode-web" { agent_id = var.agent_id display_name = "VS Code Web" @@ -138,6 +150,7 @@ resource "coder_script" "vscode-web" { EXTENSIONS_DIR : var.extensions_dir, FOLDER : var.folder, AUTO_INSTALL_EXTENSIONS : var.auto_install_extensions, + SERVER_BASE_PATH : local.server_base_path, }) run_on_start = true @@ -158,15 +171,21 @@ resource "coder_app" "vscode-web" { agent_id = var.agent_id slug = var.slug display_name = var.display_name - url = var.folder == "" ? "http://localhost:${var.port}" : "http://localhost:${var.port}?folder=${var.folder}" + url = local.url icon = "/icon/code.svg" - subdomain = true + subdomain = var.subdomain share = var.share order = var.order healthcheck { - url = "http://localhost:${var.port}/healthz" + url = local.healthcheck_url interval = 5 threshold = 6 } } + +locals { + server_base_path = var.subdomain ? "" : format("/@%s/%s/apps/%s/", data.coder_workspace_owner.me.name, data.coder_workspace.me.name, var.slug) + url = var.folder == "" ? "http://localhost:${var.port}${local.server_base_path}" : "http://localhost:${var.port}${local.server_base_path}?folder=${var.folder}" + healthcheck_url = var.subdomain ? "http://localhost:${var.port}/healthz" : "http://localhost:${var.port}${local.server_base_path}/healthz" +} diff --git a/vscode-web/run.sh b/vscode-web/run.sh index ecfad68b..1738364e 100755 --- a/vscode-web/run.sh +++ b/vscode-web/run.sh @@ -10,10 +10,16 @@ if [ -n "${EXTENSIONS_DIR}" ]; then EXTENSION_ARG="--extensions-dir=${EXTENSIONS_DIR}" fi +# Set extension directory +SERVER_BASE_PATH_ARG="" +if [ -n "${SERVER_BASE_PATH}" ]; then + SERVER_BASE_PATH_ARG="--server-base-path=${SERVER_BASE_PATH}" +fi + run_vscode_web() { - echo "👷 Running $VSCODE_WEB serve-local $EXTENSION_ARG --port ${PORT} --host 127.0.0.1 --accept-server-license-terms --without-connection-token --telemetry-level ${TELEMETRY_LEVEL} in the background..." + echo "👷 Running $VSCODE_WEB serve-local $EXTENSION_ARG $SERVER_BASE_PATH_ARG --port ${PORT} --host 127.0.0.1 --accept-server-license-terms --without-connection-token --telemetry-level ${TELEMETRY_LEVEL} in the background..." echo "Check logs at ${LOG_PATH}!" - "$VSCODE_WEB" serve-local "$EXTENSION_ARG" --port "${PORT}" --host 127.0.0.1 --accept-server-license-terms --without-connection-token --telemetry-level "${TELEMETRY_LEVEL}" > "${LOG_PATH}" 2>&1 & + "$VSCODE_WEB" serve-local "$EXTENSION_ARG" "$SERVER_BASE_PATH_ARG" --port "${PORT}" --host 127.0.0.1 --accept-server-license-terms --without-connection-token --telemetry-level "${TELEMETRY_LEVEL}" > "${LOG_PATH}" 2>&1 & } # Check if the settings file exists...