Skip to content

Commit b1c400a

Browse files
sharkymarkbpmct
andauthored
chore: update web-ides section with revised docker examples and Airflow/RStudio using subdomain config (#4855)
* chore: update web-ides section with docker examples and subdomain rstudio and airflow examples * Update docs/ides/web-ides.md * Update docs/ides/web-ides.md Co-authored-by: Ben Potter <ben@coder.com>
1 parent e26bc20 commit b1c400a

File tree

1 file changed

+60
-101
lines changed

1 file changed

+60
-101
lines changed

docs/ides/web-ides.md

+60-101
Original file line numberDiff line numberDiff line change
@@ -117,99 +117,34 @@ Workspace requirements:
117117
- RubyMine
118118
- WebStorm
119119

120-
For advanced users who want to make a custom image, you can install the Projector CLI in the `startup_script` of the `coder_agent` resource in a Coder template. Using the Projector CLI, you can use `projector ide autoinstall` and `projector run` to download and start a JetBrains IDE in your workspace.
120+
For advanced users who want to make a custom image, you can install the
121+
Projector CLI in the `startup_script` of the `coder_agent` resource in a Coder
122+
template. Using the Projector CLI, you can use `projector config add` and
123+
`projector run` to configure and start a JetBrains IDE in your workspace.
121124

122-
![IntelliJ in Coder](../images/projector-intellij.png)
123-
124-
In this example, the version of JetBrains IntelliJ IDE is passed in from a Terraform input variable. You create a JetBrains icon in the workspace using a `coder_app` resource.
125-
126-
> There is a known issue passing query string parameters when opening a JetBrains IDE from an icon in your workspace ([#2669](https://github.com/coder/coder/issues/2669)). Note the `grep` statement to remove an optional password token from the configuration so a query string parameter is not passed.
127-
128-
```hcl
129-
130-
variable "jetbrains-ide" {
131-
description = "JetBrains IntelliJ IDE"
132-
default = "IntelliJ IDEA Community Edition 2022.1.3"
133-
validation {
134-
condition = contains([
135-
"IntelliJ IDEA Community Edition 2022.1.3",
136-
"IntelliJ IDEA Community Edition 2021.3",
137-
"IntelliJ IDEA Ultimate 2022.1.3",
138-
"IntelliJ IDEA Ultimate 2021.3"
139-
], var.jetbrains-ide)
140-
# Find all compatible IDEs with the `projector IDE find` command
141-
error_message = "Invalid JetBrains IDE!"
142-
}
143-
}
144-
145-
resource "coder_agent" "coder" {
146-
dir = "/home/coder"
147-
startup_script = <<EOT
148-
#!/bin/bash
149-
150-
# install projector
151-
PROJECTOR_BINARY=/home/coder/.local/bin/projector
152-
if [ -f $PROJECTOR_BINARY ]; then
153-
echo 'projector has already been installed - check for update'
154-
/home/coder/.local/bin/projector self-update 2>&1 | tee projector.log
155-
else
156-
echo 'installing projector'
157-
pip3 install projector-installer --user 2>&1 | tee projector.log
158-
fi
159-
160-
echo 'access projector license terms'
161-
/home/coder/.local/bin/projector --accept-license 2>&1 | tee -a projector.log
162-
163-
PROJECTOR_CONFIG_PATH=/home/coder/.projector/configs/intellij
164-
165-
if [ -d "$PROJECTOR_CONFIG_PATH" ]; then
166-
echo 'projector has already been configured and the JetBrains IDE downloaded - skip step' 2>&1 | tee -a projector.log
167-
else
168-
echo 'autoinstalling IDE and creating projector config folder'
169-
/home/coder/.local/bin/projector ide autoinstall --config-name "intellij" --ide-name "${var.jetbrains-ide}" --hostname=localhost --port 8997 --use-separate-config --password coder 2>&1 | tee -a projector.log
170-
171-
# delete the configuration's run.sh input parameters that check password tokens since tokens do not work with coder_app yet passed in the querystring
172-
grep -iv "HANDSHAKE_TOKEN" $PROJECTOR_CONFIG_PATH/run.sh > temp && mv temp $PROJECTOR_CONFIG_PATH/run.sh 2>&1 | tee -a projector.log
173-
chmod +x $PROJECTOR_CONFIG_PATH/run.sh 2>&1 | tee -a projector.log
174-
175-
echo "creation of intellij configuration complete" 2>&1 | tee -a projector.log
176-
fi
177-
# start JetBrains projector-based IDE
178-
/home/coder/.local/bin/projector run intellij &
179-
180-
EOT
181-
}
182-
183-
resource "coder_app" "intellij" {
184-
agent_id = coder_agent.coder.id
185-
slug = "intellij"
186-
display_name = "${var.jetbrains-ide}"
187-
icon = "/icon/intellij.svg"
188-
url = "http://localhost:8997/"
125+
> Install the JetBrains IDE in your image and `chown` the `/opt` directory to
126+
> the user that starts the workspace. e.g., `coder`
189127
190-
healthcheck {
191-
url = "http://localhost:8997/"
192-
interval = 6
193-
threshold = 20
194-
}
128+
![IntelliJ in Coder](../images/projector-intellij.png)
195129

196-
}
197-
```
198130

199131
**Pre-built templates:**
200132

201-
You can also reference/use to these pre-built templates with JetBrains projector:
133+
You can also reference/use to these pre-built templates with JetBrains
134+
projector:
202135

203-
- IntelliJ ([Docker](https://github.com/sharkymark/v2-templates/tree/e815748bf5d029da15dac29fb25a6fd4ef8e73bf/the-archives/docker-with-intellij), [Kubernetes](https://github.com/sharkymark/v2-templates/tree/main/multi-projector-intellij))
136+
- IntelliJ
137+
([Docker](https://github.com/sharkymark/v2-templates/tree/main/docker-with-intellij),
138+
[Kubernetes](https://github.com/sharkymark/v2-templates/tree/main/multi-projector-intellij))
204139

205-
- PyCharm ([Docker](https://github.com/sharkymark/v2-templates/tree/e815748bf5d029da15dac29fb25a6fd4ef8e73bf/the-archives/docker-with-pycharm), [Kubernetes](https://github.com/sharkymark/v2-templates/tree/main/multi-projector-pycharm)
206-
207-
> You need to have a valid `~/.kube/config` on your Coder host and a namespace on a Kubernetes cluster to use the Kubernetes pod template examples.
140+
- PyCharm
141+
([Docker](https://github.com/sharkymark/v2-templates/tree/main/docker-with-pycharm),
142+
[Kubernetes](https://github.com/sharkymark/v2-templates/tree/main/multi-projector-pycharm)
208143

209-
=======
210-
![PyCharm in Coder](../images/projector-pycharm.png)
144+
> You need to have a valid `~/.kube/config` on your Coder host and a namespace
145+
> on a Kubernetes cluster to use the Kubernetes pod template examples.
211146
212-
> Coder OSS currently does not perform a health check([#2662](https://github.com/coder/coder/issues/2662)) that any IDE or commands in the `startup_script` have completed, so wait a minute or so before opening the JetBrains or code-server icons. As a precaution, you can open Terminal and run `htop` to see if the processes have completed.
147+
======= ![PyCharm in Coder](../images/projector-pycharm.png)
213148

214149
## JupyterLab
215150

@@ -252,13 +187,12 @@ resource "coder_app" "jupyter" {
252187

253188
![JupyterLab in Coder](../images/jupyterlab-port-forward.png)
254189

255-
## SSH Fallback
256-
257-
Certain Web IDEs don't support URL base path adjustment and thus can't be exposed with
258-
`coder_app`. In these cases you can use [SSH](../ides.md#ssh).
259190

260191
### RStudio
261192

193+
Configure your agent and `coder_app` like so to use RStudio. Notice the
194+
`subdomain=true` configuration:
195+
262196
```hcl
263197
resource "coder_agent" "coder" {
264198
os = "linux"
@@ -270,21 +204,31 @@ resource "coder_agent" "coder" {
270204
/usr/lib/rstudio-server/bin/rserver --server-daemonize=1 --auth-none=1 &
271205
EOT
272206
}
273-
```
274207
275-
From your local machine, start port forwarding and then open the IDE on
276-
http://localhost:8787.
208+
# rstudio
209+
resource "coder_app" "rstudio" {
210+
agent_id = coder_agent.coder.id
211+
name = "rstudio"
212+
icon = "/icon/rstudio.svg"
213+
url = "http://localhost:8787"
214+
subdomain = true
215+
share = "owner"
277216
278-
```console
279-
ssh -L 8787:localhost:8787 coder.<RStudio workspace name>
217+
healthcheck {
218+
url = "http://localhost:8787/healthz"
219+
interval = 3
220+
threshold = 10
221+
}
222+
}
280223
```
281224

282-
Check out this [RStudio Dockerfile](https://github.com/mark-theshark/dockerfiles/blob/main/rstudio/no-args/Dockerfile) for a starting point to creating a template.
283-
284225
![RStudio in Coder](../images/rstudio-port-forward.png)
285226

286227
### Airflow
287228

229+
Configure your agent and `coder_app` like so to use Airflow. Notice the
230+
`subdomain=true` configuration:
231+
288232
```hcl
289233
resource "coder_agent" "coder" {
290234
os = "linux"
@@ -293,17 +237,32 @@ resource "coder_agent" "coder" {
293237
startup_script = <<EOT
294238
#!/bin/bash
295239
# install and start airflow
296-
pip3 install apache-airflow 2>&1 | tee airflow-install.log
297-
/home/coder/.local/bin/airflow standalone 2>&1 | tee airflow-run.log &
240+
pip3 install apache-airflow
241+
/home/coder/.local/bin/airflow standalone &
298242
EOT
299243
}
300-
```
301244
302-
From your local machine, start port forwarding and then open the IDE on
303-
http://localhost:8080.
245+
resource "coder_app" "airflow" {
246+
agent_id = coder_agent.coder.id
247+
name = "airflow"
248+
icon = "https://upload.wikimedia.org/wikipedia/commons/d/de/AirflowLogo.png"
249+
url = "http://localhost:8080"
250+
subdomain = true
251+
share = "owner"
304252
305-
```console
306-
ssh -L 8080:localhost:8080 coder.<Airflow workspace name>
253+
healthcheck {
254+
url = "http://localhost:8080/healthz"
255+
interval = 10
256+
threshold = 60
257+
}
258+
}
307259
```
308260

309261
![Airflow in Coder](../images/airflow-port-forward.png)
262+
263+
## SSH Fallback
264+
265+
If you prefer to run web IDEs in localhost, you can port forward using
266+
[SSH](../ides.md#ssh) or the Coder CLI `port-forward` sub-command. Some web IDEs
267+
may not support URL base path adjustment so port forwarding is the only
268+
approach.

0 commit comments

Comments
 (0)