Merge branch 'main' into git-config

pull/47/head
Stephen Kirby 2 years ago committed by GitHub
commit 5810699435
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

1
.gitignore vendored

@ -0,0 +1 @@
.terraform*

@ -0,0 +1,10 @@
<svg version="1.0" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 185.69 237" enable-background="new 0 0 185.69 237" xml:space="preserve">
<g>
<path fill="#333333" d="M135.96,0h-1.06H16.93C7.58,0,0,7.58,0,16.93v203.14C0,229.42,7.58,237,16.93,237h151.83
c9.35,0,16.93-7.58,16.93-16.93V50.79v-1.06L135.96,0z"/>
<circle fill="#3FA9F5" cx="92.84" cy="118.5" r="25.39"/>
<line fill="#1A1A1A" x1="185.69" y1="50.79" x2="134.9" y2="0"/>
<path fill="#3FA9F5" d="M135.96,32.8c0,9.35,7.58,16.93,16.93,16.93h32.8L135.96,0V32.8z"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 600 B

@ -1 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" width="92pt" height="92pt" viewBox="0 0 92 92"><defs><clipPath id="a"><path d="M0 .113h91.887V92H0Zm0 0"/></clipPath></defs><g clip-path="url(#a)"><path style="stroke:none;fill-rule:nonzero;fill:#f03c2e;fill-opacity:1" d="M90.156 41.965 50.036 1.848a5.918 5.918 0 0 0-8.372 0l-8.328 8.332 10.566 10.566a7.03 7.03 0 0 1 7.23 1.684 7.034 7.034 0 0 1 1.669 7.277l10.187 10.184a7.028 7.028 0 0 1 7.278 1.672 7.04 7.04 0 0 1 0 9.957 7.05 7.05 0 0 1-9.965 0 7.044 7.044 0 0 1-1.528-7.66l-9.5-9.497V59.36a7.04 7.04 0 0 1 1.86 11.29 7.04 7.04 0 0 1-9.957 0 7.04 7.04 0 0 1 0-9.958 7.06 7.06 0 0 1 2.304-1.539V33.926a7.049 7.049 0 0 1-3.82-9.234L29.242 14.272 1.73 41.777a5.925 5.925 0 0 0 0 8.371L41.852 90.27a5.925 5.925 0 0 0 8.37 0l39.934-39.934a5.925 5.925 0 0 0 0-8.371"/></g></svg>
<svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve" width="97" height="97">
<path fill="#F05133" d="M92.71 44.408 52.591 4.291c-2.31-2.311-6.057-2.311-8.369 0l-8.33 8.332L46.459 23.19c2.456-.83 5.272-.273 7.229 1.685 1.969 1.97 2.521 4.81 1.67 7.275l10.186 10.185c2.465-.85 5.307-.3 7.275 1.671 2.75 2.75 2.75 7.206 0 9.958-2.752 2.751-7.208 2.751-9.961 0-2.068-2.07-2.58-5.11-1.531-7.658l-9.5-9.499v24.997c.67.332 1.303.774 1.861 1.332 2.75 2.75 2.75 7.206 0 9.959-2.75 2.749-7.209 2.749-9.957 0-2.75-2.754-2.75-7.21 0-9.959.68-.679 1.467-1.193 2.307-1.537v-25.23c-.84-.344-1.625-.853-2.307-1.537-2.083-2.082-2.584-5.14-1.516-7.698L31.798 16.715 4.288 44.222c-2.311 2.313-2.311 6.06 0 8.371l40.121 40.118c2.31 2.311 6.056 2.311 8.369 0L92.71 52.779c2.311-2.311 2.311-6.06 0-8.371z"/>
</svg>

Before

Width:  |  Height:  |  Size: 819 B

After

Width:  |  Height:  |  Size: 803 B

@ -0,0 +1 @@
<svg xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 47.5 47.5" style="enable-background:new 0 0 47.5 47.5;" id="svg2" xml:space="preserve"><defs id="defs6"><clipPath id="clipPath18"><path d="M 0,38 38,38 38,0 0,0 0,38 z" id="path20"/></clipPath></defs><g transform="matrix(1.25,0,0,-1.25,0,47.5)" id="g12"><g id="g14"><g clip-path="url(#clipPath18)" id="g16"><g transform="translate(21.8486,9.4102)" id="g22"><path d="m 0,0 c -0.395,-1.346 -2.46,-1.924 -4.613,-1.291 -2.153,0.632 -3.578,2.234 -3.183,3.581 0.395,1.346 2.461,1.924 4.613,1.29 C -1.029,2.949 0.396,1.347 0,0 m -2.849,24.447 c -9.941,0 -18,-6.908 -18,-15.428 0,-1.067 0.127,-2.108 0.367,-3.113 1.779,-3.06 3.01,-1.128 8.633,1.684 5.727,2.864 0,-4 -2,-8 -0.615,-1.231 -0.281,-2.272 0.56,-3.124 2.946,-1.804 6.544,-2.876 10.44,-2.876 9.942,0 18,6.907 18,15.429 0,8.52 -8.058,15.428 -18,15.428" id="path24" style="fill:#d99e82;fill-opacity:1;fill-rule:nonzero;stroke:none"/></g><g transform="translate(14,26)" id="g26"><path d="m 0,0 c 0,-1.657 -1.343,-3 -3,-3 -1.657,0 -3,1.343 -3,3 0,1.657 1.343,3 3,3 1.657,0 3,-1.343 3,-3" id="path28" style="fill:#5c913b;fill-opacity:1;fill-rule:nonzero;stroke:none"/></g><g transform="translate(24,28)" id="g30"><path d="m 0,0 c 0,-1.657 -1.344,-3 -3,-3 -1.657,0 -3,1.343 -3,3 0,1.657 1.343,3 3,3 1.656,0 3,-1.343 3,-3" id="path32" style="fill:#226699;fill-opacity:1;fill-rule:nonzero;stroke:none"/></g><g transform="translate(33,22)" id="g34"><path d="m 0,0 c 0,-1.657 -1.344,-3 -3,-3 -1.656,0 -3,1.343 -3,3 0,1.657 1.344,3 3,3 1.656,0 3,-1.343 3,-3" id="path36" style="fill:#dd2e44;fill-opacity:1;fill-rule:nonzero;stroke:none"/></g><g transform="translate(32,13)" id="g38"><path d="m 0,0 c 0,-1.656 -1.344,-3 -3,-3 -1.656,0 -3,1.344 -3,3 0,1.656 1.344,3 3,3 1.656,0 3,-1.344 3,-3" id="path40" style="fill:#ffcc4d;fill-opacity:1;fill-rule:nonzero;stroke:none"/></g></g></g></g></svg>

After

Width:  |  Height:  |  Size: 1.9 KiB

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.

@ -32,30 +32,4 @@ Check out the [Coder Registry](https://registry.coder.com) for instructions to i
## Contributing a Module
To quickly start contributing with a new module, clone this repository and run:
```sh
./new.sh
```
Test a module by running an instance of Coder on your local machine:
```bash
coder server --in-memory
```
Create a template and edit it to include your development module:
> *Info*
> The Docker starter template is recommended for quick-iteration!
```tf
module "testing" {
source = "/home/user/coder/modules/my-new-module"
}
```
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.
See [CONTRIBUTING.md](./CONTRIBUTING.md) for instructions on how to construct and publish a module to the [Coder Registry](https://registry.coder.com).

@ -4,7 +4,7 @@ description: A parameter with human region names and icons
icon: ../.icons/aws.svg
maintainer_github: coder
verified: true
tags: [helper, parameter]
tags: [helper, parameter, regions, aws]
---
# AWS Region
@ -12,6 +12,8 @@ tags: [helper, parameter]
A parameter with all AWS regions. This allows developers to select
the region closest to them.
![AWS Regions](../.images/aws-region.png)
## Examples
### Default Region

@ -4,7 +4,7 @@ description: A parameter with human region names and icons
icon: ../.icons/azure.svg
maintainer_github: coder
verified: true
tags: [helper, parameter, azure]
tags: [helper, parameter, azure, regions]
---
# Azure Region
@ -59,4 +59,4 @@ module "azure-region" {
resource "azurerm_resource_group" "example" {
location = module.azure_region.value
}
```
```

@ -4,7 +4,7 @@ description: VS Code in the browser
icon: ../.icons/code.svg
maintainer_github: coder
verified: true
tags: [helper, ide]
tags: [helper, ide, web]
---
# code-server
@ -63,4 +63,4 @@ module "settings" {
agent_id = coder_agent.example.id
offline = true
}
```
```

@ -0,0 +1,12 @@
---
display_name: Dotfiles
description: Allow developers to optionally bring their own dotfiles repository to customize their shell and IDE settings!
icon: ../.icons/dotfiles.svg
maintainer_github: coder
verified: true
tags: [helper]
---
# Dotfiles
Allow developers to optionally bring their own [dotfiles repository](https://dotfiles.github.io)! Under the hood, this module uses the [coder dotfiles](https://coder.com/docs/v2/latest/dotfiles) command.

@ -0,0 +1,37 @@
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."
}
data "coder_parameter" "dotfiles_uri" {
type = "string"
display_name = "Dotfiles URL (optional)"
default = ""
description = "Enter a URL for a [dotfiles repository](https://dotfiles.github.io) to personalize your workspace"
mutable = true
icon = "https://raw.githubusercontent.com/jglovier/dotfiles-logo/main/dotfiles-logo-icon.svg"
}
resource "coder_script" "personalize" {
agent_id = var.agent_id
script = <<-EOT
DOTFILES_URI="${data.coder_parameter.dotfiles_uri.value}"
if [ -n "$${DOTFILES_URI// }" ]; then
coder dotfiles "$DOTFILES_URI" -y 2>&1 | tee -a ~/.dotfiles.log
fi
EOT
display_name = "Dotfiles"
icon = "https://raw.githubusercontent.com/jglovier/dotfiles-logo/main/dotfiles-logo-icon.svg"
run_on_start = true
}

@ -1,32 +1,47 @@
---
display_name: GCP Regions
display_name: GCP Region
description: Add Google Cloud Platform regions to your Coder template.
icon: ../.icons/gcp.svg
maintainer_github: coder
verified: true
tags: [gcp, regions, zones, helper]
tags: [gcp, regions, parameter, helper]
---
# Google Cloud Platform Regions
This module adds Google Cloud Platform regions to your Coder template.
![GCP Regions](../.images/gcp-regions.png)
## Examples
1. Add only GPU zones in the US West 1 region:
```hcl
module "regions" {
source = "https://registry.coder.com/modules/gcp-regions"
default = ["us-west1"]
gpu_only = true
module "gcp_region" {
source = "https://registry.coder.com/modules/gcp-region"
default = ["us-west1-a"]
regions = ["us-west1"]
gpu_only = false
}
```
2. Add all zones in the Europe West region:
```hcl
module "regions" {
source = "https://registry.coder.com/modules/gcp-regions"
default = ["europe-west"]
module "gcp_region" {
source = "https://registry.coder.com/modules/gcp-region"
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
}
```

@ -22,6 +22,12 @@ variable "description" {
}
variable "default" {
default = null
description = "Default zone"
type = string
}
variable "regions" {
description = "List of GCP regions to include."
type = list(string)
default = ["us-central1"]
@ -51,6 +57,12 @@ variable "custom_icons" {
type = map(string)
}
variable "single_zone_per_region" {
default = true
description = "Whether to only include a single zone per region."
type = bool
}
locals {
zones = {
# US Central
@ -343,17 +355,17 @@ locals {
"europe-west2-a" = {
gpu = true
name = "London, England (a)"
icon = "/emojis/1f173-1f1ff.png"
icon = "/emojis/1f1ec-1f1e7.png"
}
"europe-west2-b" = {
gpu = true
name = "London, England (b)"
icon = "/emojis/1f173-1f1ff.png"
icon = "/emojis/1f1ec-1f1e7.png"
}
"europe-west2-c" = {
gpu = false
name = "London, England (c)"
icon = "/emojis/1f173-1f1ff.png"
icon = "/emojis/1f1ec-1f1e7.png"
}
"europe-west3-b" = {
@ -702,14 +714,16 @@ data "coder_parameter" "region" {
description = var.description
icon = "/icon/gcp.png"
mutable = var.mutable
default = var.default != null && var.default != "" ? var.default : null
dynamic "option" {
for_each = {
for k, v in local.zones : k => v
if anytrue([for d in var.default : startswith(k, d)]) && (!var.gpu_only || v.gpu)
if anytrue([for d in var.regions : startswith(k, d)]) && (!var.gpu_only || v.gpu) && (!var.single_zone_per_region || endswith(k, "-a"))
}
content {
icon = try(var.custom_icons[option.key], option.value.icon)
name = try(var.custom_names[option.key], option.value.name)
icon = try(var.custom_icons[option.key], option.value.icon)
# if single_zone_per_region is true, remove the zone letter from the name
name = try(var.custom_names[option.key], var.single_zone_per_region ? substr(option.value.name, 0, length(option.value.name) - 4) : option.value.name)
description = option.key
value = option.key
}
@ -717,5 +731,11 @@ data "coder_parameter" "region" {
}
output "value" {
value = data.coder_parameter.region.value
description = "GCP zone identifier."
value = data.coder_parameter.region.value
}
output "region" {
description = "GCP region identifier."
value = substr(data.coder_parameter.region.value, 0, length(data.coder_parameter.region.value) - 2)
}

@ -0,0 +1,38 @@
---
display_name: Git Clone
description: Clone a Git repository by URL and skip if it exists.
icon: ../.icons/git.svg
maintainer_github: coder
verified: true
tags: [git, helper]
---
# Git Clone
This module allows you to automatically clone a repository by URL and skip if it exists in the path provided.
```hcl
module "git-clone" {
source = "https://registry.coder.com/modules/git-clone"
url = "https://github.com/coder/coder"
}
```
To use with [Git Authentication](https://coder.com/docs/v2/latest/admin/git-providers), add the provider by ID to your template:
```hcl
data "coder_git_auth" "github" {
id = "github"
}
```
## Examples
### Custom Path
```hcl
module "git-clone" {
source = "https://registry.coder.com/modules/git-clone"
url = "https://github.com/coder/coder"
path = "~/projects/coder/coder"
}
```

@ -0,0 +1,37 @@
terraform {
required_version = ">= 1.0"
required_providers {
coder = {
source = "coder/coder"
version = ">= 0.11"
}
}
}
variable "url" {
description = "The URL of the Git repository."
type = string
}
variable "path" {
default = ""
description = "The path to clone the repository. Defaults to \"$HOME/<basename of url>\"."
type = string
}
variable "agent_id" {
description = "The ID of a Coder agent."
type = string
}
resource "coder_script" "git_clone" {
agent_id = var.agent_id
display_name = "Git Clone"
icon = "/icons/git.svg"
script = templatefile("${path.module}/run.sh", {
CLONE_PATH: var.path != "" ? var.path : join("/", ["~", basename(var.url)]),
REPO_URL: var.url,
})
run_on_start = true
}

@ -0,0 +1,38 @@
#!/usr/bin/env sh
REPO_URL="${REPO_URL}"
CLONE_PATH="${CLONE_PATH}"
# Expand home if it's specified!
CLONE_PATH="$${CLONE_PATH/#\~/$${HOME}}"
# Check if the variable is empty...
if [ -z "$REPO_URL" ]; then
echo "No repository specified!"
exit 1
fi
# Check if the variable is empty...
if [ -z "$CLONE_PATH" ]; then
echo "No clone path specified!"
exit 1
fi
# Check if `git` is installed...
if ! command -v git >/dev/null; then
echo "Git is not installed!"
exit 1
fi
# Check if the directory exists...
if [ ! -d "$CLONE_PATH" ]; then
echo "Creating directory $CLONE_PATH..."
mkdir -p "$CLONE_PATH"
else
echo "$CLONE_PATH already exists, skipping clone!"
exit 0
fi
# Clone the repository...
echo "Cloning $REPO_URL to $CLONE_PATH..."
git clone "$REPO_URL" "$CLONE_PATH"

@ -4,29 +4,32 @@ description: Add a one-click button to launch JetBrains Gateway IDEs in the dash
icon: ../.icons/gateway.svg
maintainer_github: coder
verified: true
tags: [ide, jetbrains, gateway, goland, webstorm, intellij, pycharm, phpstorm, clion, rubymine, datagrip, rider]
tags: [ide, jetbrains, helper, parameter]
---
# JetBrains Gateway
This module adds a JetBrains Gateway IDEs to your Coder template.
This module adds a JetBrains Gateway Button to open any workspace with a single click.
## How to use this module
![JetBrains Gateway IDes list](../.images/jetbrains-gateway.png)
To use this module, add the following snippet to your template manifest:
## Examples
### Add GoLand and WebStorm with the default set to GoLand
```hcl
module "jetbrains_gateway" {
source = "https://registry.coder.com/modules/jetbrains-gateway"
agent_id = coder_agent.main.id
agent_name = "main"
project_directory = "/home/coder/project"
gateway_ide_product_code = ["GO","WS"] # A list of JetBrains product codes use ["ALL"] for all products
agent_id = coder_agent.example.id
agent_name = "example"
project_directory = "/home/coder/example"
jetbrains_ides = ["GO", "WS"]
default = "GO"
}
```
## Supported IDEs
The following JetBrains IDEs are supported:
This module and JetBrains Gateway support the following JetBrains IDEs:
- GoLand (`GO`)
- WebStorm (`WS`)

@ -24,23 +24,26 @@ variable "project_directory" {
description = "The directory to open in the IDE. e.g. /home/coder/project"
}
variable "gateway_ide_product_code" {
variable "default" {
type = string
description = "Default IDE"
}
variable "jetbrains_ides" {
type = list(string)
description = "The list of IDE product codes, e.g. ['GO', 'WS'] or ['ALL']"
default = ["ALL"]
description = "The list of IDE product codes."
validation {
condition = (
length(var.gateway_ide_product_code) == 1 && var.gateway_ide_product_code[0] == "ALL" ||
alltrue([
for code in var.gateway_ide_product_code : contains(["IU", "IC", "PS", "WS", "PY", "PC", "CL", "GO", "DB", "RD", "RM"], code)
for code in var.jetbrains_ides : contains(["IU", "IC", "PS", "WS", "PY", "PC", "CL", "GO", "DB", "RD", "RM"], code)
])
)
error_message = "The gateway_ide_product_code must be ['ALL'] or a list of valid product codes. https://plugins.jetbrains.com/docs/marketplace/product-codes.html"
error_message = "The jetbrains_ides must be a list of valid product codes. https://plugins.jetbrains.com/docs/marketplace/product-codes.html"
}
}
locals {
gateway_ides = {
jetbrains_ides = {
"GO" = {
icon = "/icon/goland.svg",
name = "GoLand",
@ -105,10 +108,10 @@ data "coder_parameter" "jetbrains_ide" {
display_name = "JetBrains IDE"
icon = "/icon/gateway.svg"
mutable = true
default = local.gateway_ides["GO"].value
default = var.default != null && var.default != "" ? local.jetbrains_ides[var.default].value : null
dynamic "option" {
for_each = contains(var.gateway_ide_product_code, "ALL") ? local.gateway_ides : { for key, value in local.gateway_ides : key => value if contains(var.gateway_ide_product_code, key) }
for_each = { for key, value in local.jetbrains_ides : key => value if contains(var.jetbrains_ides, key) }
content {
icon = option.value.icon
name = option.value.name
@ -127,3 +130,7 @@ resource "coder_app" "gateway" {
icon = data.coder_parameter.jetbrains_ide.option[index(data.coder_parameter.jetbrains_ide.option.*.value, data.coder_parameter.jetbrains_ide.value)].icon
external = true
}
output "jetbrains_ides" {
value = data.coder_parameter.jetbrains_ide.value
}

@ -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.
![JupyterLab](../.images/jupyterlab.webp)
```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}!"

@ -4,7 +4,7 @@ description: A modern open source VNC server
icon: ../.icons/kasmvnc.svg
maintainer_github: coder
verified: true
tags: [helper, ide]
tags: [helper, VNC, web]
---
# KasmVNC
@ -13,4 +13,27 @@ Automatically install [KasmVNC](https://kasmweb.com/kasmvnc) in a workspace, and
## Examples
TODO
1. Add latest version of KasmVNC with [`lxde`](https://www.lxde.org/) desktop environment:
```hcl
module "kasmvnc" {
source = "https://registry.coder.com/modules/kasmvnc"
agent_id = coder_agent.example.id
}
```
2. Add specific version of KasmVNC with [`mate`](https://mate-desktop.org/) desktop environment and custom port:
```hcl
module "kasmvnc" {
source = "https://registry.coder.com/modules/kasmvnc"
agent_id = coder_agent.example.id
version = "1.0.0"
desktop_environment = "mate"
port = 6080
}
```
![Screenshot of KasmVNC]() //TODO

@ -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
# 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

@ -20,6 +20,12 @@ variable "path" {
default = "~/personalize"
}
variable "log_path" {
type = string
description = "The path to a log file that will contain the output of the personalize script."
default = "~/personalize.log"
}
resource "coder_script" "personalize" {
agent_id = var.agent_id
script = templatefile("${path.module}/run.sh", {
@ -27,5 +33,6 @@ resource "coder_script" "personalize" {
})
display_name = "Personalize"
icon = "/emojis/1f58c.png"
log_path = var.log_path
run_on_start = true
}

@ -4,6 +4,7 @@ BOLD='\033[0;1m'
CODE='\033[36;40;1m'
RESET='\033[0m'
SCRIPT="${PERSONALIZE_PATH}"
SCRIPT="$${SCRIPT/#\~/$${HOME}}"
# If the personalize script doesn't exist, educate
# the user how they can customize their environment!
@ -23,4 +24,4 @@ if [ ! -x $SCRIPT ]; then
fi
# Run the personalize script!
exec $SCRIPT
$SCRIPT

@ -4,6 +4,7 @@ description: Add a one-click button to launch VS Code Desktop
icon: ../.icons/code.svg
maintainer_github: coder
verified: true
tags: [ide, vscode, helper]
---
# VS Code Desktop

@ -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.
![VS Code Server with GitHub Copilot and live-share](../.images/vscode-server.gif)
## 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…
Cancel
Save