Skip to content

Commit 920ac48

Browse files
stirbymatifali
authored andcommitted
moved workspace access to a directory
1 parent ad4bb0c commit 920ac48

File tree

8 files changed

+717
-12
lines changed

8 files changed

+717
-12
lines changed

docs/user-guides/workspace-access.md

-12
This file was deleted.
+113
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
# Access your workspace
2+
3+
There are many ways to connect to your workspace, the options are only limited by the template configuration.
4+
5+
> Deployment operators can learn more about different types of workspace connections and performance in our [networking docs](../admin/infrastructure/README.md).
6+
7+
You can see the primary methods of connecting to your workspace in the workspace dashboard.
8+
9+
![Workspace View](../images/user-guides/workspace-view-connection-annotated.png)
10+
11+
<!-- ## Coder Apps
12+
13+
Coder Apps (from our [`coder_app`](https://registry.terraform.io/providers/coder/coder/latest/docs/resources/app) resource in terraform) provide IDE connections and the Terminal. Coder Apps can connect you to ports or run commands on the remote workspace. They be shared with other users by copying the URL from the button. Contact your template administrator if you have IDEs or tools you'd like added into your workspace.
14+
15+
, and can be extended with our [Module Registry](https://registry.coder.com/modules). -->
16+
17+
## Terminal
18+
19+
The terminal is enabled by implictily in Coder and allows you to access your workspace through a shell environment.
20+
21+
## Jetbrains IDEs
22+
23+
We support Jetbrains IDEs using Gateway. Currently the following are supported:
24+
- IntelliJ IDEA
25+
- CLion
26+
- GoLand
27+
- PyCharm
28+
- Rider
29+
- RubyMine
30+
- WebStorm
31+
32+
Read our [docs on Jetbrains Gateway](./jetbrains-gateway.md) for more information on setup.
33+
34+
35+
## Visual Studio Code
36+
37+
Click `VS Code Desktop` in the dashboard to one-click enter a workspace. This
38+
automatically installs the [Coder Remote](https://github.com/coder/vscode-coder)
39+
extension, authenticates with Coder, and connects to the workspace.
40+
41+
![Demo](https://github.com/coder/vscode-coder/raw/main/demo.gif?raw=true)
42+
43+
You can set the default directory in which VS Code opens via the `dir` argument
44+
on the `coder_agent` resource in your workspace template. See the
45+
[Terraform documentation for more details](https://registry.terraform.io/providers/coder/coder/latest/docs/resources/agent#dir).
46+
47+
> The `VS Code Desktop` button can be hidden by enabling
48+
> [Browser-only connections](./networking/index.md#Browser-only).
49+
50+
### Manual Installation
51+
52+
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press
53+
enter.
54+
55+
```text
56+
ext install coder.coder-remote
57+
```
58+
59+
Alternatively, manually install the VSIX from the
60+
[latest release](https://github.com/coder/vscode-coder/releases/latest).
61+
62+
### SSH
63+
64+
### Through with the CLI
65+
66+
Coder will use the optimal path for an SSH connection (determined by your deployment's [networking configuration](../admin/networking.md)) when using the CLI:
67+
68+
```console
69+
coder ssh my-workspace
70+
```
71+
72+
Or, you can configure plain SSH on your client below.
73+
74+
75+
### Configure SSH
76+
77+
Coder generates [SSH key pairs](../secrets.md#ssh-keys) for each user to simplify the setup process.
78+
79+
> Before proceeding, run `coder login <accessURL>` if you haven't already to
80+
> authenticate the CLI with the web UI and your workspaces.
81+
82+
To access Coder via SSH, run the following in the terminal:
83+
84+
```console
85+
coder config-ssh
86+
```
87+
88+
> Run `coder config-ssh --dry-run` if you'd like to see the changes that will be
89+
> made before proceeding.
90+
91+
Confirm that you want to continue by typing **yes** and pressing enter. If
92+
successful, you'll see the following message:
93+
94+
```console
95+
You should now be able to ssh into your workspace.
96+
For example, try running:
97+
98+
$ ssh coder.<workspaceName>
99+
```
100+
101+
Your workspace is now accessible via `ssh coder.<workspace_name>` (e.g.,
102+
`ssh coder.myEnv` if your workspace is named `myEnv`).
103+
104+
105+
## code-server
106+
107+
## Other IDEs
108+
- E
109+
110+
## Ports and Port forwarding
111+
112+
## Other Methods
113+
-
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
# Emacs TRAMP
2+
3+
[Emacs TRAMP](https://www.emacswiki.org/emacs/TrampMode) is a method of running
4+
editing operations on a remote server.
5+
6+
## Connecting To A Workspace
7+
8+
To connect to your workspace first run:
9+
10+
```
11+
coder config-ssh
12+
```
13+
14+
Then you can connect to your workspace by its name in the format:
15+
`coder.<WORKSPACE NAME>`.
16+
17+
In Emacs type `C-x d` and then input: `/-:coder.<WORKSPACE NAME>:` and hit
18+
enter. This will open up Dired on the workspace's home directory.
19+
20+
### Using SSH
21+
22+
By default Emacs TRAMP is setup to use SCP to access files on the Coder
23+
workspace instance. However you might want to use SSH if you have a jumpbox or
24+
some other complex network setup.
25+
26+
To do so set the following in your Emacs `init.el` file:
27+
28+
```lisp
29+
(setq tramp-default-method "ssh")
30+
```
31+
32+
Then when you access the workspace instance via `/-:coder.<WORKSPACE NAME>`
33+
Emacs will use SSH. Setting `tramp-default-method` will also tell `ansi-term`
34+
mode the correct way to access the remote when directory tracking.
35+
36+
## Directory Tracking
37+
38+
### ansi-term
39+
40+
If you run your terminal in Emacs via `ansi-term` then you might run into a
41+
problem where while SSH-ed into a workspace Emacs will not change its
42+
`default-directory` to open files in the directory your shell is in.
43+
44+
To fix this:
45+
46+
1. In your workspace Terraform template be sure to add the following:
47+
48+
```hcl
49+
data "coder_workspace" "me" {
50+
}
51+
52+
resource "coder_agent" "main" {
53+
# ...
54+
env = {
55+
name = "CODER_WORKSPACE_NAME"
56+
value = data.coder_workspace.me.name
57+
}
58+
}
59+
```
60+
61+
2. Next in the shell profile file on the workspace (ex., `~/.bashrc` for Bash
62+
and `~/.zshrc` for Zsh) add the following:
63+
64+
```bash
65+
ansi_term_announce_host() {
66+
printf '\033AnSiTh %s\n' "coder.$CODER_WORKSPACE_NAME"
67+
}
68+
69+
ansi_term_announce_user() {
70+
printf '\033AnSiTu %s\n' "$USER"
71+
}
72+
73+
ansi_term_announce_pwd() {
74+
printf '\033AnSiTc %s\n' "$PWD"
75+
}
76+
77+
ansi_term_announce() {
78+
ansi_term_announce_host
79+
ansi_term_announce_user
80+
ansi_term_announce_pwd
81+
}
82+
83+
cd() { command cd "$@"; ansi_term_announce_pwd; }
84+
pushd() { command pushd "$@"; ansi_term_announce_pwd; }
85+
popd() { command popd "$@"; ansi_term_announce_pwd; }
86+
87+
ansi_term_announce
88+
```
89+
90+
Ansi Term expects the terminal running inside of it to send escape codes to
91+
inform Emacs of the hostname, user, and working directory. The above code
92+
sends these escape codes and associated data whenever the terminal logs in
93+
and whenever the directory changes.
94+
95+
### eshell
96+
97+
The `eshell` mode will perform directory tracking by default, no additional
98+
configuration is needed.
99+
100+
## Language Servers (Code Completion)
101+
102+
If you use [`lsp-mode`](https://emacs-lsp.github.io/lsp-mode) for code
103+
intelligence and completion some additional configuration is required.
104+
105+
In your Emacs `init.el` file you must register a LSP client and tell `lsp-mode`
106+
how to find it on the remote machine using the `lsp-register-client` function.
107+
For each LSP server you want to use in your workspace add the following:
108+
109+
```lisp
110+
(lsp-register-client (make-lsp-client :new-connection (lsp-tramp-connection "<LSP SERVER BINARY>")
111+
:major-modes '(<LANGUAGE MODE>)
112+
:remote? t
113+
:server-id '<LANGUAGE SERVER ID>))
114+
```
115+
116+
This tells `lsp-mode` to look for a language server binary named
117+
`<LSP SERVER BINARY>` for use in `<LANGUAGE MODE>` on a machine named
118+
`coder.<WORKSPACE NAME>`. Be sure to replace the values between angle brackets:
119+
120+
- `<LSP SERVER BINARY>` : The name of the language server binary, without any
121+
path components. For example to use the Deno Javascript language server use
122+
the value `deno`.
123+
- `<LANGUAGE MODE>`: The name of the Emacs major mode for which the language
124+
server should be used. For example to enable the language server for
125+
Javascript development use the value `web-mode`.
126+
- `<LANGUAGE SERVER ID>`: This is just the name that `lsp-mode` will use to
127+
refer to this language server. If you are ever looking for output buffers or
128+
files they may have this name in them.
129+
130+
Calling the `lsp-register-client` function will tell `lsp-mode` the name of the
131+
LSP server binary. However this binary must be accessible via the path. If the
132+
language server binary is not in the path you must modify `tramp-remote-path` so
133+
that `lsp-mode` knows in what directories to look for the LSP server. To do this
134+
use TRAMP's connection profiles functionality. These connection profiles let you
135+
customize variables depending on what machine you are connected to. Add the
136+
following to your `init.el`:
137+
138+
```lisp
139+
(connection-local-set-profile-variables 'remote-path-lsp-servers
140+
'((tramp-remote-path . ("<PATH TO ADD>" tramp-default-remote-path))))
141+
(connection-local-set-profiles '(:machine "coder.<WORKSPACE NAME>") 'remote-path-lsp-servers)
142+
```
143+
144+
The `connection-local-set-profile-variables` function creates a new connection
145+
profile by the name `remote-path-lsp-servers`. The
146+
`connection-local-set-profiles` then indicates this `remote-path-lsp-servers`
147+
connection profile should be used when connecting to a server named
148+
`coder.<WORKSPACE NAME>`. Be sure to replace `<PATH TO ADD>` with the directory
149+
in which a LSP server is present.
150+
151+
TRAMP and `lsp-mode` are fickle friends, sometimes there is weird behavior. If
152+
you find that language servers are hanging in the `starting` state then
153+
[it might be helpful](https://github.com/emacs-lsp/lsp-mode/issues/2709#issuecomment-800868919)
154+
to set the `lsp-log-io` variable to `t`.
155+
156+
More details on configuring `lsp-mode` for TRAMP can be found
157+
[in the `lsp-mode` documentation](https://emacs-lsp.github.io/lsp-mode/page/remote/).
158+
The
159+
[TRAMP `tramp-remote-path` documentation](https://www.gnu.org/software/emacs/manual/html_node/tramp/Remote-programs.html#Remote-programs)
160+
contains more examples and details of connection profiles.
+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# JetBrains Fleet
2+
3+
JetBrains Fleet is a code editor and lightweight IDE designed to support various
4+
programming languages and development environments.
5+
6+
[See JetBrains' website to learn about Fleet](https://www.jetbrains.com/fleet/)
7+
8+
Fleet can connect to a Coder workspace by following these steps.
9+
10+
1. [Install Fleet](https://www.jetbrains.com/fleet/download)
11+
2. Install Coder CLI
12+
```shell
13+
curl -L https://coder.com/install.sh | sh
14+
```
15+
3. Login and configure Coder SSH.
16+
```shell
17+
coder login coder.example.com
18+
coder config-ssh
19+
```
20+
4. Connect via SSH with the Host set to `coder.workspace-name`
21+
![Fleet Connect to Coder](../images/fleet/ssh-connect-to-coder.png)
22+
23+
> If you experience problems, please
24+
> [create a GitHub issue](https://github.com/coder/coder/issues) or share in
25+
> [our Discord channel](https://discord.gg/coder).

docs/user-guides/workspace-access/jetbrains-gateway.md

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Remote Desktops
2+
3+
> Built-in remote desktop is on the roadmap
4+
> ([#2106](https://github.com/coder/coder/issues/2106)).
5+
6+
## VNC Desktop
7+
8+
The common way to use remote desktops with Coder is through VNC.
9+
10+
![VNC Desktop in Coder](../images/vnc-desktop.png)
11+
12+
Workspace requirements:
13+
14+
- VNC server (e.g. [tigervnc](https://tigervnc.org/))
15+
- VNC client (e.g. [novnc](https://novnc.com/info.html))
16+
17+
Installation instructions vary depending on your workspace's operating system,
18+
platform, and build system.
19+
20+
As a starting point, see the
21+
[desktop-container](https://github.com/bpmct/coder-templates/tree/main/desktop-container)
22+
community template. It builds and provisions a Dockerized workspace with the
23+
following software:
24+
25+
- Ubuntu 20.04
26+
- TigerVNC server
27+
- noVNC client
28+
- XFCE Desktop
29+
30+
## RDP Desktop
31+
32+
To use RDP with Coder, you'll need to install an
33+
[RDP client](https://docs.microsoft.com/en-us/windows-server/remote/remote-desktop-services/clients/remote-desktop-clients)
34+
on your local machine, and enable RDP on your workspace.
35+
36+
As a starting point, see the
37+
[gcp-windows-rdp](https://github.com/matifali/coder-templates/tree/main/gcp-windows-rdp)
38+
community template. It builds and provisions a Windows Server workspace on GCP.
39+
40+
Use the following command to forward the RDP port to your local machine:
41+
42+
```console
43+
coder port-forward <workspace-name> --tcp 3399:3389
44+
```
45+
46+
Then, connect to your workspace via RDP:
47+
48+
```console
49+
mstsc /v localhost:3399
50+
```
51+
52+
or use your favorite RDP client to connect to `localhost:3399`.
53+
![windows-rdp](../images/ides/windows_rdp_client.png)
54+
55+
> Note: Default username is `Administrator` and password is `coderRDP!`.

0 commit comments

Comments
 (0)