|
| 1 | +# VS Code extensions |
| 2 | + |
| 3 | +This article will show you the ways to add VS Code extensions and use them with |
| 4 | +a Coder workspace: |
| 5 | + |
| 6 | +1. Using the |
| 7 | + [public extensions marketplaces](vscode-extensions.md#using-the-public-extensions-marketplaces) |
| 8 | + with Code Web (code-server) |
| 9 | +1. Adding |
| 10 | + [extensions to custom images](vscode-extensions.md#adding-extensions-to-custom-images) |
| 11 | +1. Installing extensions |
| 12 | + [using its `vsix` file at the command line](vscode-extensions.md#installing-extensions-using-its-vsix-file-at-the-command-line) |
| 13 | +1. Installing extensions |
| 14 | + [from a marketplace using the command line](vscode-extensions.md#installing-from-a-marketplace-at-the-command-line) |
| 15 | +1. Using a |
| 16 | + [local VS Code instance with SSH](vscode-extensions.md#using-a-local-vs-code-instance-with-ssh) |
| 17 | + |
| 18 | +## Using the public extensions marketplaces |
| 19 | + |
| 20 | +You can manually add an extension while you're working in the Code Web IDE. The |
| 21 | +extensions can be from Coder's public marketplace, Eclipse Open VSX's public |
| 22 | +marketplace, or the Eclipse Open VSX _local_ marketplace. |
| 23 | + |
| 24 | + |
| 25 | + |
| 26 | +> Note: Microsoft does not allow any unofficial VS Code IDE to connect to the |
| 27 | +> extension marketplace. |
| 28 | +
|
| 29 | +## Adding extensions to custom images |
| 30 | + |
| 31 | +You can add extensions to a custom image and install them either through Code |
| 32 | +Web or using the workspace's terminal. |
| 33 | + |
| 34 | +1. Download the extension(s) from the Microsoft public marketplace. |
| 35 | + |
| 36 | +  |
| 37 | + |
| 38 | +1. Add the `vsix` extension files to the same folder as your Dockerfile. |
| 39 | + |
| 40 | + ```shell |
| 41 | + ~/images/base |
| 42 | + ➜ ls -l |
| 43 | + -rw-r--r-- 1 coder coder 0 Aug 1 19:23 Dockerfile |
| 44 | + -rw-r--r-- 1 coder coder 8925314 Aug 1 19:40 GitHub.copilot.vsix |
| 45 | + ``` |
| 46 | + |
| 47 | +1. In the Dockerfile, add instructions to make a folder and to copy the `vsix` |
| 48 | + files into the newly created folder. |
| 49 | + |
| 50 | + ```Dockerfile |
| 51 | + FROM codercom/enterprise-base:ubuntu |
| 52 | + |
| 53 | + # Run below commands as root user |
| 54 | + USER root |
| 55 | + |
| 56 | + # Download and install VS Code extensions into the container |
| 57 | + RUN mkdir -p /vsix |
| 58 | + ADD ./GitHub.copilot.vsix /vsix |
| 59 | + |
| 60 | + USER coder |
| 61 | + ``` |
| 62 | + |
| 63 | +1. Build the custom image, and push it to your image registry. |
| 64 | + |
| 65 | +1. Pass in the image and below command into your template `startup_script` (be |
| 66 | + sure to update the filename below): |
| 67 | + |
| 68 | + **Startup Script** |
| 69 | + |
| 70 | + ```hcl |
| 71 | + resource "coder_agent" "main" { |
| 72 | + ... |
| 73 | + startup_script = "code-server --install-extension /vsix/Github.copilot.vsix" |
| 74 | + } |
| 75 | + ``` |
| 76 | + |
| 77 | + **Image Definition** |
| 78 | + |
| 79 | + ```hcl |
| 80 | + resource "kubernetes_deployment" "main" { |
| 81 | + spec { |
| 82 | + template { |
| 83 | + spec { |
| 84 | + container { |
| 85 | + name = "dev" |
| 86 | + image = "registry.internal/image-name:tag" |
| 87 | + } |
| 88 | + } |
| 89 | + } |
| 90 | + } |
| 91 | + } |
| 92 | + ``` |
| 93 | + |
| 94 | +1. Create a workspace using the template. |
| 95 | + |
| 96 | +You will now have access to the extension in your workspace. |
| 97 | + |
| 98 | +## Installing extensions using its `vsix` file at the command line |
| 99 | + |
| 100 | +Using the workspace's terminal or the terminal available inside `code-server`, |
| 101 | +you can install an extension whose files you've downloaded from a marketplace: |
| 102 | + |
| 103 | +```console |
| 104 | +/path/to/code-server --install-extension /vsix/Github.copilot.vsix |
| 105 | +``` |
| 106 | + |
| 107 | +## Installing from a marketplace at the command line |
| 108 | + |
| 109 | +Using the workspace's terminal or the terminal available inside Code Web (code |
| 110 | +server), run the following to install an extension (be sure to update the |
| 111 | +snippets with the name of the extension you want to install): |
| 112 | + |
| 113 | +```console |
| 114 | +SERVICE_URL=https://extensions.coder.com/api ITEM_URL=https://extensions.coder.com/item /path/to/code-server --install-extension GitHub.copilot |
| 115 | +``` |
| 116 | + |
| 117 | +Alternatively, you can install an extension from Open VSX's public marketplace: |
| 118 | + |
| 119 | +```console |
| 120 | +SERVICE_URL=https://open-vsx.org/vscode/gallery ITEM_URL=https://open-vsx.org/vscode/item /path/to/code-server --install-extension GitHub.copilot |
| 121 | +``` |
| 122 | + |
| 123 | +## Using VS Code Desktop |
| 124 | + |
| 125 | +For your local VS Code to pickup extension files in your Coder workspace, |
| 126 | +include this command in your `startup_script`, or run in manually in your |
| 127 | +workspace terminal: |
| 128 | + |
| 129 | +```console |
| 130 | +code --extensions-dir ~/.vscode-server/extensions --install-extension "$extension" |
| 131 | +``` |
0 commit comments