refactor: migrate service toggles to coder_parameter and update app icons/healthchecks

This commit is contained in:
2025-08-24 22:04:50 -04:00
parent bf247b0950
commit b163f031ef
5 changed files with 85 additions and 24 deletions

View File

@@ -16,6 +16,7 @@ resource "coder_app" "code_server" {
icon = "/icon/code.svg"
subdomain = true
share = "owner"
order = 1
healthcheck {
url = "http://localhost:8080/healthz"
@@ -31,6 +32,7 @@ resource "coder_app" "terminal" {
display_name = "Terminal"
icon = "/icon/terminal.svg"
command = "bash"
order = 2
}
# =============================================================================
@@ -39,7 +41,7 @@ resource "coder_app" "terminal" {
# pgAdmin - PostgreSQL Administration
resource "coder_app" "pgadmin" {
count = data.coder_parameter.enable_services.value && var.enable_pgadmin ? 1 : 0
count = data.coder_parameter.enable_services.value && data.coder_parameter.enable_pgadmin.value ? 1 : 0
agent_id = coder_agent.main.id
slug = "pgadmin"
display_name = "pgAdmin"
@@ -47,6 +49,7 @@ resource "coder_app" "pgadmin" {
icon = "/icon/postgresql.svg"
subdomain = true
share = "owner"
order = 10
healthcheck {
url = "http://pgadmin-${local.workspace_id}:80/misc/ping"
@@ -65,11 +68,12 @@ resource "coder_app" "qdrant" {
icon = "/icon/database.svg"
subdomain = true
share = "owner"
order = 11
healthcheck {
url = "http://qdrant-${local.workspace_id}:6333/health"
interval = 20
threshold = 5
interval = 30
threshold = 10
}
}
@@ -84,7 +88,7 @@ resource "coder_app" "nextjs_dev" {
slug = "nextjs-3000"
display_name = "Next.js Dev Server"
url = "http://localhost:3000"
icon = "/icon/nextjs.svg"
icon = "/icon/react.svg"
subdomain = true
share = "owner"
@@ -104,6 +108,7 @@ resource "coder_app" "dev_server_3000" {
icon = "/icon/web.svg"
subdomain = true
share = "owner"
order = 21
healthcheck {
url = "http://localhost:3000"
@@ -121,6 +126,7 @@ resource "coder_app" "api_server_8000" {
icon = "/icon/api.svg"
subdomain = true
share = "owner"
order = 20
healthcheck {
url = "http://localhost:8000/health"
@@ -152,7 +158,7 @@ resource "coder_app" "rust_server" {
slug = "rust-8080"
display_name = "Rust Server (8080)"
url = "http://localhost:8080"
icon = "/icon/rust.svg"
icon = "/icon/code.svg"
subdomain = true
share = "owner"
@@ -169,12 +175,12 @@ resource "coder_app" "rust_server" {
# Jupyter Lab (if enabled)
resource "coder_app" "jupyter" {
count = var.enable_jupyter ? 1 : 0
count = data.coder_parameter.enable_jupyter.value ? 1 : 0
agent_id = coder_agent.main.id
slug = "jupyter"
display_name = "Jupyter Lab"
url = "http://localhost:8888"
icon = "/icon/jupyter.svg"
icon = "/icon/python.svg"
subdomain = true
share = "owner"
@@ -232,11 +238,11 @@ resource "coder_app" "git_manager" {
# Claude Code CLI Access
resource "coder_app" "claude_code" {
count = data.coder_parameter.enable_ai_tools.value && var.install_claude_code ? 1 : 0
count = data.coder_parameter.enable_ai_tools.value && data.coder_parameter.enable_claude_code.value ? 1 : 0
agent_id = coder_agent.main.id
slug = "claude-code"
display_name = "Claude Code"
icon = "/icon/claude.svg"
icon = "/icon/ai.svg"
command = "claude"
}

View File

@@ -81,6 +81,56 @@ data "coder_parameter" "enable_ai_tools" {
order = 4
}
data "coder_parameter" "enable_claude_code" {
name = "enable_claude_code"
display_name = "Enable Claude Code CLI"
description = "Install Claude Code command-line interface"
type = "bool"
default = "true"
mutable = true
order = 4.1
}
data "coder_parameter" "enable_cursor_support" {
name = "enable_cursor_support"
display_name = "Enable Cursor IDE Support"
description = "Install Cursor IDE configuration and settings"
type = "bool"
default = "true"
mutable = true
order = 4.2
}
data "coder_parameter" "enable_windsurf_support" {
name = "enable_windsurf_support"
display_name = "Enable Windsurf IDE Support"
description = "Install Windsurf IDE configuration and settings"
type = "bool"
default = "true"
mutable = true
order = 4.3
}
data "coder_parameter" "enable_jupyter" {
name = "enable_jupyter"
display_name = "Enable Jupyter Lab"
description = "Enable Jupyter Lab for data science and notebook development"
type = "bool"
default = "false"
mutable = true
order = 5
}
data "coder_parameter" "enable_pgadmin" {
name = "enable_pgadmin"
display_name = "Enable pgAdmin"
description = "Enable pgAdmin web interface for PostgreSQL management"
type = "bool"
default = "true"
mutable = true
order = 6
}
# Local Variables
locals {
# Container and workspace naming

View File

@@ -8,10 +8,10 @@
# =============================================================================
resource "coder_script" "claude_code_setup" {
count = data.coder_parameter.enable_ai_tools.value && var.install_claude_code ? 1 : 0
count = data.coder_parameter.enable_ai_tools.value && data.coder_parameter.enable_claude_code.value ? 1 : 0
agent_id = coder_agent.main.id
display_name = "Install Claude Code CLI"
icon = "/icon/claude.svg"
icon = "/icon/ai.svg"
run_on_start = true
script = "bash /home/coder/resources/tf/scripts/claude-install.sh"
@@ -22,10 +22,10 @@ resource "coder_script" "claude_code_setup" {
# =============================================================================
resource "coder_script" "cursor_setup" {
count = data.coder_parameter.enable_ai_tools.value && var.install_cursor_support ? 1 : 0
count = data.coder_parameter.enable_ai_tools.value && data.coder_parameter.enable_cursor_support.value ? 1 : 0
agent_id = coder_agent.main.id
display_name = "Configure Cursor IDE Support"
icon = "/icon/cursor.svg"
icon = "/icon/code.svg"
run_on_start = true
script = "bash /home/coder/resources/tf/scripts/cursor-setup.sh"
@@ -36,10 +36,10 @@ resource "coder_script" "cursor_setup" {
# =============================================================================
resource "coder_script" "windsurf_setup" {
count = data.coder_parameter.enable_ai_tools.value && var.install_windsurf_support ? 1 : 0
count = data.coder_parameter.enable_ai_tools.value && data.coder_parameter.enable_windsurf_support.value ? 1 : 0
agent_id = coder_agent.main.id
display_name = "Configure Windsurf IDE Support"
icon = "/icon/windsurf.svg"
icon = "/icon/code.svg"
run_on_start = true
script = "bash /home/coder/resources/tf/scripts/windsurf-setup.sh"

View File

@@ -76,9 +76,9 @@ apt-get install -y make tree jq curl wget unzip build-essential postgresql-clien
# =============================================================================
echo "🟢 Setting up Node.js and npm..."
# Clean any existing npm caches with wrong ownership (as root before switching users)
rm -rf /home/coder/.npm /home/coder/.npm-global 2>/dev/null || true
rm -rf /root/.npm 2>/dev/null || true
# Clean any existing npm caches and config files with wrong ownership (as root before switching users)
rm -rf /home/coder/.npm /home/coder/.npm-global /home/coder/.npmrc 2>/dev/null || true
rm -rf /root/.npm /root/.npmrc 2>/dev/null || true
# Pre-create directories with proper ownership including lib and bin subdirectories
mkdir -p /home/coder/.npm /home/coder/.npm-global/{lib,bin,lib/node_modules}
chown -R coder:coder /home/coder/.npm /home/coder/.npm-global 2>/dev/null || true
@@ -92,7 +92,7 @@ echo '[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"' >> ~/.bashrc
echo '[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"' >> ~/.bashrc
# Clean any npmrc files that might conflict with nvm
rm -f ~/.npmrc 2>/dev/null || true
rm -f ~/.npmrc /home/coder/.npmrc 2>/dev/null || true
# Verify npm directories exist and are owned by coder
ls -la ~/.npm ~/.npm-global || echo "npm directories ready"
@@ -109,6 +109,10 @@ nvm install ${NODE_VERSION}
nvm use ${NODE_VERSION}
nvm alias default ${NODE_VERSION}
# Clean npm config that conflicts with nvm
npm config delete globalconfig 2>/dev/null || true
npm config delete prefix 2>/dev/null || true
# Create npm-global lib directory structure
mkdir -p ~/.npm-global/{lib,bin}

View File

@@ -162,7 +162,8 @@ resource "docker_container" "qdrant" {
# Qdrant configuration
env = [
"QDRANT__SERVICE__HTTP_PORT=6333",
"QDRANT__SERVICE__GRPC_PORT=6334",
"QDRANT__SERVICE__GRPC_PORT=6334",
"QDRANT__SERVICE__HOST=0.0.0.0",
"QDRANT__LOG_LEVEL=INFO"
]
@@ -203,7 +204,7 @@ resource "docker_container" "qdrant" {
# pgAdmin data volume
resource "docker_volume" "pgadmin_data" {
count = data.coder_parameter.enable_services.value && var.enable_pgadmin ? 1 : 0
count = data.coder_parameter.enable_services.value && data.coder_parameter.enable_pgadmin.value ? 1 : 0
name = "pgadmin-data-${local.workspace_id}"
labels {
@@ -218,7 +219,7 @@ resource "docker_volume" "pgadmin_data" {
# pgAdmin container
resource "docker_container" "pgadmin" {
count = data.coder_parameter.enable_services.value && var.enable_pgadmin ? 1 : 0
count = data.coder_parameter.enable_services.value && data.coder_parameter.enable_pgadmin.value ? 1 : 0
image = "dpage/pgadmin4:latest"
name = "pgadmin-${local.workspace_id}"
@@ -259,7 +260,7 @@ resource "docker_container" "pgadmin" {
# Jupyter data volume
resource "docker_volume" "jupyter_data" {
count = var.enable_jupyter ? 1 : 0
count = data.coder_parameter.enable_jupyter.value ? 1 : 0
name = "jupyter-data-${local.workspace_id}"
labels {
@@ -274,7 +275,7 @@ resource "docker_volume" "jupyter_data" {
# Jupyter Lab container
resource "docker_container" "jupyter" {
count = var.enable_jupyter ? 1 : 0
count = data.coder_parameter.enable_jupyter.value ? 1 : 0
image = "jupyter/scipy-notebook:latest"
name = "jupyter-${local.workspace_id}"