|
| 1 | +--- |
| 2 | +title: Developers |
| 3 | +description: Get started with Coder as a developer. |
| 4 | +--- |
| 5 | + |
| 6 | +This article will walk you through the process of getting started with a Coder |
| 7 | +workspace and a web development project featuring Node.js and React.js. You'll |
| 8 | +learn how to: |
| 9 | + |
| 10 | +- Connect Coder to your Git provider; |
| 11 | +- Create a workspace; |
| 12 | +- Add a sample project to your workspace; |
| 13 | +- Create a dev URL and preview changes to your project. |
| 14 | + |
| 15 | +## Prerequisites |
| 16 | + |
| 17 | +This guide assumes that you have a Coder deployment available to you and that |
| 18 | +you have the credentials needed to access the deployment. |
| 19 | + |
| 20 | +## Step 1: Log in and connect Coder to your Git provider |
| 21 | + |
| 22 | +In this step, you'll log into Coder and connect and authenticate with your Git |
| 23 | +provider. This will allow you to do things like pull repositories and push |
| 24 | +changes. |
| 25 | + |
| 26 | +1. Navigate to the Coder deployment using the URL provided to you by your site |
| 27 | + manager, and log in. |
| 28 | + |
| 29 | +1. Click on your avatar in the top-right, and select **Account**. |
| 30 | + |
| 31 | +  |
| 32 | + |
| 33 | +1. Provide Coder with your SSH key to connect and authenticate to GitHub. |
| 34 | + |
| 35 | + If your site manager has configured OAuth, go to **Linked Accounts** and |
| 36 | + follow the on-screen instructions to link your GitHub account. |
| 37 | + |
| 38 | +  |
| 39 | + |
| 40 | + If your site manager has _not_ configured OAuth, go to **SSH keys**. Copy |
| 41 | + your public SSH key and |
| 42 | + [provide it to GitHub](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account). |
| 43 | + |
| 44 | +  |
| 45 | + |
| 46 | +## Step 2: Create your workspace |
| 47 | + |
| 48 | +You will now create the workspace where you'll work on your development project. |
| 49 | + |
| 50 | +1. Return to **Workspaces** using the top navigation bar. |
| 51 | + |
| 52 | +1. Click **New workspace** to launch the workspace-creation dialog. |
| 53 | + |
| 54 | +1. Provide a **Workspace Name**. |
| 55 | + |
| 56 | +1. In the **Image** section, click **Packaged** (this tab contains |
| 57 | + Coder-provided images hosted in a Docker registry). Select **NodeJS**. This |
| 58 | + will populate the form in the **Import** tab. |
| 59 | + |
| 60 | +1. Under **Workspace providers**, leave the default option (which is |
| 61 | + **built-in**) selected. |
| 62 | + |
| 63 | +1. Expand the **Advanced** section. If the **Run as a container-based virtual |
| 64 | + machine** option is selected, _unselect_ the box. Leave the **CPU**, |
| 65 | + **Memory**, **Disk**, and **GPU** allocations as-is. |
| 66 | + |
| 67 | +1. Scroll to the bottom, and click **Create workspace**. The dialog will close, |
| 68 | + allowing you to see the main workspace page. You can track the workspace |
| 69 | + build process using the **Build log** on the right-hand side. |
| 70 | + |
| 71 | + |
| 72 | + |
| 73 | +Once your workspace is ready for use, you'll see a chip that says **Running** |
| 74 | +next to the name of your workspace. |
| 75 | + |
| 76 | +## Step 3: Add a sample project to your workspace |
| 77 | + |
| 78 | +Once you've created your workspace, you can start using Coder after adding a |
| 79 | +sample project to your workspace. |
| 80 | + |
| 81 | +1. Under **Browser applications**, click **Code Web** to open VS Code in your |
| 82 | + browser. |
| 83 | + |
| 84 | +1. When VS Code launches in your browser, click **Open folder...**. In the |
| 85 | + prompt, you'll see `/home/coder`. This directory is where you'll clone a |
| 86 | + sample React app project Git repository. Click **OK** to proceed. |
| 87 | + |
| 88 | +  |
| 89 | + |
| 90 | +1. Click the hamburger icon in the top right, and select **Terminal** > **New |
| 91 | + Terminal** to open a new terminal. |
| 92 | + |
| 93 | +1. Clone the `create-react-app` repository: |
| 94 | + |
| 95 | + ```console |
| 96 | + git clone git@github.com:facebook/create-react-app.git |
| 97 | + ``` |
| 98 | + |
| 99 | + Once you've cloned the repository, you can click the **Explorer** icon and |
| 100 | + expand the **create-react-app** folder in the left-have nav bar to see the |
| 101 | + contents of the repo. |
| 102 | + |
| 103 | +  |
| 104 | + |
| 105 | + You're now ready to make changes to the application. |
| 106 | + |
| 107 | +## Step 4: Preview your app and view changes live |
| 108 | + |
| 109 | +Dev URLs allow you to access the web services you're developing in your |
| 110 | +workspace. Once you've created a dev URL, Coder listens on the port you |
| 111 | +specified and renders a browser link you can use to view your application. |
| 112 | + |
| 113 | +> Please note that your site manager must have enabled and configured dev URLs |
| 114 | +> for your Coder deployment before you can use this feature. |
| 115 | +
|
| 116 | +1. Return to your workspace overview page, and find the **Dev URLs** section. |
| 117 | + |
| 118 | +1. Click **Add port**. |
| 119 | + |
| 120 | +1. Provide a **Name** for your port, and leave the remaining fields as-is. Click |
| 121 | + **Save**. |
| 122 | + |
| 123 | +  |
| 124 | + |
| 125 | +1. At this point, you can build and run the sample app by returning to your Code |
| 126 | + Web window and running the following in the terminal: |
| 127 | + |
| 128 | + ```console |
| 129 | + npx create-react-app my-app |
| 130 | + cd my-app |
| 131 | + npm start |
| 132 | + ``` |
| 133 | + |
| 134 | +1. From the workspace overview, launch your dev URL by clicking its name; Coder |
| 135 | + will open a new browser window and point you to the appropriate URL. |
| 136 | + |
| 137 | +  |
| 138 | + |
| 139 | +1. You can test preview by making changes to the `src/App.js` file; every time |
| 140 | + you save your changes to this file, your preview will reload. |
| 141 | + |
| 142 | +  |
0 commit comments