From a5ea3774a800d2d7331059b01a4e628f9e2e2c8c Mon Sep 17 00:00:00 2001 From: authentik Default Admin Date: Fri, 22 May 2026 07:01:37 +0000 Subject: [PATCH] =?UTF-8?q?python3=20=EB=AA=A8=EB=93=88=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- registry/yamanin/modules/python3/README.md | 61 +++++++++++++++++++ registry/yamanin/modules/python3/main.test.ts | 12 ++++ registry/yamanin/modules/python3/main.tf | 17 ++++++ registry/yamanin/modules/python3/run.sh | 18 ++++++ registry/yamanin/modules/python3/run_tmp.sh | 53 ++++++++++++++++ 5 files changed, 161 insertions(+) create mode 100644 registry/yamanin/modules/python3/README.md create mode 100644 registry/yamanin/modules/python3/main.test.ts create mode 100644 registry/yamanin/modules/python3/main.tf create mode 100644 registry/yamanin/modules/python3/run.sh create mode 100644 registry/yamanin/modules/python3/run_tmp.sh diff --git a/registry/yamanin/modules/python3/README.md b/registry/yamanin/modules/python3/README.md new file mode 100644 index 00000000..d7293aac --- /dev/null +++ b/registry/yamanin/modules/python3/README.md @@ -0,0 +1,61 @@ +--- +display_name: Node.js +description: Install Node.js via nvm +icon: ../../../../.icons/node.svg +maintainer_github: TheZoker +verified: false +tags: [helper, nodejs] +--- + +# nodejs + +Automatically installs [Node.js](https://github.com/nodejs/node) via [`nvm`](https://github.com/nvm-sh/nvm). It can also install multiple versions of node and set a default version. If no options are specified, the latest version is installed. + +```tf +module "nodejs" { + count = data.coder_workspace.me.start_count + source = "registry.coder.com/thezoker/nodejs/coder" + version = "1.0.13" + agent_id = coder_agent.example.id +} +``` + +## Install multiple versions + +This installs multiple versions of Node.js: + +```tf +module "nodejs" { + count = data.coder_workspace.me.start_count + source = "registry.coder.com/thezoker/nodejs/coder" + version = "1.0.13" + agent_id = coder_agent.example.id + node_versions = [ + "18", + "20", + "node" + ] + default_node_version = "1.0.13" +} +``` + +## Full example + +A example with all available options: + +```tf +module "nodejs" { + count = data.coder_workspace.me.start_count + source = "registry.coder.com/thezoker/nodejs/coder" + version = "1.0.13" + agent_id = coder_agent.example.id + nvm_version = "1.0.13" + nvm_install_prefix = "/opt/nvm" + node_versions = [ + "16", + "18", + "node" + ] + default_node_version = "1.0.13" +} +``` diff --git a/registry/yamanin/modules/python3/main.test.ts b/registry/yamanin/modules/python3/main.test.ts new file mode 100644 index 00000000..14f8a066 --- /dev/null +++ b/registry/yamanin/modules/python3/main.test.ts @@ -0,0 +1,12 @@ +import { describe } from "bun:test"; +import { runTerraformInit, testRequiredVariables } from "~test"; + +describe("nodejs", async () => { + await runTerraformInit(import.meta.dir); + + testRequiredVariables(import.meta.dir, { + agent_id: "foo", + }); + + // More tests depend on shebang refactors +}); diff --git a/registry/yamanin/modules/python3/main.tf b/registry/yamanin/modules/python3/main.tf new file mode 100644 index 00000000..2705c044 --- /dev/null +++ b/registry/yamanin/modules/python3/main.tf @@ -0,0 +1,17 @@ +terraform { + required_version = ">= 1.0" + } +} + +variable "agent_id" { + type = string + description = "The ID of a Coder agent." +} + +resource "coder_script" "python3" { + agent_id = var.agent_id + display_name = "python3:" + script = templatefile("${path.module}/run.sh") + run_on_start = true + start_blocks_login = true +} diff --git a/registry/yamanin/modules/python3/run.sh b/registry/yamanin/modules/python3/run.sh new file mode 100644 index 00000000..55e86cfe --- /dev/null +++ b/registry/yamanin/modules/python3/run.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash + +sudo apt update +sudo apt install -y make build-essential libssl-dev zlib1g-dev \ +libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm \ +libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev + +curl https://pyenv.run | bash + +echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc +echo 'command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc +echo 'eval "$(pyenv init -)"' >> ~/.bashrc + +source ~/.bashrc # or source ~/.zshrc + +pyenv install 3.9 + +pyenv global 3.9 \ No newline at end of file diff --git a/registry/yamanin/modules/python3/run_tmp.sh b/registry/yamanin/modules/python3/run_tmp.sh new file mode 100644 index 00000000..31044eb5 --- /dev/null +++ b/registry/yamanin/modules/python3/run_tmp.sh @@ -0,0 +1,53 @@ +#!/usr/bin/env bash + +NVM_VERSION='${NVM_VERSION}' +NODE_VERSIONS='${NODE_VERSIONS}' +INSTALL_PREFIX='${INSTALL_PREFIX}' +DEFAULT='${DEFAULT}' +BOLD='\033[0;1m' +CODE='\033[36;40;1m' +RESET='\033[0m' + +printf "$${BOLD}Installing nvm!$${RESET}\n" + +export NVM_DIR="$HOME/$${INSTALL_PREFIX}/nvm" +mkdir -p "$NVM_DIR" + +script="$(curl -sS -o- "https://raw.githubusercontent.com/nvm-sh/nvm/$${NVM_VERSION}/install.sh" 2>&1)" +if [ $? -ne 0 ]; then + echo "Failed to download nvm installation script: $script" + exit 1 +fi + +output="$(bash <<< "$script" 2>&1)" +if [ $? -ne 0 ]; then + echo "Failed to install nvm: $output" + exit 1 +fi + +printf "🥳 nvm has been installed\n\n" + +# Set up nvm for the rest of the script. +[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" + +# Install each node version... +IFS=',' read -r -a VERSIONLIST <<< "$${NODE_VERSIONS}" +# shellcheck disable=SC2066 +for version in "$${VERSIONLIST[@]}"; do + if [ -z "$version" ]; then + continue + fi + printf "🛠️ Installing node version $${CODE}$version$${RESET}...\n" + output=$(nvm install "$version" 2>&1) + if [ $? -ne 0 ]; then + echo "Failed to install version: $version: $output" + exit 1 + fi +done + +# Set default if provided +# shellcheck disable=SC2157 +if [ -n "$${DEFAULT}" ]; then + printf "🛠️ Setting default node version $${CODE}$DEFAULT$${RESET}...\n" + output=$(nvm alias default $DEFAULT 2>&1) +fi