|
1 |
| -# How to manage Coder templates |
2 |
| - |
3 |
| -Coder templates are the DNA used to create workspaces. They abstract the complexity of cloud environments, allowing developers to focus on their projects. |
4 |
| - |
5 |
| -[](./static/templates.png) |
6 |
| - |
7 |
| -## Organizing your templates |
8 |
| - |
9 |
| -There are many ways to organize your templates. You can use them to: |
10 |
| - |
11 |
| -### Team based templates |
12 |
| - |
13 |
| -A template for each of your teams e.g. a template for your _frontend_ team and a template for your _backend_ team. |
14 |
| - |
15 |
| -### Project based templates |
16 |
| - |
17 |
| -A template for each of your projects e.g. a template for your _cool-project_ and a template for your _awesome-project_. |
18 |
| - |
19 |
| -### Image based templates |
20 |
| - |
21 |
| -A single template that is used for all your projects but with a different image for each project. |
22 |
| - |
23 |
| -## What is the difference between a template and an image? |
24 |
| - |
25 |
| -A template is a collection of settings that are used to create a workspace. An image is a collection of software that is used to create a workspace. A template can use one or more images. For example, you can have a template that uses the _ubuntu_ image and the _node_ image and the user will have the choice of which image to use when creating a workspace. Choices are managed by a terraform variable e.g. |
26 |
| - |
27 |
| -```hcl |
28 |
| - variable "image" { |
29 |
| - type = string |
30 |
| - description = "The image to use for the workspace" |
31 |
| - default = "ubuntu" |
32 |
| - validation { |
33 |
| - condition = contains(["ubuntu", "node"], var.image) |
34 |
| - error_message = "The image must be either ubuntu or node" |
35 |
| - } |
36 |
| - } |
37 |
| -``` |
38 |
| - |
39 |
| -## Creating your first template |
40 |
| - |
41 |
| -### Create a new repository |
42 |
| - |
43 |
| -Create a new repository in your GitHub account. This will be the repository that contains your Coder templates. |
44 |
| - |
45 |
| -### Create a new directory |
46 |
| - |
47 |
| -Create a new directory in your repository called `deeplearning`. |
48 |
| - |
49 |
| -### Create a new file |
50 |
| - |
51 |
| -Create a new file in the _templates_ directory called `main.tf` This is the file that contains the Coder template. |
52 |
| - |
53 |
| -```hcl |
54 |
| - provider "coder" { |
55 |
| - name = "coder" |
56 |
| - version = "0.6.11" |
57 |
| - } |
58 |
| -
|
59 |
| - provider "docker" { |
60 |
| -
|
61 |
| - version = "2.7.2" |
62 |
| - } |
63 |
| -``` |
| 1 | +# How to manage Coder templates |
| 2 | + |
| 3 | +Coder templates are the DNA used to create workspaces. They abstract the complexity of cloud environments, allowing developers to focus on their projects. |
| 4 | + |
| 5 | +[](./static/templates.png) |
| 6 | + |
| 7 | +## Organizing your templates |
| 8 | + |
| 9 | +There are many ways to organize your templates. You can use them to: |
| 10 | + |
| 11 | +### Team based templates |
| 12 | + |
| 13 | +A template for each of your teams e.g. a template for your _frontend_ team and a template for your _backend_ team. |
| 14 | + |
| 15 | +### Project based templates |
| 16 | + |
| 17 | +A template for each of your projects e.g. a template for your _cool-project_ and a template for your _awesome-project_. |
| 18 | + |
| 19 | +### Image based templates |
| 20 | + |
| 21 | +A single template that is used for all your projects but with a different image for each project. |
| 22 | + |
| 23 | +## What is the difference between a template and an image? |
| 24 | + |
| 25 | +A template is a collection of settings that are used to create a workspace. An image is a collection of software that is used to create a workspace. A template can use one or more images. For example, you can have a template that uses the _ubuntu_ image and the _node_ image and the user will have the choice of which image to use when creating a workspace. Choices are managed by a terraform variable e.g. |
| 26 | + |
| 27 | +```hcl |
| 28 | + variable "image" { |
| 29 | + type = string |
| 30 | + description = "The image to use for the workspace" |
| 31 | + default = "ubuntu" |
| 32 | + validation { |
| 33 | + condition = contains(["ubuntu", "node"], var.image) |
| 34 | + error_message = "The image must be either ubuntu or node" |
| 35 | + } |
| 36 | + } |
| 37 | +``` |
| 38 | + |
| 39 | +## Creating your first template |
| 40 | + |
| 41 | +1. Create a new repository in your GitHub account. This will be the repository that contains your Coder templates. |
| 42 | + |
| 43 | +2. Create a new directory in your repository called `deeplearning`. |
| 44 | + |
| 45 | +3. Create a new file in the _templates_ directory called `main.tf` This is the file that contains the Coder template. |
| 46 | + |
| 47 | + ```hcl |
| 48 | + terraform { |
| 49 | + required_providers { |
| 50 | + coder = { |
| 51 | + source = "coder/coder" |
| 52 | + version = "0.6.12" |
| 53 | + } |
| 54 | + docker = { |
| 55 | + source = "kreuzwerker/docker" |
| 56 | + version = "3.0.1" |
| 57 | + } |
| 58 | + } |
| 59 | + } |
| 60 | +
|
| 61 | + provider "docker" { |
| 62 | + # Configuration options |
| 63 | + } |
| 64 | + ``` |
0 commit comments