Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc91b885

Browse files
sharkymarkstirby
andauthored
chore: add optional coder_app to faq (#11351)
Merging since Mark is out.* chore: add optional coder_app to faq* applied Atif's suggestions* make fmt again---------Co-authored-by: kirby <kirby@coder.com>Co-authored-by: Stephen Kirby <58410745+stirby@users.noreply.github.com>
1 parentfcd2991 commitc91b885

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed

‎docs/faqs.md‎

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,64 @@ Colima will show the path to the docker socket so I have a
404404
[Coder template](./docker-code-server/main.tf) that prompts the Coder admin to
405405
enter the docker socket as a Terraform variable.
406406

407+
## How to make a `coder_app` optional?
408+
409+
An example use case is the user should decide if they want a browser-based IDE
410+
like code-server when creating the workspace.
411+
412+
1. Add a `coder_parameter` with type `bool` to ask the user if they want the
413+
code-server IDE
414+
415+
```hcl
416+
data "coder_parameter" "code_server" {
417+
name = "Do you want code-server in your workspace?"
418+
description = "Use VS Code in a browser."
419+
type = "bool"
420+
default = false
421+
mutable = true
422+
icon = "/icon/code.svg"
423+
order = 6
424+
}
425+
```
426+
427+
2. Add conditional logic to the `startup_script` to install and start
428+
code-server depending on the value of the added `coder_parameter`
429+
430+
```sh
431+
# install and start code-server, VS Code in a browser
432+
433+
if [ ${data.coder_parameter.code_server.value} = true ]; then
434+
echo "🧑🏼‍💻 Downloading and installing the latest code-server IDE..."
435+
curl -fsSL https://code-server.dev/install.sh | sh
436+
code-server --auth none --port 13337 >/dev/null 2>&1 &
437+
fi
438+
```
439+
440+
3. Add a Terraform meta-argument
441+
[`count`](https://developer.hashicorp.com/terraform/language/meta-arguments/count)
442+
in the `coder_app` resource so it will only create the resource if the
443+
`coder_parameter`is `true`
444+
445+
```hcl
446+
# code-server
447+
resource "coder_app" "code-server" {
448+
count = data.coder_parameter.code_server.value ? 1 : 0
449+
agent_id = coder_agent.coder.id
450+
slug = "code-server"
451+
display_name = "code-server"
452+
icon = "/icon/code.svg"
453+
url = "http://localhost:13337?folder=/home/coder"
454+
subdomain = false
455+
share = "owner"
456+
457+
healthcheck {
458+
url = "http://localhost:13337/healthz"
459+
interval = 3
460+
threshold = 10
461+
}
462+
}
463+
```
464+
407465
## Why am I getting this "remote host doesn't meet VS Code Server's prerequisites" error when opening up VSCode remote in a Linux environment?
408466

409467
![VS Code Server prerequisite](https://github.com/coder/coder/assets/10648092/150c5996-18b1-4fae-afd0-be2b386a3239)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp