Skip to content

Commit f999968

Browse files
feat: support more cli options (#9)
Add support for: - `--locale` - `--app-name` - `--welcome-text` - `--verbose` - `--trusted-origins` - `--enable-proposed-api` - `--proxy-domain`
1 parent 4384a34 commit f999968

12 files changed

+243
-6
lines changed

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.PHONY: test
22
test:
3-
devcontainer features test
3+
devcontainer features test --filter "$$DEVCONTAINER_FEATURE_TEST_FILTER"
44

55
.PHONY: docs
66
docs: src/code-server/README.md

src/code-server/README.md

+9-2
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,31 @@ VS Code in the browser
1515

1616
| Options Id | Description | Type | Default Value |
1717
|-----|-----|-----|-----|
18+
| appName | The name to use in branding. Will be shown in titlebar and welcome message. | string | - |
1819
| auth | The type of authentication to use. When 'password' is selected, code-server will auto-generate a password. 'none' disables authentication entirely. | string | password |
1920
| cert | Path to certificate. A self signed certificate is generated if none is provided. | string | - |
20-
| certHost | hostname to use when generating a self signed certificate. | string | - |
21-
| certKey | path to certificate key when using non-generated cert. | string | - |
21+
| certHost | Hostname to use when generating a self signed certificate. | string | - |
22+
| certKey | Path to certificate key when using non-generated cert. | string | - |
2223
| disableFileDownloads | Disable file downloads from Code. When enabled, users will not be able to download files from the editor. | boolean | false |
2324
| disableFileUploads | Disable file uploads to Code. When enabled, users will not be able to upload files to the editor. | boolean | false |
2425
| disableGettingStartedOverride | Disable the coder/coder override in the Help: Getting Started page. | boolean | false |
2526
| disableProxy | Disable domain and path proxy routes. | boolean | false |
2627
| disableTelemetry | Disable telemetry reporting. | boolean | false |
2728
| disableUpdateCheck | Disable update check. Without this flag, code-server checks every 6 hours against the latest GitHub release and notifies once a week when updates are available. | boolean | false |
2829
| disableWorkspaceTrust | Disable Workspace Trust feature. This only affects the current session. | boolean | false |
30+
| enableProposedAPI | Comma-separated list of VS Code extension IDs to enable proposed API features for. | string | - |
2931
| extensions | Comma-separated list of VS Code extensions to install. Format: 'publisher.extension[@version]' (e.g., 'ms-python.python,ms-azuretools.vscode-docker'). | string | - |
3032
| host | The address to bind to for the code-server. Use '0.0.0.0' to listen on all interfaces. | string | 127.0.0.1 |
33+
| locale | Set VS Code display language and language shown on the login page. Format should be an IETF language tag (e.g., 'en', 'fr', 'zh-CN'). | string | - |
3134
| logFile | Path to a file to send stdout and stderr logs to from code-server. | string | /tmp/code-server.log |
3235
| port | The port to bind to for the code-server. | string | 8080 |
36+
| proxyDomain | Domain used for proxying ports. | string | - |
3337
| socket | Path to a socket. When specified, host and port will be ignored. | string | - |
3438
| socketMode | File mode of the socket when using the socket option. | string | - |
39+
| trustedOrigins | Comma-separated list of trusted-origins to disable origin check for. Useful if not able to access reverse proxy configuration. | string | - |
40+
| verbose | Enable verbose logging. | boolean | false |
3541
| version | The version of code-server to install. If empty, installs the latest version. | string | - |
42+
| welcomeText | Text to show on login page. | string | - |
3643
| workspace | Path to the workspace or folder to open on startup. Can be a directory or a .code-workspace file. | string | - |
3744

3845

src/code-server/devcontainer-feature.json

+37-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
"version": "1.0.0",
55
"description": "VS Code in the browser",
66
"options": {
7+
"appName": {
8+
"type": "string",
9+
"default": "",
10+
"description": "The name to use in branding. Will be shown in titlebar and welcome message."
11+
},
712
"auth": {
813
"type": "string",
914
"enum": ["password", "none"],
@@ -18,12 +23,12 @@
1823
"certHost": {
1924
"type": "string",
2025
"default": "",
21-
"description": "hostname to use when generating a self signed certificate."
26+
"description": "Hostname to use when generating a self signed certificate."
2227
},
2328
"certKey": {
2429
"type": "string",
2530
"default": "",
26-
"description": "path to certificate key when using non-generated cert."
31+
"description": "Path to certificate key when using non-generated cert."
2732
},
2833
"disableFileDownloads": {
2934
"type": "boolean",
@@ -60,6 +65,11 @@
6065
"default": false,
6166
"description": "Disable Workspace Trust feature. This only affects the current session."
6267
},
68+
"enableProposedAPI": {
69+
"type": "string",
70+
"default": "",
71+
"description": "Comma-separated list of VS Code extension IDs to enable proposed API features for."
72+
},
6373
"extensions": {
6474
"type": "string",
6575
"default": "",
@@ -70,6 +80,11 @@
7080
"default": "127.0.0.1",
7181
"description": "The address to bind to for the code-server. Use '0.0.0.0' to listen on all interfaces."
7282
},
83+
"locale": {
84+
"type": "string",
85+
"default": "",
86+
"description": "Set VS Code display language and language shown on the login page. Format should be an IETF language tag (e.g., 'en', 'fr', 'zh-CN')."
87+
},
7388
"logFile": {
7489
"type": "string",
7590
"default": "/tmp/code-server.log",
@@ -80,6 +95,11 @@
8095
"default": "8080",
8196
"description": "The port to bind to for the code-server."
8297
},
98+
"proxyDomain": {
99+
"type": "string",
100+
"default": "",
101+
"description": "Domain used for proxying ports."
102+
},
83103
"socket": {
84104
"type": "string",
85105
"default": "",
@@ -90,11 +110,26 @@
90110
"default": "",
91111
"description": "File mode of the socket when using the socket option."
92112
},
113+
"trustedOrigins": {
114+
"type": "string",
115+
"default": "",
116+
"description": "Comma-separated list of trusted-origins to disable origin check for. Useful if not able to access reverse proxy configuration."
117+
},
118+
"verbose": {
119+
"type": "boolean",
120+
"default": false,
121+
"description": "Enable verbose logging."
122+
},
93123
"version": {
94124
"type": "string",
95125
"default": "",
96126
"description": "The version of code-server to install. If empty, installs the latest version."
97127
},
128+
"welcomeText": {
129+
"type": "string",
130+
"default": "",
131+
"description": "Text to show on login page."
132+
},
98133
"workspace": {
99134
"type": "string",
100135
"default": "",

src/code-server/install.sh

+32-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ fi
1010
curl -fsSL https://code-server.dev/install.sh | sh -s -- $CODE_SERVER_INSTALL_ARGS
1111

1212
IFS=',' read -ra extensions <<<"$EXTENSIONS"
13-
declare -p extensions
1413

1514
for extension in "${extensions[@]}"
1615
do
@@ -75,6 +74,38 @@ if [[ -n "$SOCKETMODE" ]]; then
7574
FLAGS+=(--socket-mode "$SOCKETMODE")
7675
fi
7776

77+
if [[ -n "$LOCALE" ]]; then
78+
FLAGS+=(--locale "$LOCALE")
79+
fi
80+
81+
if [[ -n "$APPNAME" ]]; then
82+
FLAGS+=(--app-name "$APPNAME")
83+
fi
84+
85+
if [[ -n "$WELCOMETEXT" ]]; then
86+
FLAGS+=(--welcome-text "$WELCOMETEXT")
87+
fi
88+
89+
if [[ "$VERBOSE" == "true" ]]; then
90+
FLAGS+=(--verbose)
91+
fi
92+
93+
IFS=',' read -ra trusted_origins <<<"$TRUSTEDORIGINS"
94+
95+
for trusted_origin in "${trusted_origins[@]}"; do
96+
FLAGS+=(--trusted-origins "$trusted_origin")
97+
done
98+
99+
IFS=',' read -ra proposed_api_extensions <<<"$ENABLEPROPOSEDAPI"
100+
101+
for extension in "${proposed_api_extensions[@]}"; do
102+
FLAGS+=(--enable-proposed-api "$extension")
103+
done
104+
105+
if [[ "$PROXYDOMAIN" ]]; then
106+
FLAGS+=(--proxy-domain "$PROXYDOMAIN")
107+
fi
108+
78109
cat > /usr/local/bin/code-server-entrypoint <<EOF
79110
#!/usr/bin/env bash
80111
set -e
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# Optional: Import test library bundled with the devcontainer CLI
5+
source dev-container-features-test-lib
6+
7+
# Feature-specific tests
8+
check "code-server version" code-server --version
9+
check "code-server running" pgrep -f 'code-server/lib/node.*/code-server'
10+
check "code-server listening" lsof -i "@127.0.0.1:8080"
11+
12+
check "code-server locale" grep '"--app-name".*"My Code Server"' < /usr/local/bin/code-server-entrypoint
13+
14+
# Report results
15+
reportResults
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# Optional: Import test library bundled with the devcontainer CLI
5+
source dev-container-features-test-lib
6+
7+
# Feature-specific tests
8+
check "code-server version" code-server --version
9+
check "code-server running" pgrep -f 'code-server/lib/node.*/code-server'
10+
check "code-server listening" lsof -i "@127.0.0.1:8080"
11+
12+
check "code-server enable-proposed-api" grep '"--enable-proposed-api".*"rust-lang.rust-analyzer".*"--enable-proposed-api".*"ms-python.python"' < /usr/local/bin/code-server-entrypoint
13+
14+
# Report results
15+
reportResults
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# Optional: Import test library bundled with the devcontainer CLI
5+
source dev-container-features-test-lib
6+
7+
# Feature-specific tests
8+
check "code-server version" code-server --version
9+
check "code-server running" pgrep -f 'code-server/lib/node.*/code-server'
10+
check "code-server listening" lsof -i "@127.0.0.1:8080"
11+
12+
check "code-server locale" grep '"--locale".*"fr"' < /usr/local/bin/code-server-entrypoint
13+
14+
# Report results
15+
reportResults
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# Optional: Import test library bundled with the devcontainer CLI
5+
source dev-container-features-test-lib
6+
7+
# Feature-specific tests
8+
check "code-server version" code-server --version
9+
check "code-server running" pgrep -f 'code-server/lib/node.*/code-server'
10+
check "code-server listening" lsof -i "@127.0.0.1:8080"
11+
12+
check "code-server proxy-domain" grep '"--proxy-domain".*"dev.coder.com"' < /usr/local/bin/code-server-entrypoint
13+
14+
# Report results
15+
reportResults
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# Optional: Import test library bundled with the devcontainer CLI
5+
source dev-container-features-test-lib
6+
7+
# Feature-specific tests
8+
check "code-server version" code-server --version
9+
check "code-server running" pgrep -f 'code-server/lib/node.*/code-server'
10+
check "code-server listening" lsof -i "@127.0.0.1:8080"
11+
12+
check "code-server trusted-origins" grep '"--trusted-origins".*"dev.coder.com".*"--trusted-origins".*"coder.com"' < /usr/local/bin/code-server-entrypoint
13+
14+
# Report results
15+
reportResults
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# Optional: Import test library bundled with the devcontainer CLI
5+
source dev-container-features-test-lib
6+
7+
# Feature-specific tests
8+
check "code-server version" code-server --version
9+
check "code-server running" pgrep -f 'code-server/lib/node.*/code-server'
10+
check "code-server listening" lsof -i "@127.0.0.1:8080"
11+
12+
check "code-server verbose" grep '"--verbose"' < /usr/local/bin/code-server-entrypoint
13+
14+
# Report results
15+
reportResults
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# Optional: Import test library bundled with the devcontainer CLI
5+
source dev-container-features-test-lib
6+
7+
# Feature-specific tests
8+
check "code-server version" code-server --version
9+
check "code-server running" pgrep -f 'code-server/lib/node.*/code-server'
10+
check "code-server listening" lsof -i "@127.0.0.1:8080"
11+
12+
check "code-server welcome-text" grep '"--welcome-text".*"Some Welcome Text"' < /usr/local/bin/code-server-entrypoint
13+
14+
# Report results
15+
reportResults

test/code-server/scenarios.json

+59
Original file line numberDiff line numberDiff line change
@@ -168,5 +168,64 @@
168168
"logFile": "/tmp/code-server-log-file.log"
169169
}
170170
}
171+
},
172+
"code-server-locale": {
173+
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
174+
"features": {
175+
"code-server": {
176+
"locale": "fr"
177+
}
178+
}
179+
},
180+
"code-server-app-name": {
181+
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
182+
"features": {
183+
"code-server": {
184+
"appName": "My Code Server"
185+
}
186+
}
187+
},
188+
"code-server-welcome-text": {
189+
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
190+
"features": {
191+
"code-server": {
192+
"welcomeText": "Some Welcome Text"
193+
}
194+
}
195+
},
196+
"code-server-verbose": {
197+
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
198+
"features": {
199+
"code-server": {
200+
"verbose": true
201+
}
202+
}
203+
},
204+
"code-server-trusted-origins": {
205+
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
206+
"features": {
207+
"code-server": {
208+
"trustedOrigins": ["dev.coder.com", "coder.com"]
209+
}
210+
}
211+
},
212+
"code-server-enable-proposed-api": {
213+
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
214+
"features": {
215+
"code-server": {
216+
"enableProposedAPI": [
217+
"rust-lang.rust-analyzer",
218+
"ms-python.python"
219+
]
220+
}
221+
}
222+
},
223+
"code-server-proxy-domain": {
224+
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
225+
"features": {
226+
"code-server": {
227+
"proxyDomain": "dev.coder.com"
228+
}
229+
}
171230
}
172231
}

0 commit comments

Comments
 (0)