Initial commit
commit
4e5b8d1069
@ -0,0 +1,19 @@
|
|||||||
|
# Modules
|
||||||
|
|
||||||
|
Enjoy official, community, and partner modules to extend your Coder workspace.
|
||||||
|
|
||||||
|
- [code-server](https://registry.coder.com/modules/code-server): Run VS Code in the browser
|
||||||
|
- [personalize](https://registry.coder.com/modules/personalize): Execute a user-specific script on start
|
||||||
|
- [VS Code Desktop](https://registry.coder.com/modules/vscode-desktop): Display a button to launch VS Code desktop in the dashboard.
|
||||||
|
|
||||||
|
## Registry
|
||||||
|
|
||||||
|
Check out the [Coder Registry](https://registry.coder.com) for instructions to integrate modules into your template.
|
||||||
|
|
||||||
|
## Adding a new module
|
||||||
|
|
||||||
|
To quickly start contributing with a new module, clone this repository and run:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
./new.sh
|
||||||
|
```
|
@ -0,0 +1,62 @@
|
|||||||
|
---
|
||||||
|
display_name: code-server
|
||||||
|
description: VS Code in the browser
|
||||||
|
icon: ../icons/code.svg
|
||||||
|
---
|
||||||
|
|
||||||
|
# code-server
|
||||||
|
|
||||||
|
Run [VS Code](https://github.com/Microsoft/vscode) on any machine anywhere and
|
||||||
|
access it in the browser.
|
||||||
|
|
||||||
|

|
||||||
|

|
||||||
|
|
||||||
|
## Highlights
|
||||||
|
|
||||||
|
- Code on any device with a consistent development environment
|
||||||
|
- Use cloud servers to speed up tests, compilations, downloads, and more
|
||||||
|
- Preserve battery life when you're on the go; all intensive tasks run on your
|
||||||
|
server
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
### Extensions
|
||||||
|
|
||||||
|
Automatically install extensions from [OpenVSX](https://open-vsx.org/):
|
||||||
|
|
||||||
|
```hcl
|
||||||
|
module "code-server" {
|
||||||
|
source = "https://registry.coder.com/modules/code-server"
|
||||||
|
extensions = [
|
||||||
|
"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Enter the `<author>.<name>` into the extensions array and code-server will automatically install on start.
|
||||||
|
|
||||||
|
### Settings
|
||||||
|
|
||||||
|
Pre-configure code-server with settings:
|
||||||
|
|
||||||
|
```hcl
|
||||||
|
module "settings" {
|
||||||
|
source = "https://registry.coder.com/modules/code-server"
|
||||||
|
extensions = [ "dracula-theme.theme-dracula" ]
|
||||||
|
settings = {
|
||||||
|
"workbench.colorTheme" = "Dracula"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Offline Mode
|
||||||
|
|
||||||
|
Just run code-server in the background, don't fetch it from GitHub:
|
||||||
|
|
||||||
|
```hcl
|
||||||
|
module "settings" {
|
||||||
|
source = "https://registry.coder.com/modules/code-server"
|
||||||
|
offline = true
|
||||||
|
}
|
||||||
|
```
|
@ -0,0 +1,82 @@
|
|||||||
|
terraform {
|
||||||
|
required_version = ">= 1.0"
|
||||||
|
|
||||||
|
required_providers {
|
||||||
|
coder = {
|
||||||
|
source = "terraform.local/coder/coder"
|
||||||
|
version = ">= 0.12"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "agent_id" {
|
||||||
|
type = string
|
||||||
|
description = "The ID of a Coder agent."
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "extensions" {
|
||||||
|
type = list(string)
|
||||||
|
description = "A list of extensions to install."
|
||||||
|
default = [ ]
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "port" {
|
||||||
|
type = number
|
||||||
|
description = "The port to run code-server on."
|
||||||
|
default = 13337
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "settings" {
|
||||||
|
type = map(string)
|
||||||
|
description = "A map of settings to apply to code-server."
|
||||||
|
default = {}
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "folder" {
|
||||||
|
type = string
|
||||||
|
description = "The folder to open in code-server."
|
||||||
|
default = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "install_prefix" {
|
||||||
|
type = string
|
||||||
|
description = "The prefix to install code-server to."
|
||||||
|
default = "/tmp/code-server"
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "log_path" {
|
||||||
|
type = string
|
||||||
|
description = "The path to log code-server to."
|
||||||
|
default = "/tmp/code-server.log"
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "coder_script" "code-server" {
|
||||||
|
agent_id = var.agent_id
|
||||||
|
display_name = "code-server"
|
||||||
|
icon = "/icon/code.svg"
|
||||||
|
script = templatefile("${path.module}/run.sh", {
|
||||||
|
EXTENSIONS: join(",", var.extensions),
|
||||||
|
PORT: var.port,
|
||||||
|
LOG_PATH: var.log_path,
|
||||||
|
INSTALL_PREFIX: var.install_prefix,
|
||||||
|
// This is necessary otherwise the quotes are stripped!
|
||||||
|
SETTINGS: replace(jsonencode(var.settings), "\"", "\\\""),
|
||||||
|
})
|
||||||
|
run_on_start = true
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "coder_app" "code-server" {
|
||||||
|
agent_id = var.agent_id
|
||||||
|
slug = "code-server"
|
||||||
|
display_name = "code-server"
|
||||||
|
url = "http://localhost:${var.port}/?folder=${var.folder}"
|
||||||
|
icon = "/icon/code.svg"
|
||||||
|
subdomain = false
|
||||||
|
share = "owner"
|
||||||
|
|
||||||
|
healthcheck {
|
||||||
|
url = "http://localhost:${var.port}/healthz"
|
||||||
|
interval = 5
|
||||||
|
threshold = 6
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,37 @@
|
|||||||
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
|
EXTENSIONS=("${EXTENSIONS}")
|
||||||
|
BOLD='\033[0;1m'
|
||||||
|
CODE='\033[36;40;1m'
|
||||||
|
RESET='\033[0m'
|
||||||
|
|
||||||
|
printf "$${BOLD}Installing code-server!\n"
|
||||||
|
output=$(curl -fsSL https://code-server.dev/install.sh | sh -s -- --method=standalone --prefix=${INSTALL_PREFIX})
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "Failed to install code-server: $output"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
printf "🥳 code-server has been installed in ${INSTALL_PREFIX}\n\n"
|
||||||
|
|
||||||
|
CODE_SERVER="${INSTALL_PREFIX}/bin/code-server"
|
||||||
|
|
||||||
|
# Install each extension...
|
||||||
|
for extension in "$${EXTENSIONS[@]}"; do
|
||||||
|
printf "🧩 Installing extension $${CODE}$extension$${RESET}...\n"
|
||||||
|
output=$($CODE_SERVER --install-extension "$extension")
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "Failed to install extension: $extension: $output"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# Check if the settings file exists...
|
||||||
|
if [ ! -f ~/.local/share/code-server/User/settings.json ]; then
|
||||||
|
echo "⚙️ Creating settings file..."
|
||||||
|
mkdir -p ~/.local/share/code-server/User
|
||||||
|
echo "${SETTINGS}" > ~/.local/share/code-server/User/settings.json
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "👷 Running code-server in the background..."
|
||||||
|
echo "Check logs at ${LOG_PATH}!"
|
||||||
|
$CODE_SERVER --auth none --port ${PORT} >${LOG_PATH} 2>&1 &
|
@ -0,0 +1,31 @@
|
|||||||
|
terraform {
|
||||||
|
required_version = ">= 1.0"
|
||||||
|
|
||||||
|
required_providers {
|
||||||
|
coder = {
|
||||||
|
source = "terraform.local/coder/coder"
|
||||||
|
version = ">= 0.12"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "agent_id" {
|
||||||
|
type = string
|
||||||
|
description = "The ID of a Coder agent."
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "path" {
|
||||||
|
type = string
|
||||||
|
description = "The path to a script that will be ran on start enabling a user to personalize their workspace."
|
||||||
|
default = "~/personalize"
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "coder_script" "personalize" {
|
||||||
|
agent_id = var.agent_id
|
||||||
|
script = templatefile("${path.module}/run.sh", {
|
||||||
|
PERSONALIZE_PATH: var.path,
|
||||||
|
})
|
||||||
|
display_name = "Personalize"
|
||||||
|
icon = "/emojis/1f58c.png"
|
||||||
|
run_on_start = true
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
|
BOLD='\033[0;1m'
|
||||||
|
CODE='\033[36;40;1m'
|
||||||
|
RESET='\033[0m'
|
||||||
|
SCRIPT="${PERSONALIZE_PATH}"
|
||||||
|
|
||||||
|
# If the personalize script doesn't exist, educate
|
||||||
|
# the user how they can customize their environment!
|
||||||
|
if [ ! -f $SCRIPT ]; then
|
||||||
|
printf "✨ $${BOLD}You don't have a personalize script!\n\n"
|
||||||
|
printf "Run $${CODE}touch $${SCRIPT} && chmod +x $${SCRIPT}$${RESET} to create one.\n"
|
||||||
|
printf "It will run every time your workspace starts. Use it to install personal packages!\n\n"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check if the personalize script is executable, if not,
|
||||||
|
# try to make it executable and educate the user if it fails.
|
||||||
|
if [ ! -x $SCRIPT ]; then
|
||||||
|
echo "🔐 Your personalize script isn't executable!"
|
||||||
|
printf "Run $CODE\`chmod +x $SCRIPT\`$RESET to make it executable.\n"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Run the personalize script!
|
||||||
|
exec $SCRIPT
|
@ -0,0 +1,32 @@
|
|||||||
|
terraform {
|
||||||
|
required_version = ">= 1.0"
|
||||||
|
|
||||||
|
required_providers {
|
||||||
|
coder = {
|
||||||
|
source = "terraform.local/coder/coder"
|
||||||
|
version = ">= 0.12"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "agent_id" {
|
||||||
|
type = string
|
||||||
|
description = "The ID of a Coder agent."
|
||||||
|
}
|
||||||
|
|
||||||
|
data "coder_workspace" "me" {}
|
||||||
|
|
||||||
|
resource "coder_app" "vscode" {
|
||||||
|
agent_id = var.agent_id
|
||||||
|
external = true
|
||||||
|
icon = "/icons/code.svg"
|
||||||
|
slug = "vscode"
|
||||||
|
url = join("", [
|
||||||
|
"vscode://coder.coder-remote/open?owner=",
|
||||||
|
data.coder_workspace.me.owner,
|
||||||
|
"&workspace=",
|
||||||
|
data.coder_workspace.me.name,
|
||||||
|
"&token=",
|
||||||
|
data.coder_workspace.me.owner_session_token,
|
||||||
|
])
|
||||||
|
}
|
Loading…
Reference in New Issue