Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b06d833

Browse files
EdwardAngertjohnstcnbpmctEdward Angertmatifali
authored
docs: improve dev containers documentation for user start-up (#15458)
- [x] TODO: verify and expand [What is an image, template, devcontainer, or workspace](https://coder.com/docs/@bp-dev-containers/admin#what-is-an-image-template-devcontainer-or-workspace) - [x] TODO: verify and expand `## Add a devcontainer template to Coder` - [x] TODO: verify and expand `## Layer and image caching` - [x] TODO: link to and edit [dotfiles](https://coder.com/docs/user-guides/workspace-dotfiles) doc - [x] TODO: https://github.com/coder/coder/pull/15458/files#diff-be0dd9ff983020129c7a94c628a0fc4a397a9bbc8b5eec92ec38f4b8c83fe167R10 [preview](https://coder.com/docs/@bp-dev-containers/admin/templates/managing-templates/devcontainers) --------- Co-authored-by: EdwardAngert <[email protected]> Co-authored-by: Cian Johnston <[email protected]> Co-authored-by: Ben Potter <[email protected]> Co-authored-by: Edward Angert <[email protected]> Co-authored-by: Muhammad Atif Ali <[email protected]>
1 parent 19ec6af commit b06d833

11 files changed

+440
-120
lines changed

docs/admin/index.md

+52
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,56 @@ and [API](../reference/api/index.md) docs.
1515
For any information not strictly contained in these sections, check out our
1616
[Tutorials](../tutorials/index.md) and [FAQs](../tutorials/faqs.md).
1717

18+
## What is an image, template, dev container, or workspace
19+
20+
**Image**
21+
22+
- A [base image](./templates/managing-templates/image-management.md) contains
23+
OS-level packages and utilities that the Coder workspace is built on. It can
24+
be an [example image](https://github.com/coder/images), custom image in your
25+
registry, or one from [Docker Hub](https://hub.docker.com/search). It is
26+
defined in each template.
27+
- Managed by: Externally to Coder.
28+
29+
**Template**
30+
31+
- [Templates](./templates/index.md) include infrastructure-level dependencies
32+
for the workspace. For example, a template can include Kubernetes
33+
PersistentVolumeClaims, Docker containers, or EC2 VMs.
34+
- Managed by: Template administrators from within the Coder deployment.
35+
36+
**Startup scripts**
37+
38+
- Agent startup scripts apply to all users of a template. This is an
39+
intentionally flexible area that template authors have at their disposal to
40+
manage the "last mile" of workspace creation.
41+
- Managed by: Coder template administrators.
42+
43+
**Workspace**
44+
45+
- A [workspace](../user-guides/workspace-management.md) is the environment that
46+
a developer works in. Developers on a team each work from their own workspace
47+
and can use [multiple IDEs](../user-guides/workspace-access/index.md).
48+
- Managed by: Developers
49+
50+
**Development containers (dev containers)**
51+
52+
- A
53+
[Development Container](./templates/managing-templates/devcontainers/index.md)
54+
is an open-source specification for defining development environments (called
55+
dev containers). It is generally stored in VCS alongside associated source
56+
code. It can reference an existing base image, or a custom Dockerfile that
57+
will be built on-demand.
58+
- Managed by: Dev Teams
59+
60+
**Dotfiles / personalization**
61+
62+
- Users may have their own specific preferences relating to shell prompt, custom
63+
keybindings, color schemes, and more. Users can leverage Coder's
64+
[dotfiles support](../user-guides/workspace-dotfiles.md) or create their own
65+
script to personalize their workspace. Be aware that users with root
66+
permissions in their workspace can override almost all of the previous
67+
configuration.
68+
- Managed by: Individual Users
69+
1870
<children></children>

docs/admin/templates/index.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ needs of different teams.
4848

4949
- [Image management](./managing-templates/image-management.md): Learn how to
5050
create and publish images for use within Coder workspaces & templates.
51-
- [Dev Container support](./managing-templates/devcontainers.md): Enable dev
52-
containers to allow teams to bring their own tools into Coder workspaces.
51+
- [Dev Container support](./managing-templates/devcontainers/index.md): Enable
52+
dev containers to allow teams to bring their own tools into Coder workspaces.
5353
- [Template hardening](./extending-templates/resource-persistence.md#-bulletproofing):
5454
Configure your template to prevent certain resources from being destroyed
5555
(e.g. user disks).

docs/admin/templates/managing-templates/devcontainers.md

-112
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
# Add a dev container template to Coder
2+
3+
A Coder administrator adds a dev container-compatible template to Coder
4+
(Envbuilder). This allows the template to prompt for the developer for their dev
5+
container repository's URL as a
6+
[parameter](../../extending-templates/parameters.md) when they create their
7+
workspace. Envbuilder clones the repo and builds a container from the
8+
`devcontainer.json` specified in the repo.
9+
10+
You can create template files through the Coder dashboard, CLI, or you can
11+
choose a template from the
12+
[Coder registry](https://registry.coder.com/templates):
13+
14+
<div class="tabs">
15+
16+
## Dashboard
17+
18+
1. In the Coder dashboard, select **Templates** then **Create Template**.
19+
1. Use a
20+
[starter template](https://github.com/coder/coder/tree/main/examples/templates)
21+
or create a new template:
22+
23+
- Starter template:
24+
25+
1. Select **Choose a starter template**.
26+
1. Choose a template from the list or select **Devcontainer** from the
27+
sidebar to display only dev container-compatible templates.
28+
1. Select **Use template**, enter the details, then select **Create
29+
template**.
30+
31+
- To create a new template, select **From scratch** and enter the templates
32+
details, then select **Create template**.
33+
34+
1. Edit the template files to fit your deployment.
35+
36+
## CLI
37+
38+
1. Use the `template init` command to initialize your choice of image:
39+
40+
```shell
41+
coder template init --id devcontainer-kubernetes
42+
```
43+
44+
A list of available templates is shown in the
45+
[templates_init](../../../../reference/cli/templates.md) reference.
46+
47+
1. `cd` into the directory and push the template to your Coder deployment:
48+
49+
```shell
50+
cd devcontainer-kubernetes && coder templates push
51+
```
52+
53+
You can also edit the files or make changes to the files before you push them
54+
to Coder.
55+
56+
## Registry
57+
58+
1. Go to the [Coder registry](https://registry.coder.com/templates) and select a
59+
dev container-compatible template.
60+
61+
1. Copy the files to your local device, then edit them to fit your needs.
62+
63+
1. Upload them to Coder through the CLI or dashboard:
64+
65+
- CLI:
66+
67+
```shell
68+
coder templates push <template-name> -d <path to folder containing main.tf>
69+
```
70+
71+
- Dashboard:
72+
73+
1. Create a `.zip` of the template files:
74+
75+
- On Mac or Windows, highlight the files and then right click. A
76+
"compress" option is available through the right-click context menu.
77+
78+
- To zip the files through the command line:
79+
80+
```shell
81+
zip templates.zip Dockerfile main.tf
82+
```
83+
84+
1. Select **Templates**.
85+
1. Select **Create Template**, then **Upload template**:
86+
87+
![Upload template](../../../../images/templates/upload-create-your-first-template.png)
88+
89+
1. Drag the `.zip` file into the **Upload template** section and fill out the
90+
details, then select **Create template**.
91+
92+
![Upload the template files](../../../../images/templates/upload-create-template-form.png)
93+
94+
</div>
95+
96+
To set variables such as the namespace, go to the template in your Coder
97+
dashboard and select **Settings** from the **** (vertical ellipsis) menu:
98+
99+
<Image height="255px" src="../../../../images/templates/template-menu-settings.png" alt="Choose Settings from the template's menu" align="center" />
100+
101+
## Envbuilder Terraform provider
102+
103+
When using the
104+
[Envbuilder Terraform provider](https://registry.terraform.io/providers/coder/envbuilder/latest/docs),
105+
a previously built and cached image can be reused directly, allowing dev
106+
containers to start instantaneously.
107+
108+
Developers can edit the `devcontainer.json` in their workspace to customize
109+
their development environments:
110+
111+
```json
112+
#
113+
{
114+
"features": {
115+
"ghcr.io/devcontainers/features/common-utils:2": {}
116+
}
117+
}
118+
#
119+
```
120+
121+
## Example templates
122+
123+
| Template | Description |
124+
| ------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
125+
| [Docker dev containers](https://github.com/coder/coder/tree/main/examples/templates/devcontainer-docker) | Docker provisions a development container. |
126+
| [Kubernetes dev containers](https://github.com/coder/coder/tree/main/examples/templates/devcontainer-kubernetes) | Provisions a development container on the Kubernetes cluster. |
127+
| [Google Compute Engine dev container](https://github.com/coder/coder/tree/main/examples/templates/gcp-devcontainer) | Runs a development container inside a single GCP instance. It also mounts the Docker socket from the VM inside the container to enable Docker inside the workspace. |
128+
| [AWS EC2 dev container](https://github.com/coder/coder/tree/main/examples/templates/aws-devcontainer) | Runs a development container inside a single EC2 instance. It also mounts the Docker socket from the VM inside the container to enable Docker inside the workspace. |
129+
130+
Your template can prompt the user for a repo URL with
131+
[parameters](../../extending-templates/parameters.md):
132+
133+
![Dev container parameter screen](../../../../images/templates/devcontainers.png)
134+
135+
## Dev container lifecycle scripts
136+
137+
The `onCreateCommand`, `updateContentCommand`, `postCreateCommand`, and
138+
`postStartCommand` lifecycle scripts are run each time the container is started.
139+
This could be used, for example, to fetch or update project dependencies before
140+
a user begins using the workspace.
141+
142+
Lifecycle scripts are managed by project developers.
143+
144+
## Next steps
145+
146+
- [Dev container security and caching](./devcontainer-security-caching.md)
147+
148+
```
149+
150+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Dev container releases and known issues
2+
3+
## Release channels
4+
5+
Envbuilder provides two release channels:
6+
7+
- **Stable**
8+
- Available at
9+
[`ghcr.io/coder/envbuilder`](https://github.com/coder/envbuilder/pkgs/container/envbuilder).
10+
Tags `>=1.0.0` are considered stable.
11+
- **Preview**
12+
- Available at
13+
[`ghcr.io/coder/envbuilder-preview`](https://github.com/coder/envbuilder/pkgs/container/envbuilder-preview).
14+
Built from the tip of `main`, and should be considered experimental and
15+
prone to breaking changes.
16+
17+
Refer to the
18+
[Envbuilder GitHub repository](https://github.com/coder/envbuilder/) for more
19+
information and to submit feature requests or bug reports.
20+
21+
## Known issues
22+
23+
Visit the
24+
[Envbuilder repository](https://github.com/coder/envbuilder/blob/main/docs/devcontainer-spec-support.md)
25+
for a full list of supported features and known issues.

0 commit comments

Comments
 (0)