Skip to content
This repository was archived by the owner on May 15, 2025. It is now read-only.

feat(code-server): add extension_dir variable #205

Merged
merged 7 commits into from
Apr 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions code-server/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,12 @@ variable "use_cached" {
default = false
}

variable "extensions_dir" {
type = string
description = "Override the directory to store extensions in."
default = ""
}

resource "coder_script" "code-server" {
agent_id = var.agent_id
display_name = "code-server"
Expand All @@ -110,6 +116,7 @@ resource "coder_script" "code-server" {
SETTINGS : replace(jsonencode(var.settings), "\"", "\\\""),
OFFLINE : var.offline,
USE_CACHED : var.use_cached,
EXTENSIONS_DIR : var.extensions_dir,
})
run_on_start = true

Expand Down
10 changes: 8 additions & 2 deletions code-server/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,16 @@ CODE='\033[36;40;1m'
RESET='\033[0m'
CODE_SERVER="${INSTALL_PREFIX}/bin/code-server"

# Set extension directory
EXTENSION_ARG=""
if [ -n "${EXTENSIONS_DIR}" ]; then
EXTENSION_ARG="--extensions-dir=${EXTENSIONS_DIR}"
fi

function run_code_server() {
echo "👷 Running code-server in the background..."
echo "Check logs at ${LOG_PATH}!"
$CODE_SERVER --auth none --port "${PORT}" --app-name "${APP_NAME}" > "${LOG_PATH}" 2>&1 &
$CODE_SERVER "$EXTENSION_ARG" --auth none --port "${PORT}" --app-name "${APP_NAME}" > "${LOG_PATH}" 2>&1 &
}

# Check if the settings file exists...
Expand Down Expand Up @@ -57,7 +63,7 @@ for extension in "$${EXTENSIONLIST[@]}"; do
continue
fi
printf "🧩 Installing extension $${CODE}$extension$${RESET}...\n"
output=$($CODE_SERVER --install-extension "$extension")
output=$($CODE_SERVER "$EXTENSION_ARG" --install-extension "$extension")
if [ $? -ne 0 ]; then
echo "Failed to install extension: $extension: $output"
exit 1
Expand Down