|
| 1 | +# Pre-install JetBrains Gateway in a template |
| 2 | + |
| 3 | +For a faster JetBrains Gateway experience, pre-install the IDEs backend in your template. |
| 4 | + |
| 5 | +> [!NOTE] |
| 6 | +> This guide only talks about installing the IDEs backend. For a complete guide on setting up JetBrains Gateway with client IDEs, refer to the [JetBrains Gateway air-gapped guide](../../../user-guides/workspace-access/jetbrains/jetbrains-airgapped.md). |
| 7 | +
|
| 8 | +## Install the Client Downloader |
| 9 | + |
| 10 | +Install the JetBrains Client Downloader binary: |
| 11 | + |
| 12 | +```shell |
| 13 | +wget https://download.jetbrains.com/idea/code-with-me/backend/jetbrains-clients-downloader-linux-x86_64-1867.tar.gz && \ |
| 14 | +tar -xzvf jetbrains-clients-downloader-linux-x86_64-1867.tar.gz |
| 15 | +rm jetbrains-clients-downloader-linux-x86_64-1867.tar.gz |
| 16 | +``` |
| 17 | + |
| 18 | +## Install Gateway backend |
| 19 | + |
| 20 | +```shell |
| 21 | +mkdir ~/JetBrains |
| 22 | +./jetbrains-clients-downloader-linux-x86_64-1867/bin/jetbrains-clients-downloader --products-filter <product-code> --build-filter <build-number> --platforms-filter linux-x64 --download-backends ~/JetBrains |
| 23 | +``` |
| 24 | + |
| 25 | +For example, to install the build `243.26053.27` of IntelliJ IDEA: |
| 26 | + |
| 27 | +```shell |
| 28 | +./jetbrains-clients-downloader-linux-x86_64-1867/bin/jetbrains-clients-downloader --products-filter IU --build-filter 243.26053.27 --platforms-filter linux-x64 --download-backends ~/JetBrains |
| 29 | +tar -xzvf ~/JetBrains/backends/IU/*.tar.gz -C ~/JetBrains/backends/IU |
| 30 | +rm -rf ~/JetBrains/backends/IU/*.tar.gz |
| 31 | +``` |
| 32 | + |
| 33 | +## Register the Gateway backend |
| 34 | + |
| 35 | +Add the following command to your template's `startup_script`: |
| 36 | + |
| 37 | +```shell |
| 38 | +~/JetBrains/backends/IU/ideaIU-243.26053.27/bin/remote-dev-server.sh registerBackendLocationForGateway |
| 39 | +``` |
| 40 | + |
| 41 | +## Configure JetBrains Gateway Module |
| 42 | + |
| 43 | +If you are using our [jetbrains-gateway](https://registry.coder.com/modules/jetbrains-gateway) module, you can configure it by adding the following snippet to your template: |
| 44 | + |
| 45 | +```tf |
| 46 | +module "jetbrains_gateway" { |
| 47 | + count = data.coder_workspace.me.start_count |
| 48 | + source = "registry.coder.com/modules/jetbrains-gateway/coder" |
| 49 | + version = "1.0.28" |
| 50 | + agent_id = coder_agent.main.id |
| 51 | + folder = "/home/coder/example" |
| 52 | + jetbrains_ides = ["IU"] |
| 53 | + default = "IU" |
| 54 | + latest = false |
| 55 | + jetbrains_ide_versions = { |
| 56 | + "IU" = { |
| 57 | + build_number = "243.26053.27" |
| 58 | + version = "2024.3" |
| 59 | + } |
| 60 | + } |
| 61 | +} |
| 62 | +
|
| 63 | +resource "coder_agent" "main" { |
| 64 | + ... |
| 65 | + startup_script = <<-EOF |
| 66 | + ~/JetBrains/backends/IU/ideaIU-243.26053.27/bin/remote-dev-server.sh registerBackendLocationForGateway |
| 67 | + EOF |
| 68 | +} |
| 69 | +``` |
| 70 | + |
| 71 | +## Dockerfile example |
| 72 | + |
| 73 | +If you are using Docker based workspaces, you can add the command to your Dockerfile: |
| 74 | + |
| 75 | +```dockerfile |
| 76 | +FROM ubuntu |
| 77 | + |
| 78 | +# Combine all apt operations in a single RUN command |
| 79 | +# Install only necessary packages |
| 80 | +# Clean up apt cache in the same layer |
| 81 | +RUN apt-get update \ |
| 82 | + && apt-get install -y --no-install-recommends \ |
| 83 | + curl \ |
| 84 | + git \ |
| 85 | + golang \ |
| 86 | + sudo \ |
| 87 | + vim \ |
| 88 | + wget \ |
| 89 | + && apt-get clean \ |
| 90 | + && rm -rf /var/lib/apt/lists/* |
| 91 | + |
| 92 | +# Create user in a single layer |
| 93 | +ARG USER=coder |
| 94 | +RUN useradd --groups sudo --no-create-home --shell /bin/bash ${USER} \ |
| 95 | + && echo "${USER} ALL=(ALL) NOPASSWD:ALL" >/etc/sudoers.d/${USER} \ |
| 96 | + && chmod 0440 /etc/sudoers.d/${USER} |
| 97 | + |
| 98 | +USER ${USER} |
| 99 | +WORKDIR /home/${USER} |
| 100 | + |
| 101 | +# Install JetBrains Gateway in a single RUN command to reduce layers |
| 102 | +# Download, extract, use, and clean up in the same layer |
| 103 | +RUN mkdir -p ~/JetBrains \ |
| 104 | + && wget -q https://download.jetbrains.com/idea/code-with-me/backend/jetbrains-clients-downloader-linux-x86_64-1867.tar.gz -P /tmp \ |
| 105 | + && tar -xzf /tmp/jetbrains-clients-downloader-linux-x86_64-1867.tar.gz -C /tmp \ |
| 106 | + && /tmp/jetbrains-clients-downloader-linux-x86_64-1867/bin/jetbrains-clients-downloader \ |
| 107 | + --products-filter IU \ |
| 108 | + --build-filter 243.26053.27 \ |
| 109 | + --platforms-filter linux-x64 \ |
| 110 | + --download-backends ~/JetBrains \ |
| 111 | + && tar -xzf ~/JetBrains/backends/IU/*.tar.gz -C ~/JetBrains/backends/IU \ |
| 112 | + && rm -f ~/JetBrains/backends/IU/*.tar.gz \ |
| 113 | + && rm -rf /tmp/jetbrains-clients-downloader-linux-x86_64-1867* \ |
| 114 | + && rm -rf /tmp/*.tar.gz |
| 115 | +``` |
| 116 | + |
| 117 | +## Next steps |
| 118 | + |
| 119 | +- [Pre-install the Client IDEs](../../../user-guides/workspace-access/jetbrains/jetbrains-airgapped.md#1-deploy-the-server-and-install-the-client-downloader) |
0 commit comments