Merge branch 'main' into dotfiles
commit
7b4d0878bf
Binary file not shown.
After Width: | Height: | Size: 176 KiB |
Binary file not shown.
After Width: | Height: | Size: 149 KiB |
Binary file not shown.
After Width: | Height: | Size: 20 KiB |
Binary file not shown.
After Width: | Height: | Size: 163 KiB |
Binary file not shown.
After Width: | Height: | Size: 5.2 MiB |
@ -0,0 +1,65 @@
|
|||||||
|
---
|
||||||
|
display_name: MODULE_NAME
|
||||||
|
description: Describe what this module does
|
||||||
|
icon: ../.icons/<A_RELEVANT_ICON>.svg
|
||||||
|
maintainer_github: GITHUB_USERNAME
|
||||||
|
verified: false
|
||||||
|
tags: [helper]
|
||||||
|
---
|
||||||
|
|
||||||
|
# MODULE_NAME
|
||||||
|
|
||||||
|
<!-- Describes what this module does -->
|
||||||
|
|
||||||
|
<!-- Add a screencast or screenshot here put them in .images directory -->
|
||||||
|
|
||||||
|
```hcl
|
||||||
|
module "MODULE_NAME" {
|
||||||
|
source = "https://registry.coder.com/modules/MODULE_NAME"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
### Example 1
|
||||||
|
|
||||||
|
Install the Dracula theme from [OpenVSX](https://open-vsx.org/):
|
||||||
|
|
||||||
|
```hcl
|
||||||
|
module "MODULE_NAME" {
|
||||||
|
source = "https://registry.coder.com/modules/MODULE_NAME"
|
||||||
|
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 "MODULE_NAME" {
|
||||||
|
source = "https://registry.coder.com/modules/MODULE_NAME"
|
||||||
|
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 "MODULE_NAME" {
|
||||||
|
source = "https://registry.coder.com/modules/MODULE_NAME"
|
||||||
|
agent_id = coder_agent.example.id
|
||||||
|
offline = true
|
||||||
|
}
|
||||||
|
```
|
@ -0,0 +1,101 @@
|
|||||||
|
terraform {
|
||||||
|
required_version = ">= 1.0"
|
||||||
|
|
||||||
|
required_providers {
|
||||||
|
coder = {
|
||||||
|
source = "coder/coder"
|
||||||
|
version = ">= 0.12"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
locals {
|
||||||
|
# A built-in icon like "/icon/code.svg" or a full URL of icon
|
||||||
|
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
|
||||||
|
variable "agent_id" {
|
||||||
|
type = string
|
||||||
|
description = "The ID of a Coder agent."
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "log_path" {
|
||||||
|
type = string
|
||||||
|
description = "The path to log MODULE_NAME to."
|
||||||
|
default = "/tmp/MODULE_NAME.log"
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "port" {
|
||||||
|
type = number
|
||||||
|
description = "The port to run MODULE_NAME on."
|
||||||
|
default = 19999
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "mutable" {
|
||||||
|
type = bool
|
||||||
|
description = "Whether the parameter is mutable."
|
||||||
|
default = true
|
||||||
|
}
|
||||||
|
# Add other variables here
|
||||||
|
|
||||||
|
|
||||||
|
resource "coder_script" "MODULE_NAME" {
|
||||||
|
agent_id = var.agent_id
|
||||||
|
display_name = "MODULE_NAME"
|
||||||
|
icon = local.icon_url
|
||||||
|
script = templatefile("${path.module}/run.sh", {
|
||||||
|
LOG_PATH : var.log_path,
|
||||||
|
})
|
||||||
|
run_on_start = true
|
||||||
|
run_on_stopt = false
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "coder_app" "MODULE_NAME" {
|
||||||
|
agent_id = var.agent_id
|
||||||
|
slug = "MODULE_NAME"
|
||||||
|
display_name = "MODULE_NAME"
|
||||||
|
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" "MODULE_NAME" {
|
||||||
|
type = "list(string)"
|
||||||
|
name = "MODULE_NAME"
|
||||||
|
display_name = "MODULE_NAME"
|
||||||
|
icon = local.icon_url
|
||||||
|
mutable = var.mutable
|
||||||
|
default = local.options["Option 1"]["value"]
|
||||||
|
|
||||||
|
dynamic "option" {
|
||||||
|
for_each = local.options
|
||||||
|
content {
|
||||||
|
icon = option.value.icon
|
||||||
|
name = option.value.name
|
||||||
|
value = option.value.value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,17 @@
|
|||||||
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
|
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!"
|
||||||
|
|
||||||
|
echo "Starting ${MODULE_NAME}..."
|
||||||
|
# Start the app in here
|
||||||
|
# 1. Use & to run it in background
|
||||||
|
# 2. redirct stdout and stderr to log files
|
||||||
|
|
||||||
|
./app >${LOG_PATH} 2>&1 &
|
||||||
|
|
||||||
|
echo "Sample app started!"
|
@ -0,0 +1,42 @@
|
|||||||
|
# Contributing
|
||||||
|
|
||||||
|
To create a new module, clone this repository and run:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
./new.sh MOUDLE_NAME
|
||||||
|
```
|
||||||
|
|
||||||
|
Test a module by running an instance of Coder on your local machine:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
coder server --in-memory
|
||||||
|
```
|
||||||
|
|
||||||
|
This will create a new module in the modules directory with the given name and scaffolding.
|
||||||
|
Edit the files, adding your module's implementation, documentation and screenshots.
|
||||||
|
|
||||||
|
## Testing a Module
|
||||||
|
|
||||||
|
Create a template and edit it to include your development module:
|
||||||
|
|
||||||
|
> [!NOTE]
|
||||||
|
> The Docker starter template is recommended for quick-iteration!
|
||||||
|
|
||||||
|
```hcl
|
||||||
|
module "MOUDLE_NAME" {
|
||||||
|
source = "/home/user/coder/modules/MOUDLE_NAME"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
You can also test your module by specifying the source as a git repository:
|
||||||
|
|
||||||
|
```hcl
|
||||||
|
module "MOUDLE_NAME" {
|
||||||
|
source = "git::https://github.com/<USERNAME>/<REPO>.git//<FOLDER>?ref=<BRANCH>"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Build a workspace and your module will be consumed! 🥳
|
||||||
|
|
||||||
|
Open a pull-request with your module, a member of the Coder team will
|
||||||
|
manually test it, and after-merge it will appear on the Registry.
|
@ -1,32 +1,47 @@
|
|||||||
---
|
---
|
||||||
display_name: GCP Regions
|
display_name: GCP Region
|
||||||
description: Add Google Cloud Platform regions to your Coder template.
|
description: Add Google Cloud Platform regions to your Coder template.
|
||||||
icon: ../.icons/gcp.svg
|
icon: ../.icons/gcp.svg
|
||||||
maintainer_github: coder
|
maintainer_github: coder
|
||||||
verified: true
|
verified: true
|
||||||
tags: [gcp, regions, zones, helper]
|
tags: [gcp, regions, parameter, helper]
|
||||||
---
|
---
|
||||||
# Google Cloud Platform Regions
|
# Google Cloud Platform Regions
|
||||||
|
|
||||||
This module adds Google Cloud Platform regions to your Coder template.
|
This module adds Google Cloud Platform regions to your Coder template.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
1. Add only GPU zones in the US West 1 region:
|
1. Add only GPU zones in the US West 1 region:
|
||||||
|
|
||||||
```hcl
|
```hcl
|
||||||
module "regions" {
|
module "gcp_region" {
|
||||||
source = "https://registry.coder.com/modules/gcp-regions"
|
source = "https://registry.coder.com/modules/gcp-region"
|
||||||
default = ["us-west1"]
|
default = ["us-west1-a"]
|
||||||
gpu_only = true
|
regions = ["us-west1"]
|
||||||
|
gpu_only = false
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
2. Add all zones in the Europe West region:
|
2. Add all zones in the Europe West region:
|
||||||
|
|
||||||
```hcl
|
```hcl
|
||||||
module "regions" {
|
module "gcp_region" {
|
||||||
source = "https://registry.coder.com/modules/gcp-regions"
|
source = "https://registry.coder.com/modules/gcp-region"
|
||||||
default = ["europe-west"]
|
regions = ["europe-west"]
|
||||||
|
single_zone_per_region = false
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
3. Add a single zone from each region in US and Europe that laos has GPUs
|
||||||
|
|
||||||
|
```hcl
|
||||||
|
module "gcp_region" {
|
||||||
|
source = "https://registry.coder.com/modules/gcp-region"
|
||||||
|
regions = ["us", "europe"]
|
||||||
|
gpu_only = true
|
||||||
|
single_zone_per_region = true
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
@ -1,16 +0,0 @@
|
|||||||
---
|
|
||||||
display_name: JupyterHub
|
|
||||||
description: A multi-user version of the notebook designed for companies, classrooms and research labs
|
|
||||||
icon: ../.icons/jupyter.svg
|
|
||||||
maintainer_github: coder
|
|
||||||
verified: true
|
|
||||||
tags: [helper, ide]
|
|
||||||
---
|
|
||||||
|
|
||||||
# JupyterHub
|
|
||||||
|
|
||||||
Automatically install [JupyterHub](https://jupyter.org/hub) in a workspace, and create an app to access it via the dashboard.
|
|
||||||
|
|
||||||
## Examples
|
|
||||||
|
|
||||||
TODO
|
|
@ -0,0 +1,21 @@
|
|||||||
|
---
|
||||||
|
display_name: JupyterLab
|
||||||
|
description: A module that adds JupyterLab in your Coder template.
|
||||||
|
icon: ../.icons/jupyter.svg
|
||||||
|
maintainer_github: coder
|
||||||
|
verified: true
|
||||||
|
tags: [jupyter, helper, ide, web]
|
||||||
|
---
|
||||||
|
|
||||||
|
# JupyterLab
|
||||||
|
|
||||||
|
A module that adds JupyterLab in your Coder template.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
```hcl
|
||||||
|
module "jupyterlab" {
|
||||||
|
source = "https://registry.coder.com/modules/jupyterlab"
|
||||||
|
agent_id = coder_agent.example.id
|
||||||
|
}
|
||||||
|
```
|
@ -0,0 +1,54 @@
|
|||||||
|
terraform {
|
||||||
|
required_version = ">= 1.0"
|
||||||
|
|
||||||
|
required_providers {
|
||||||
|
coder = {
|
||||||
|
source = "coder/coder"
|
||||||
|
version = ">= 0.12"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
locals {
|
||||||
|
icon_url = "/icon/jupyter.svg"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Add required variables for your modules and remove any unneeded variables
|
||||||
|
variable "agent_id" {
|
||||||
|
type = string
|
||||||
|
description = "The ID of a Coder agent."
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "log_path" {
|
||||||
|
type = string
|
||||||
|
description = "The path to log jupyterlab to."
|
||||||
|
default = "/tmp/jupyterlab.log"
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "port" {
|
||||||
|
type = number
|
||||||
|
description = "The port to run jupyterlab on."
|
||||||
|
default = 19999
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "coder_script" "jupyterlab" {
|
||||||
|
agent_id = var.agent_id
|
||||||
|
display_name = "jupyterlab"
|
||||||
|
icon = local.icon_url
|
||||||
|
script = templatefile("${path.module}/run.sh", {
|
||||||
|
LOG_PATH : var.log_path,
|
||||||
|
PORT : var.port
|
||||||
|
})
|
||||||
|
run_on_start = true
|
||||||
|
run_on_stopt = false
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "coder_app" "jupyterlab" {
|
||||||
|
agent_id = var.agent_id
|
||||||
|
slug = "jupyterlab"
|
||||||
|
display_name = "JupyterLab"
|
||||||
|
url = "http://localhost:${var.port}"
|
||||||
|
icon = local.icon_url
|
||||||
|
subdomain = true
|
||||||
|
share = "owner"
|
||||||
|
}
|
@ -0,0 +1,22 @@
|
|||||||
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
|
echo "Instalalting ${MODULE_NAME}..."
|
||||||
|
|
||||||
|
# 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
|
||||||
|
pip3 install jupyterlab
|
||||||
|
echo "jupyterlab installed!"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Starting ${MODULE_NAME}..."
|
||||||
|
|
||||||
|
$HOME/.local/bin/jupyter lab --no-browser --LabApp.token='' --LabApp.password='' >${LOG_PATH} 2>&1 &
|
||||||
|
|
||||||
|
echo "Started ${MODULE_NAME}!"
|
@ -0,0 +1,55 @@
|
|||||||
|
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 KasmVNC on."
|
||||||
|
default = 8443
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "desktop_environment" {
|
||||||
|
type = string
|
||||||
|
description = "The desktop environment to for KasmVNC (xfce, lxde, mate, etc)."
|
||||||
|
default = "lxde"
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "version" {
|
||||||
|
type = string
|
||||||
|
description = "Version of KasmVNC to install."
|
||||||
|
default = "1.2.0"
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "coder_script" "kasm_vnc" {
|
||||||
|
agent_id = var.agent_id
|
||||||
|
display_name = "KasmVNC"
|
||||||
|
icon = "/icon/kasmvnc.svg"
|
||||||
|
script = templatefile("${path.module}/run.sh", {
|
||||||
|
PORT : var.port,
|
||||||
|
DESKTOP_ENVIRONMENT : var.desktop_environment,
|
||||||
|
VERSION : var.version
|
||||||
|
})
|
||||||
|
run_on_start = true
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "coder_app" "kasm_vnc" {
|
||||||
|
agent_id = var.agent_id
|
||||||
|
slug = "kasm-vnc"
|
||||||
|
display_name = "kasmVNC"
|
||||||
|
url = "http://localhost:${var.port}"
|
||||||
|
icon = "/icon/kasmvnc.svg"
|
||||||
|
subdomain = false
|
||||||
|
share = "owner"
|
||||||
|
}
|
@ -0,0 +1,40 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# Check if desktop enivronment is installed
|
||||||
|
if ! dpkg -s ${DESKTOP_ENVIRONMENT} &>/dev/null; then
|
||||||
|
sudo apt-get update
|
||||||
|
DEBIAN_FRONTEND=noninteractive sudo apt-get install -y ${DESKTOP_ENVIRONMENT}
|
||||||
|
else
|
||||||
|
echo "${DESKTOP_ENVIRONMENT} is already installed."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check if vncserver is installed
|
||||||
|
if ! dpkg -s kasmvncserver &>/dev/null; then
|
||||||
|
cd /tmp
|
||||||
|
wget https://github.com/kasmtech/KasmVNC/releases/download/v${VERSION}/kasmvncserver_focal_${VERSION}_amd64.deb
|
||||||
|
sudo apt install -y ./kasmvncserver_focal_${VERSION}_amd64.deb
|
||||||
|
printf "🥳 KasmVNC v${VERSION} has been successfully installed!\n\n"
|
||||||
|
else
|
||||||
|
echo "KasmVNC is already installed."
|
||||||
|
fi
|
||||||
|
|
||||||
|
sudo addgroup $USER ssl-cert
|
||||||
|
|
||||||
|
# Coder port-forwarding from dashboard only supports HTTP
|
||||||
|
sudo bash -c 'cat > /etc/kasmvnc/kasmvnc.yaml <<EOF
|
||||||
|
network:
|
||||||
|
protocol: http
|
||||||
|
websocekt_port: ${PORT}
|
||||||
|
ssl:
|
||||||
|
require_ssl: false
|
||||||
|
udp:
|
||||||
|
public_ip: 127.0.0.1
|
||||||
|
EOF'
|
||||||
|
|
||||||
|
# This password is not used since we start the server without auth.
|
||||||
|
# The server is protected via the Coder session token / tunnel
|
||||||
|
# and does not listen publicly on the VM
|
||||||
|
echo -e "password\npassword\n" | vncpasswd -wo -u $USER
|
||||||
|
|
||||||
|
# Start the server :)
|
||||||
|
sudo su -u $USER bash -c 'vncserver -select-de "${DESKTOP_ENVIRONMENT}" -disableBasicAuth'
|
@ -1 +1,40 @@
|
|||||||
#!/usr/bin/env sh
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
|
# This scripts creates a new sample moduledir with requried files
|
||||||
|
# Run it like : ./new.sh my-module
|
||||||
|
|
||||||
|
MODULE_NAME=$1
|
||||||
|
|
||||||
|
# Check if module name is provided
|
||||||
|
if [ -z "$MODULE_NAME" ]; then
|
||||||
|
echo "Usage: ./new.sh <module_name>"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Create module directory and exit if it alredy exists
|
||||||
|
if [ -d "$MODULE_NAME" ]; then
|
||||||
|
echo "Module with name $MODULE_NAME already exists"
|
||||||
|
echo "Please choose a different name"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
mkdir -p "${MODULE_NAME}"
|
||||||
|
|
||||||
|
# Copy required files from the sample module
|
||||||
|
cp -r .sample/* "${MODULE_NAME}"
|
||||||
|
|
||||||
|
# Change to module directory
|
||||||
|
cd "${MODULE_NAME}"
|
||||||
|
|
||||||
|
# Detect OS
|
||||||
|
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||||
|
# macOS
|
||||||
|
sed -i '' "s/MODULE_NAME/${MODULE_NAME}/g" main.tf
|
||||||
|
sed -i '' "s/MODULE_NAME/${MODULE_NAME}/g" README.md
|
||||||
|
else
|
||||||
|
# Linux
|
||||||
|
sed -i "s/MODULE_NAME/${MODULE_NAME}/g" main.tf
|
||||||
|
sed -i "s/MODULE_NAME/${MODULE_NAME}/g" README.md
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Make run.sh executable
|
||||||
|
chmod +x run.sh
|
||||||
|
@ -0,0 +1,38 @@
|
|||||||
|
---
|
||||||
|
display_name: vscode-server
|
||||||
|
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 CLIs](https://code.visualstudio.com/docs/editor/command-line) and create an app to access it via the dashboard.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
1. Install VS Code Server with default settings:
|
||||||
|
|
||||||
|
```hcl
|
||||||
|
module "vscode-web" {
|
||||||
|
source = "https://registry.coder.com/modules/vscode-server"
|
||||||
|
agent_id = coder_agent.example.id
|
||||||
|
accept_license = true
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
2. 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
|
||||||
|
}
|
||||||
|
```
|
@ -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-server."
|
||||||
|
default = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "log_path" {
|
||||||
|
type = string
|
||||||
|
description = "The path to log."
|
||||||
|
default = "/tmp/vscode-server.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-server" {
|
||||||
|
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-server" {
|
||||||
|
agent_id = var.agent_id
|
||||||
|
slug = "vscode-server"
|
||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
@ -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 &
|
Loading…
Reference in New Issue