chore: update metadata (#54)
This commit is contained in:
committed by
GitHub
parent
ab527c8ffd
commit
c3d8a9949c
36
vscode-web/README.md
Normal file
36
vscode-web/README.md
Normal file
@@ -0,0 +1,36 @@
|
||||
---
|
||||
display_name: VS Code Web
|
||||
description: VS Code Web - Visual Studio Code in the browser
|
||||
icon: ../.icons/code.svg
|
||||
maintainer_github: coder
|
||||
verified: true
|
||||
tags: [helper, ide, vscode, web]
|
||||
---
|
||||
|
||||
# VS Code Web
|
||||
|
||||
Automatically install [Visual Studio Code Server](https://code.visualstudio.com/docs/remote/vscode-server) in a workspace using the [VS Code CLI](https://code.visualstudio.com/docs/editor/command-line) and create an app to access it via the dashboard.
|
||||
|
||||
```hcl
|
||||
module "vscode-web" {
|
||||
source = "https://registry.coder.com/modules/vscode-server"
|
||||
agent_id = coder_agent.example.id
|
||||
accept_license = true
|
||||
}
|
||||
```
|
||||
|
||||

|
||||
|
||||
## Examples
|
||||
|
||||
### Install VS Code Server to a custom folder
|
||||
|
||||
```hcl
|
||||
module "vscode-web" {
|
||||
source = "https://registry.coder.com/modules/vscode-server"
|
||||
agent_id = coder_agent.example.id
|
||||
install_dir = "/home/coder/.vscode-server"
|
||||
folder = "/home/coder"
|
||||
accept_license = true
|
||||
}
|
||||
```
|
||||
77
vscode-web/main.tf
Normal file
77
vscode-web/main.tf
Normal file
@@ -0,0 +1,77 @@
|
||||
terraform {
|
||||
required_version = ">= 1.0"
|
||||
|
||||
required_providers {
|
||||
coder = {
|
||||
source = "coder/coder"
|
||||
version = ">= 0.12"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
variable "agent_id" {
|
||||
type = string
|
||||
description = "The ID of a Coder agent."
|
||||
}
|
||||
|
||||
variable "port" {
|
||||
type = number
|
||||
description = "The port to run VS Code Web on."
|
||||
default = 13338
|
||||
}
|
||||
|
||||
variable "folder" {
|
||||
type = string
|
||||
description = "The folder to open in vscode-web."
|
||||
default = ""
|
||||
}
|
||||
|
||||
variable "log_path" {
|
||||
type = string
|
||||
description = "The path to log."
|
||||
default = "/tmp/vscode-web.log"
|
||||
}
|
||||
|
||||
variable "install_dir" {
|
||||
type = string
|
||||
description = "The directory to install VS Code CLI"
|
||||
default = "/tmp/vscode-cli"
|
||||
}
|
||||
|
||||
variable "accept_license" {
|
||||
type = bool
|
||||
description = "Accept the VS Code license. https://code.visualstudio.com/license"
|
||||
default = false
|
||||
validation {
|
||||
condition = var.accept_license == true
|
||||
error_message = "You must accept the VS Code license agreement by setting accept_license=true."
|
||||
}
|
||||
}
|
||||
|
||||
resource "coder_script" "vscode-web" {
|
||||
agent_id = var.agent_id
|
||||
display_name = "VS Code Web"
|
||||
icon = "/icon/code.svg"
|
||||
script = templatefile("${path.module}/run.sh", {
|
||||
PORT : var.port,
|
||||
LOG_PATH : var.log_path,
|
||||
INSTALL_DIR : var.install_dir,
|
||||
})
|
||||
run_on_start = true
|
||||
}
|
||||
|
||||
resource "coder_app" "vscode-web" {
|
||||
agent_id = var.agent_id
|
||||
slug = "vscode-web"
|
||||
display_name = "VS Code Web"
|
||||
url = var.folder == "" ? "http://localhost:${var.port}" : "http://localhost:${var.port}?folder=${var.folder}"
|
||||
icon = "/icon/code.svg"
|
||||
subdomain = true
|
||||
share = "owner"
|
||||
|
||||
healthcheck {
|
||||
url = "http://localhost:${var.port}/healthz"
|
||||
interval = 5
|
||||
threshold = 6
|
||||
}
|
||||
}
|
||||
21
vscode-web/run.sh
Normal file
21
vscode-web/run.sh
Normal file
@@ -0,0 +1,21 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
BOLD='\033[0;1m'
|
||||
|
||||
# Create install directory if it doesn't exist
|
||||
mkdir -p ${INSTALL_DIR}
|
||||
|
||||
printf "$${BOLD}Installing vscode-cli!\n"
|
||||
|
||||
# Download and extract code-cli tarball
|
||||
output=$(curl -Lk 'https://code.visualstudio.com/sha/download?build=stable&os=cli-alpine-x64' --output vscode_cli.tar.gz && tar -xf vscode_cli.tar.gz -C ${INSTALL_DIR} && rm vscode_cli.tar.gz)
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Failed to install vscode-cli: $output"
|
||||
exit 1
|
||||
fi
|
||||
printf "🥳 vscode-cli has been installed.\n\n"
|
||||
|
||||
echo "👷 Running ${INSTALL_DIR}/bin/code serve-web --port ${PORT} --without-connection-token --accept-server-license-terms in the background..."
|
||||
echo "Check logs at ${LOG_PATH}!"
|
||||
${INSTALL_DIR}/code serve-web --port ${PORT} --without-connection-token --accept-server-license-terms >${LOG_PATH} 2>&1 &
|
||||
Reference in New Issue
Block a user