Files
coder/docs/start/first-template.md
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

130 lines
4.2 KiB
Markdown
Raw Normal View History

2023-10-17 17:47:12 +03:00
# Your first template
A common way to create a template is to begin with a starter template then
modify it for your needs. Coder makes this easy with starter templates for
popular development targets like Docker, Kubernetes, Azure, and so on. Once your
template is up and running, you can edit it in the Coder dashboard. Coder even
handles versioning for you so you can publish official updates or revert to
previous versions.
In this tutorial, you'll create your first template from the Docker starter
template.
## Before you start
2024-10-05 08:52:04 -07:00
Use the [previous section](./local-deploy.md) of this guide to set up
[Docker](https://docs.docker.com/get-docker/) and [Coder](../install/cli.md) on
your local machine to continue.
2023-10-17 17:47:12 +03:00
## 1. Log in to Coder
2024-10-05 08:52:04 -07:00
In your web browser, go to your Coder dashboard using the URL provided during
setup to log in.
2023-10-17 17:47:12 +03:00
## 2. Choose a starter template
2024-10-05 08:52:04 -07:00
Select **Templates** to see the **Starter Templates**. Use the **Docker
Containers** template by pressing **Use Template**.
2023-10-17 17:47:12 +03:00
2024-10-05 08:52:04 -07:00
![Starter Templates UI](../images/start/starter-templates.png)
2023-10-17 17:47:12 +03:00
You can also a find a comprehensive list of starter templates in **Templates**
-> **Create Template** -> **Starter Templates**. s
2023-10-17 17:47:12 +03:00
## 3. Create your template
2024-10-05 08:52:04 -07:00
In **Create template**, fill in **Name** and **Display name**, then select
**Create template**.
2023-10-17 17:47:12 +03:00
2024-10-05 08:52:04 -07:00
![Creating a template](../images/start/create-template.png)
2023-10-17 17:47:12 +03:00
2024-10-05 08:52:04 -07:00
TODO:
- add CLI guide for making a new template
- refactor text below to be more beginner-friendly
<!-- ## 4. Create a workspace from your template
2023-10-17 17:47:12 +03:00
When the template is ready, select **Create Workspace**.
2024-10-05 08:52:04 -07:00
![Template Preview](../images/start/template-preview.png)
2023-10-17 17:47:12 +03:00
In **New workspace**, fill in **Name** then scroll down to select **Create
Workspace**.
2024-10-05 08:52:04 -07:00
![Create Workspace](../images/start/create-workspace.png)
2023-10-17 17:47:12 +03:00
Coder starts your new workspace from your template.
After a few seconds, your workspace is ready to use.
![Workspace is ready](../images/templates/workspace-ready.png)
## 5. Try out your new workspace
This starter template lets you connect to your workspace in a few ways:
- VS Code Desktop: Loads your workspace into
[VS Code Desktop](https://code.visualstudio.com/Download) installed on your
local computer.
- code-server: Opens [browser-based VS Code](../ides/web-ides.md) with your
workspace.
- Terminal: Opens a browser-based terminal with a shell in the workspace's
Docker instance.
- SSH: Use SSH to log in to the workspace from your local machine. If you
haven't already, you'll have to install Coder on your local machine to
configure your SSH client.
> [!TIP]
> You can edit the template to let developers connect to a workspace in
2023-10-17 17:47:12 +03:00
> [a few more ways](../ides.md).
2024-10-05 08:52:04 -07:00
When you're done, you can stop the workspace. -->
2023-10-17 17:47:12 +03:00
## 6. Modify your template
Now you can modify your template to suit your team's needs.
Let's replace the `golang` package in the Docker image with the `python3`
package. You can do this by editing the template's `Dockerfile` directly in your
web browser.
In the Coder dashboard, select **Templates** then your first template.
![Selecting the first template](../images/templates/select-template.png)
In the drop-down menu, select **Edit files**.
![Edit template files](../images/templates/edit-files.png)
Expand the **build** directory and select **Dockerfile**.
![Selecting source code](../images/templates/source-code.png)
Edit `build/Dockerfile` to replace `golang` with `python3`.
![Editing source code](../images/templates/edit-source-code.png)
Select **Build template** and wait for Coder to prepare the template for
workspaces.
![Building a template](../images/templates/build-template.png)
Select **Publish version**. In the **Publish new version** dialog, make sure
**Promote to active version** is checked then select **Publish**.
2023-10-17 17:47:12 +03:00
![Publish a template](../images/templates/publish.png)
Now when developers create a new workspace from this template, they can use
Python 3 instead of Go.
For developers with workspaces that were created with a previous version of your
template, Coder will notify them that there's a new version of the template.
2024-10-05 08:52:04 -07:00
You can also handle
[change management](../admin/templates/managing-templates/change-management.md)
through your own repo and continuous integration.
2023-10-17 17:47:12 +03:00
## Next steps
2024-10-05 08:52:04 -07:00
- [Setting up templates](../admin/templates/creating-templates.md)