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

Commit c4df384

Browse files
feat(code-server): add extension_dir variable (#205)
1 parent 892174d commit c4df384

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

code-server/main.tf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,12 @@ variable "use_cached" {
9595
default = false
9696
}
9797

98+
variable "extensions_dir" {
99+
type = string
100+
description = "Override the directory to store extensions in."
101+
default = ""
102+
}
103+
98104
resource "coder_script" "code-server" {
99105
agent_id = var.agent_id
100106
display_name = "code-server"
@@ -110,6 +116,7 @@ resource "coder_script" "code-server" {
110116
SETTINGS : replace(jsonencode(var.settings), "\"", "\\\""),
111117
OFFLINE : var.offline,
112118
USE_CACHED : var.use_cached,
119+
EXTENSIONS_DIR : var.extensions_dir,
113120
})
114121
run_on_start = true
115122

code-server/run.sh

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,16 @@ CODE='\033[36;40;1m'
66
RESET='\033[0m'
77
CODE_SERVER="${INSTALL_PREFIX}/bin/code-server"
88

9+
# Set extension directory
10+
EXTENSION_ARG=""
11+
if [ -n "${EXTENSIONS_DIR}" ]; then
12+
EXTENSION_ARG="--extensions-dir=${EXTENSIONS_DIR}"
13+
fi
14+
915
function run_code_server() {
1016
echo "👷 Running code-server in the background..."
1117
echo "Check logs at ${LOG_PATH}!"
12-
$CODE_SERVER --auth none --port "${PORT}" --app-name "${APP_NAME}" > "${LOG_PATH}" 2>&1 &
18+
$CODE_SERVER "$EXTENSION_ARG" --auth none --port "${PORT}" --app-name "${APP_NAME}" > "${LOG_PATH}" 2>&1 &
1319
}
1420

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

0 commit comments

Comments
 (0)