diff --git a/.icons/coder-white.svg b/.icons/coder-white.svg new file mode 100644 index 0000000..3bb941d --- /dev/null +++ b/.icons/coder-white.svg @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/.images/aws-custom.png b/.images/aws-custom.png new file mode 100644 index 0000000..e43f616 Binary files /dev/null and b/.images/aws-custom.png differ diff --git a/.images/aws-exclude.png b/.images/aws-exclude.png new file mode 100644 index 0000000..d4c60f2 Binary files /dev/null and b/.images/aws-exclude.png differ diff --git a/.images/azure-custom.png b/.images/azure-custom.png new file mode 100644 index 0000000..47be4fe Binary files /dev/null and b/.images/azure-custom.png differ diff --git a/.images/azure-default.png b/.images/azure-default.png new file mode 100644 index 0000000..963ce09 Binary files /dev/null and b/.images/azure-default.png differ diff --git a/.images/azure-exclude.png b/.images/azure-exclude.png new file mode 100644 index 0000000..8a4cd01 Binary files /dev/null and b/.images/azure-exclude.png differ diff --git a/.images/coder-login.png b/.images/coder-login.png new file mode 100644 index 0000000..a085450 Binary files /dev/null and b/.images/coder-login.png differ diff --git a/.images/filebrowser.png b/.images/filebrowser.png new file mode 100644 index 0000000..8a8bbf3 Binary files /dev/null and b/.images/filebrowser.png differ diff --git a/.images/jupyter-notebook.png b/.images/jupyter-notebook.png new file mode 100644 index 0000000..dad85cc Binary files /dev/null and b/.images/jupyter-notebook.png differ diff --git a/.images/vscode-desktop.png b/.images/vscode-desktop.png new file mode 100644 index 0000000..e3e40a4 Binary files /dev/null and b/.images/vscode-desktop.png differ diff --git a/.images/vscode-server.gif b/.images/vscode-web.gif similarity index 100% rename from .images/vscode-server.gif rename to .images/vscode-web.gif diff --git a/.sample/run.sh b/.sample/run.sh index 79eb123..2f8fae1 100755 --- a/.sample/run.sh +++ b/.sample/run.sh @@ -1,7 +1,7 @@ #!/usr/bin/env sh BOLD='\033[0;1m' -echo "$${BOLD}Installing MODULE_NAME..." +printf "$${BOLD}Installing MODULE_NAME..." # Add code here # Use varibles from the templatefile function in main.tf # e.g. LOG_PATH, PORT, etc. diff --git a/aws-region/README.md b/aws-region/README.md index f23b11f..02a731a 100644 --- a/aws-region/README.md +++ b/aws-region/README.md @@ -29,18 +29,19 @@ provider "aws" { ## Examples -### Customize Regions +### Customize regions -Change the display name and icon for a region: +Change the display name and icon for a region using the corresponding maps: ```hcl module "aws-region" { source = "https://registry.coder.com/modules/aws-region" + default = "ap-south-1" custom_names = { - "fra": "Awesome Germany!" + "ap-south-1": "Awesome Mumbai!" } custom_icons = { - "fra": "/icons/smiley.svg" + "ap-south-1": "/emojis/1f33a.png" } } @@ -49,17 +50,28 @@ provider "aws" { } ``` -### Exclude Regions +![AWS Custom](../.images/aws-custom.png) -Hide the `fra` region: +### Exclude regions + +Hide the Asia Pacific regions Seoul and Osaka: ```hcl module "aws-region" { source = "https://registry.coder.com/modules/aws-region" - exclude = [ "fra" ] + exclude = [ "ap-northeast-2", "ap-northeast-3" ] } provider "aws" { region = module.aws_region.value } ``` + +![AWS Exclude](../.images/aws-exclude.png) + +## Related templates + +For a complete AWS EC2 template, see the following examples in the [Coder Registry](https://registry.coder.com/). + +- [AWS EC2 (Linux)](https://registry.coder.com/templates/aws-linux) +- [AWS EC2 (Windows)](https://registry.coder.com/templates/aws-windows) diff --git a/azure-region/README.md b/azure-region/README.md index 235f58e..a6a0b7c 100644 --- a/azure-region/README.md +++ b/azure-region/README.md @@ -22,20 +22,22 @@ resource "azurem_resource_group" "example" { } ``` +![Azure Region Default](../.images/azure-default.png) + ## Examples ### Customize existing regions -Change the display name for a region: +Change the display name and icon for a region using the corresponding maps: ```hcl module "azure-region" { source = "https://registry.coder.com/modules/azure-region" custom_names = { - "eastus": "Eastern United States!" + "australia": "Go Australia!" } custom_icons = { - "eastus": "/icons/smiley.svg" + "australia": "/icons/smiley.svg" } } @@ -44,17 +46,33 @@ resource "azurerm_resource_group" "example" { } ``` +![Azure Region Custom](../.images/azure-custom.png) + ### Exclude Regions -Hide the `westus2` region: +Hide all regions in Australia except australiacentral: ```hcl module "azure-region" { source = "https://registry.coder.com/modules/azure-region" - exclude = [ "westus2" ] + exclude = [ + "australia", + "australiacentral2", + "australiaeast", + "australiasoutheast" + ] } resource "azurerm_resource_group" "example" { location = module.azure_region.value } ``` + +![Azure Exclude](../.images/azure-exclude.png) + +## Related templates + +For a complete Azure template, see the following examples in the [Coder Registry](https://registry.coder.com/). + +- [Azure VM (Linux)](https://registry.coder.com/templates/azure-linux) +- [Azure VM (Windows)](https://registry.coder.com/templates/azure-windows) diff --git a/azure-region/main.tf b/azure-region/main.tf index 1e38091..744fb88 100644 --- a/azure-region/main.tf +++ b/azure-region/main.tf @@ -310,6 +310,7 @@ data "coder_parameter" "region" { description = var.description default = var.default mutable = var.mutable + icon = "/icon/azure.png" dynamic "option" { for_each = { for k, v in local.all_regions : k => v if !(contains(var.exclude, k)) } content { diff --git a/code-server/run.sh b/code-server/run.sh index 3e1a38b..6676aaa 100755 --- a/code-server/run.sh +++ b/code-server/run.sh @@ -41,9 +41,9 @@ done if [ ! -f ~/.local/share/code-server/Machine/settings.json ]; then echo "⚙️ Creating settings file..." mkdir -p ~/.local/share/code-server/Machine - echo "${SETTINGS}" > ~/.local/share/code-server/Machine/settings.json + echo "${SETTINGS}" >~/.local/share/code-server/Machine/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 & \ No newline at end of file +$CODE_SERVER --auth none --port ${PORT} >${LOG_PATH} 2>&1 & diff --git a/coder-login/README.md b/coder-login/README.md new file mode 100644 index 0000000..def4c97 --- /dev/null +++ b/coder-login/README.md @@ -0,0 +1,20 @@ +--- +display_name: Coder Login +description: Automatically logs the user into Coder on their workspace +icon: ../.icons/coder-white.svg +maintainer_github: coder +verified: true +tags: [helper] +--- + +# Coder Login + +Automatically logs the user into Coder when creating their workspace. + +```hcl +module "coder-login" { + agent_id = coder_agent.example.id +} +``` + +![Coder Login Logs](../.images/coder-login.png) diff --git a/coder-login/main.test.ts b/coder-login/main.test.ts new file mode 100644 index 0000000..d8fba35 --- /dev/null +++ b/coder-login/main.test.ts @@ -0,0 +1,15 @@ +import { describe, expect, it } from "bun:test"; +import { + executeScriptInContainer, + runTerraformApply, + runTerraformInit, + testRequiredVariables, +} from "../test"; + +describe("coder-login", async () => { + await runTerraformInit(import.meta.dir); + + testRequiredVariables(import.meta.dir, { + agent_id: "foo", + }); +}); diff --git a/coder-login/main.tf b/coder-login/main.tf new file mode 100644 index 0000000..2d3ac8b --- /dev/null +++ b/coder-login/main.tf @@ -0,0 +1,30 @@ +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_workspace" "me" {} + +resource "coder_script" "coder-login" { + agent_id = var.agent_id + script = templatefile("${path.module}/run.sh", { + CODER_USER_TOKEN : data.coder_workspace.me.owner_session_token, + CODER_DEPLOYMENT_URL : data.coder_workspace.me.access_url + }) + display_name = "Coder Login" + icon = "http://svgur.com/i/y5G.svg" + run_on_start = true + start_blocks_login = true +} + diff --git a/coder-login/run.sh b/coder-login/run.sh new file mode 100644 index 0000000..e5a58ec --- /dev/null +++ b/coder-login/run.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env sh + +# Automatically authenticate the user if they are not +# logged in to another deployment + +BOLD='\033[0;1m' + +printf "$${BOLD}Logging into Coder...\n\n$${RESET}" + +if ! coder list >/dev/null 2>&1; then + set +x; coder login --token="${CODER_USER_TOKEN}" --url="${CODER_DEPLOYMENT_URL}" +else + echo "You are already authenticated with coder." +fi diff --git a/filebrowser/README.md b/filebrowser/README.md index bd1ba07..9a08398 100644 --- a/filebrowser/README.md +++ b/filebrowser/README.md @@ -18,6 +18,8 @@ module "filebrowser" { } ``` +![Filebrowsing Example](../.images/filebrowser.png) + ## Examples ### Serve a specific directory diff --git a/filebrowser/run.sh b/filebrowser/run.sh index 427c864..b13e919 100644 --- a/filebrowser/run.sh +++ b/filebrowser/run.sh @@ -1,7 +1,7 @@ #!/usr/bin/env sh BOLD='\033[0;1m' -echo "$${BOLD}Installing filebrowser \n\n" +printf "$${BOLD}Installing filebrowser \n\n" curl -fsSL https://raw.githubusercontent.com/filebrowser/get/master/get.sh | bash diff --git a/jfrog/run.sh b/jfrog/run.sh index 7f58114..272eb1d 100644 --- a/jfrog/run.sh +++ b/jfrog/run.sh @@ -1,7 +1,7 @@ #!/usr/bin/env sh BOLD='\033[0;1m' -echo "$${BOLD}Installing JFrog CLI..." +printf "$${BOLD}Installing JFrog CLI..." # Install the JFrog CLI. curl -fL https://install-cli.jfrog.io | sudo sh @@ -20,11 +20,11 @@ if [ -z "${REPOSITORY_NPM}" ]; then else echo "📦 Configuring npm..." jf npmc --global --repo-resolve "${JFROG_URL}/artifactory/api/npm/${REPOSITORY_NPM}" - cat << EOF > ~/.npmrc + cat <~/.npmrc email = ${ARTIFACTORY_USERNAME} registry = ${JFROG_URL}/artifactory/api/npm/${REPOSITORY_NPM} EOF - jf rt curl /api/npm/auth >> ~/.npmrc + jf rt curl /api/npm/auth >>~/.npmrc fi # Configure the `pip` to use the Artifactory "python" repository. @@ -33,7 +33,7 @@ if [ -z "${REPOSITORY_PYPI}" ]; then else echo "🐍 Configuring pip..." mkdir -p ~/.pip - cat << EOF > ~/.pip/pip.conf + cat <~/.pip/pip.conf [global] index-url = https://${ARTIFACTORY_USERNAME}:${ARTIFACTORY_ACCESS_TOKEN}@${JFROG_HOST}/artifactory/api/pypi/${REPOSITORY_PYPI}/simple EOF @@ -46,4 +46,4 @@ else echo "🐹 Configuring go..." export GOPROXY="https://${ARTIFACTORY_USERNAME}:${ARTIFACTORY_ACCESS_TOKEN}@${JFROG_HOST}/artifactory/api/go/${REPOSITORY_GO}" fi -echo "🥳 Configuration complete!" \ No newline at end of file +echo "🥳 Configuration complete!" diff --git a/jupyter-notebook/README.md b/jupyter-notebook/README.md new file mode 100644 index 0000000..f3730b6 --- /dev/null +++ b/jupyter-notebook/README.md @@ -0,0 +1,21 @@ +--- +display_name: Jupyter Notebook +description: A module that adds Jupyter Notebook in your Coder template. +icon: ../.icons/jupyter.svg +maintainer_github: coder +verified: true +tags: [jupyter, helper, ide, web] +--- + +# Jupyter Notebook + +A module that adds Jupyter Notebook in your Coder template. + +![Jupyter Notebook](../.images/jupyter-notebook.png) + +```hcl +module "jupyter-notebook" { + source = "https://registry.coder.com/modules/jupyter-notebook" + agent_id = coder_agent.example.id +} +``` diff --git a/jupyter-notebook/main.tf b/jupyter-notebook/main.tf new file mode 100644 index 0000000..fb36b86 --- /dev/null +++ b/jupyter-notebook/main.tf @@ -0,0 +1,49 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + coder = { + source = "coder/coder" + version = ">= 0.12" + } + } +} + +# 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 jupyter notebook to." + default = "/tmp/jupyter-notebook.log" +} + +variable "port" { + type = number + description = "The port to run jupyter-notebook on." + default = 19999 +} + +resource "coder_script" "jupyter-notebook" { + agent_id = var.agent_id + display_name = "jupyter-notebook" + icon = "/icon/jupyter.svg" + script = templatefile("${path.module}/run.sh", { + LOG_PATH : var.log_path, + PORT : var.port + }) + run_on_start = true +} + +resource "coder_app" "jupyter-notebook" { + agent_id = var.agent_id + slug = "jupyter-notebook" + display_name = "Jupyter Notebook" + url = "http://localhost:${var.port}" + icon = "/icon/jupyter.svg" + subdomain = true + share = "owner" +} diff --git a/jupyter-notebook/run.sh b/jupyter-notebook/run.sh new file mode 100755 index 0000000..1f948ab --- /dev/null +++ b/jupyter-notebook/run.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env sh + +BOLD='\033[0;1m' + +printf "$${BOLD}Installing jupyter-notebook!\n" + +# check if jupyter-notebook is installed +if ! command -v jupyter-notebook >/dev/null 2>&1; then + # install jupyter-notebook + # check if python3 pip is installed + if ! command -v pip3 >/dev/null 2>&1; then + echo "pip3 is not installed" + echo "Please install pip3 in your Dockerfile/VM image before running this script" + exit 1 + fi + # install jupyter-notebook + pip3 install --upgrade --no-cache-dir --no-warn-script-location jupyter + echo "🥳 jupyter-notebook has been installed\n\n" +else + echo "🥳 jupyter-notebook is already installed\n\n" +fi + +echo "👷 Starting jupyter-notebook in background..." +echo "check logs at ${LOG_PATH}" +$HOME/.local/bin/jupyter notebook --NotebookApp.ip='0.0.0.0' --ServerApp.port=${PORT} --no-browser --ServerApp.token='' --ServerApp.password='' >${LOG_PATH} 2>&1 & diff --git a/jupyterlab/run.sh b/jupyterlab/run.sh index ec7c28d..8f77cac 100755 --- a/jupyterlab/run.sh +++ b/jupyterlab/run.sh @@ -2,13 +2,13 @@ BOLD='\033[0;1m' -echo "$${BOLD}Installing jupyterlab!\n" +printf "$${BOLD}Installing jupyterlab!\n" # check if jupyterlab is installed -if ! command -v jupyterlab > /dev/null 2>&1; then +if ! command -v jupyterlab >/dev/null 2>&1; then # install jupyterlab # check if python3 pip is installed - if ! command -v pip3 > /dev/null 2>&1; then + if ! command -v pip3 >/dev/null 2>&1; then echo "pip3 is not installed" echo "Please install pip3 in your Dockerfile/VM image before running this script" exit 1 @@ -22,4 +22,4 @@ 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 & +$HOME/.local/bin/jupyter lab --ServerApp.ip='0.0.0.0' --ServerApp.port=${PORT} --no-browser --ServerApp.token='' --ServerApp.password='' >${LOG_PATH} 2>&1 & diff --git a/vscode-web/README.md b/vscode-web/README.md index 4dcfb8d..2956109 100644 --- a/vscode-web/README.md +++ b/vscode-web/README.md @@ -13,23 +13,23 @@ Automatically install [Visual Studio Code Server](https://code.visualstudio.com/ ```hcl module "vscode-web" { - source = "https://registry.coder.com/modules/vscode-server" + source = "https://registry.coder.com/modules/vscode-web" agent_id = coder_agent.example.id accept_license = true } ``` -![VS Code Server with GitHub Copilot and live-share](../.images/vscode-server.gif) +![VS Code Web with GitHub Copilot and live-share](../.images/vscode-web.gif) ## Examples -### Install VS Code Server to a custom folder +### Install VS Code Web to a custom folder ```hcl module "vscode-web" { - source = "https://registry.coder.com/modules/vscode-server" + source = "https://registry.coder.com/modules/vscode-web" agent_id = coder_agent.example.id - install_dir = "/home/coder/.vscode-server" + install_dir = "/home/coder/.vscode-web" folder = "/home/coder" accept_license = true }