Skip to content

docs: improve workspaces and templates doc #9139

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 42 commits into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
224bf4c
Reorg, updated/new screenshots, consistent terminology
marcpaq Aug 16, 2023
d494d28
First pass
marcpaq Aug 17, 2023
eabd21f
Another pass
marcpaq Aug 17, 2023
a92693d
Added integration section
marcpaq Aug 21, 2023
46618e4
New outline for template pages, small updates
marcpaq Aug 22, 2023
85535d0
Revised outline for templates, added tutorial
marcpaq Aug 23, 2023
bbd4928
First pass at tutorial
marcpaq Aug 23, 2023
3cc2dbb
Some feedback from Ben.
marcpaq Aug 23, 2023
cb39a6d
Update docs/workspaces.md
marcpaq Aug 25, 2023
6706032
Update docs/workspaces.md
marcpaq Aug 25, 2023
4e4b9e5
Update docs/workspaces.md
marcpaq Aug 25, 2023
351c457
Fixed typos
marcpaq Aug 25, 2023
50e9041
Expanded tutorial
marcpaq Aug 28, 2023
ed27c28
New screenshots, improved tutorial, revised anatomy
marcpaq Sep 7, 2023
744bad0
Improved tutorial. Anatomy is now a guided tour.
marcpaq Sep 8, 2023
58d5c9e
First pass at guided tour
marcpaq Sep 8, 2023
bf5228c
Updated authentication info
marcpaq Sep 11, 2023
92eea5f
Reorganized the guided tour
marcpaq Sep 12, 2023
302f5dd
Edited more template pages
marcpaq Sep 13, 2023
c80c0e3
Update docs/templates/tour.md
marcpaq Sep 15, 2023
e308e5d
Update docs/templates/tour.md
marcpaq Sep 15, 2023
22570dd
Update docs/templates/tour.md
marcpaq Sep 15, 2023
cbeac94
Update docs/templates/tutorial.md
marcpaq Sep 15, 2023
b12c1d6
Update docs/templates/tour.md
marcpaq Sep 15, 2023
b4f33d5
Update docs/templates/tour.md
marcpaq Sep 15, 2023
ec1741e
Update docs/templates/tour.md
marcpaq Sep 15, 2023
223dc9a
Update docs/templates/tour.md
marcpaq Sep 15, 2023
cb266c6
Update docs/templates/tour.md
marcpaq Sep 15, 2023
b5c0371
Revised devcontainers and docker-in-workspaces
marcpaq Sep 15, 2023
9f16953
Edited and added screenshots
marcpaq Sep 18, 2023
6bda970
Prepared first draft, except docs/templates/open-in-coder.md
marcpaq Sep 19, 2023
c2d992b
Fix typo
marcpaq Oct 3, 2023
c9a6c3c
remove legacy parameters and migration guide
matifali Oct 9, 2023
3efae01
Use coder templates create
marcpaq Oct 11, 2023
267639c
Added screenshot for workspace template variables
marcpaq Oct 12, 2023
5c64352
Made it prettier
marcpaq Oct 12, 2023
dbfc80d
Fixed minor typos and markdown problems
marcpaq Oct 12, 2023
6506168
edits to repairing workspaces
bpmct Oct 15, 2023
588a08a
fix broken links in product
bpmct Oct 15, 2023
151687d
Added troubleshooting, minor corrections.
marcpaq Oct 16, 2023
456f5d5
fix terminal links
bpmct Oct 16, 2023
59528ff
fmt
matifali Oct 16, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified docs/images/autostart.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/autostop.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/creating-workspace-ui.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/schedule.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/workspace-update.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
134 changes: 81 additions & 53 deletions docs/workspaces.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,31 @@
# Workspaces

Workspaces contain the IDEs, dependencies, and configuration information needed
for software development.
A workspace is the environment that a developer works in. Developers
in a team each work from their own workspace and can use [multiple
IDEs](./ides.md).

## Create workspaces
A developer creates a workspace from a [shared
template](./templates/index.md). This lets an entire team work in
environments that are identically configured and provisioned with the
same resources.

Each Coder user has their own workspaces created from [shared templates](./templates/index.md):

## Creating workspaces

You can create a workspace in the UI. Log in to your Coder instance,
go to the **Templates** tab, find the template you need, and select
**Create Workspace**.

![Creating a workspace in the UI](./images/creating-workspace-ui.png)

When you create a workspace, you will be prompted to give it a name. You
might also be prompted to set some parameters that the template
provides.

You can manage your existing templates in the **Workspaces**
tab.

You can also create a workspace from the command line:

```console
# create a workspace from the template; specify any variables
Expand All @@ -15,76 +35,97 @@ coder create --template="<templateName>" <workspaceName>
coder show <workspace-name>
```

## IDEs

Coder [supports multiple IDEs](./ides.md) for use with your workspaces.
## Workspace filtering

## Workspace lifecycle
In the Coder UI, you can filter your workspaces using pre-defined
filters or Coder's filter query. For example, you can find the
workspaces that you own or that are currently running.

Workspaces in Coder are started and stopped, often based on whether there was
any activity or if there was a [template update](./templates/index.md#Start/stop) available.
The following filters are supported:

Resources are often destroyed and re-created when a workspace is restarted,
though the exact behavior depends on the template. For more
information, see [Resource Persistence](./templates/resource-persistence.md).
- `owner` - Represents the `username` of the owner. You can also use `me` as a convenient alias for the logged-in user.
- `template` - Specifies the name of the template.
- `status` - Indicates the status of the workspace. For a list of supported statuses, see [WorkspaceStatus documentation](https://pkg.go.dev/github.com/coder/coder/codersdk#WorkspaceStatus).

> ⚠️ To avoid data loss, refer to your template documentation for information on
> where to store files, install software, etc., so that they persist. Default
> templates are documented in [../examples/templates](https://github.com/coder/coder/tree/c6b1daabc5a7aa67bfbb6c89966d728919ba7f80/examples/templates).
>
> You can use `coder show <workspace-name>` to see which resources are
> persistent and which are ephemeral.

When a workspace is deleted, all of the workspace's resources are deleted.
## Starting and stopping workspaces

## Workspace scheduling
By default, you manually start and stop workspaces as you need. You
can also schedule a workspace to start and stop automatically.

By default, workspaces are manually turned on/off by the user. However, a schedule
can be defined on a per-workspace basis to automate the workspace start/stop.
To set a workspace's schedule, go to the workspace, then **Settings** > **Schedule**.

![Scheduling UI](./images/schedule.png)

### Autostart
Coder might also stop a workspace automatically if there is a [template
update](./templates/index.md#Start/stop) available.


### Autostart and autostop

The autostart feature automates the workspace build at a user-specified time
and day(s) of the week. In addition, users can select their preferred timezone.
Use autostart to start a workspace at a specified time and which days of the
week. Also, you can choose your preferred timezone.

![Autostart UI](./images/autostart.png)

### Autostop
Use autostop to stop a workspace after a number of hours. Autostop
won't stop a workspace if you're still using it. It waits for
another hour before checking again. Coder checks for active
connections in the IDE, SSH, Port Forwarding, and coder_app.

The autostop feature shuts off workspaces after given number of hours in the "on"
state. If Coder detects workspace connection activity, the autostop timer is bumped up
one hour. IDE, SSH, Port Forwarding, and coder_app activity trigger this bump.
![Autostop UI](./images/autostop.png)

![autostop UI](./images/autostop.png)

### Max lifetime

Max lifetime is a template-level setting that determines the number of hours a
workspace can run before it is automatically shutdown, regardless of any
active connections. This setting ensures workspaces do not run in perpetuity
when connections are left open inadvertently.
Max lifetime is a template setting that determines the number of hours
a workspace will run before Coder automatically stops it, regardless
of any active connections. Use this setting to ensure that workspaces
do not run in perpetuity when connections are left open inadvertently.


## Updating workspaces

Use the following command to update a workspace to the latest template version.
The workspace will be stopped and started:
After updating the default version of the template that a workspace
was created from, you can update the workspace.

![Updating a workspace](./images/workspace-update.png)

If the workspace is running, Coder stops it, updates it, then starts
the workspace again.

On the command line:

```console
coder update <workspace-name>
```


## Repairing workspaces

Use the following command to re-enter template input
variables in an existing workspace. This command is useful when a workspace fails
to build because its state is out of sync with the template.
Use the following command to re-enter template input variables in an
existing workspace. This command is useful when a workspace fails to
build because its state is out of sync with the template.

```console
coder update <your workspace name> --always-prompt
```

## Workspace resources

Resources are often destroyed and re-created when a workspace is restarted,
though the exact behavior depends on the template. For more
information, see [Resource Persistence](./templates/resource-persistence.md).

> ⚠️ To avoid data loss, refer to your template documentation for information on
> where to store files, install software, etc., so that they persist. Default
> templates are documented in [../examples/templates](https://github.com/coder/coder/tree/c6b1daabc5a7aa67bfbb6c89966d728919ba7f80/examples/templates).
>
> You can use `coder show <workspace-name>` to see which resources are
> persistent and which are ephemeral.

When a workspace is deleted, all of the workspace's resources are deleted.

## Logging

Coder stores macOS and Linux logs at the following locations:
Expand All @@ -97,19 +138,6 @@ Coder stores macOS and Linux logs at the following locations:

> Note: Logs are truncated once they reach 5MB in size.

## Workspace filtering

In the Coder UI, you can filter your workspaces using pre-defined filters or employing the Coder's filter query. Take a look at the following examples to understand how to use the Coder's filter query:

- To find the workspaces that you own, use the filter `owner:me`.
- To find workspaces that are currently running, use the filter `status:running`.

The following filters are supported:

- `owner` - Represents the `username` of the owner. You can also use `me` as a convenient alias for the logged-in user.
- `template` - Specifies the name of the template.
- `status` - Indicates the status of the workspace. For a list of supported statuses, please refer to the [WorkspaceStatus documentation](https://pkg.go.dev/github.com/coder/coder/codersdk#WorkspaceStatus).

---

## Up next
Expand Down