-
Notifications
You must be signed in to change notification settings - Fork 949
docs: update dev container docs for GA #18907
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
Draft
EdwardAngert
wants to merge
16
commits into
main
Choose a base branch
from
18582-dev-containers
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
fb92c9f
update devcontainers for ga
EdwardAngert 5a4ca2f
edit devcontainers doc
EdwardAngert d978111
add advanced dev containers
EdwardAngert 736202d
add dev-container-envbuilder comparison
EdwardAngert 09effa1
edit add-devcontainer
EdwardAngert 0b4ac18
edit dev-container-known-issues
EdwardAngert bff7a37
edit envbuilder docs
EdwardAngert dde4010
update workspace screenshot
EdwardAngert 02b110f
update workspace screenshot
EdwardAngert 0f47c56
update manifest
EdwardAngert 0e8383e
update user-guide
EdwardAngert 4116768
troubleshooting-dev-containers
EdwardAngert 6a6a49e
init working-with-dev-containers edit
EdwardAngert 7a4719d
dev container casing
EdwardAngert f88ecb8
link fix
EdwardAngert 5085d78
s/coder ssh/ssh
EdwardAngert File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,7 +49,7 @@ Coder's backend is built using a collection of robust, modern Go libraries and i | |
|
||
The Coder backend is organized into multiple packages and directories, each with a specific purpose. Here's a high-level overview of the most important ones: | ||
|
||
* [agent](https://github.com/coder/coder/tree/main/agent): core logic of a workspace agent, supports DevContainers, remote SSH, startup/shutdown script execution. Protobuf definitions for DRPC communication with `coderd` are kept in [proto](https://github.com/coder/coder/tree/main/agent/proto). | ||
* [agent](https://github.com/coder/coder/tree/main/agent): core logic of a workspace agent, supports dev containers, remote SSH, startup/shutdown script execution. Protobuf definitions for DRPC communication with `coderd` are kept in [proto](https://github.com/coder/coder/tree/main/agent/proto). | ||
* [cli](https://github.com/coder/coder/tree/main/cli): CLI interface for `coder` command built on [coder/serpent](https://github.com/coder/serpent). Input controls are defined in [cliui](https://github.com/coder/coder/tree/docs-backend-contrib-guide/cli/cliui), and [testdata](https://github.com/coder/coder/tree/docs-backend-contrib-guide/cli/testdata) contains golden files for common CLI calls | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [linkspector] reported by reviewdog 🐶 |
||
* [cmd](https://github.com/coder/coder/tree/main/cmd): entry points for CLI and services, including `coderd` | ||
* [coderd](https://github.com/coder/coder/tree/main/coderd): the main API server implementation with [chi](https://github.com/go-chi/chi) endpoints | ||
|
@@ -72,7 +72,7 @@ The Coder backend is organized into multiple packages and directories, each with | |
* [dbpurge](https://github.com/coder/coder/tree/main/coderd/database/dbpurge): simple wrapper for periodic database cleanup operations | ||
* [migrations](https://github.com/coder/coder/tree/main/coderd/database/migrations): an ordered list of up/down database migrations, use `./create_migration.sh my_migration_name` to modify the database schema | ||
* [pubsub](https://github.com/coder/coder/tree/main/coderd/database/pubsub): PubSub implementation using PostgreSQL and in-memory drop-in replacement | ||
* [queries](https://github.com/coder/coder/tree/main/coderd/database/queries): contains SQL files with queries, `sqlc` compiles them to [Go functions](https://github.com/coder/coder/blob/docs-backend-contrib-guide/coderd/database/queries.sql.go) | ||
* [queries](https://github.com/coder/coder/tree/main/coderd/database/queries): contains SQL files with queries, `sqlc` compiles them to [Go functions](https://github.com/coder/coder/tree/main/coderd/database/queries.sql.go) | ||
* [sqlc.yaml](https://github.com/coder/coder/tree/main/coderd/database/sqlc.yaml): defines mappings between SQL types and custom Go structures | ||
* [codersdk](https://github.com/coder/coder/tree/main/codersdk): user-facing API entities used by CLI and site to communicate with `coderd` endpoints | ||
* [dogfood](https://github.com/coder/coder/tree/main/dogfood): Terraform definition of the dogfood cluster deployment | ||
|
100 changes: 100 additions & 0 deletions
100
docs/admin/templates/extending-templates/advanced-dev-containers.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
# Advanced Dev Container Configuration | ||
|
||
This page extends the [dev containers documentation](./devcontainers.md) with patterns for multiple dev containers, | ||
user-controlled startup, repository selection, and infrastructure tuning. | ||
|
||
## Run Multiple Dev Containers | ||
|
||
Run independent dev containers in the same workspace so each component appears as its own agent. | ||
|
||
In this example, there are two: repositories called `frontend` and `backend`: | ||
|
||
```terraform | ||
# Clone each repo | ||
module "git-clone-frontend" { | ||
count = data.coder_workspace.me.start_count | ||
source = "dev.registry.coder.com/modules/git-clone/coder" | ||
|
||
agent_id = coder_agent.main.id | ||
url = "https://github.com/your-org/frontend.git" | ||
} | ||
|
||
module "git-clone-backend" { | ||
count = data.coder_workspace.me.start_count | ||
source = "dev.registry.coder.com/modules/git-clone/coder" | ||
|
||
agent_id = coder_agent.main.id | ||
url = "https://github.com/your-org/backend.git" | ||
} | ||
|
||
# Dev container resources | ||
resource "coder_devcontainer" "frontend" { | ||
count = data.coder_workspace.me.start_count | ||
agent_id = coder_agent.main.id | ||
workspace_folder = module.git-clone-frontend[0].repo_dir | ||
} | ||
|
||
resource "coder_devcontainer" "backend" { | ||
count = data.coder_workspace.me.start_count | ||
agent_id = coder_agent.main.id | ||
workspace_folder = module.git-clone-backend[0].repo_dir | ||
} | ||
``` | ||
|
||
Each dev container appears as a separate agent, so developers can connect to each separately. | ||
|
||
## Conditional Startup | ||
|
||
Use `coder_parameter` booleans to let workspace creators choose which dev containers start automatically, | ||
reducing resource usage for unneeded components: | ||
|
||
```terraform | ||
data "coder_parameter" "autostart_frontend" { | ||
type = "bool" | ||
name = "Autostart frontend container" | ||
default = true | ||
mutable = true | ||
order = 3 | ||
} | ||
|
||
resource "coder_devcontainer" "frontend" { | ||
count = data.coder_parameter.autostart_frontend.value ? data.coder_workspace.me.start_count : 0 | ||
agent_id = coder_agent.main.id | ||
workspace_folder = module.git-clone-frontend[0].repo_dir | ||
} | ||
``` | ||
|
||
## Repository-selection Patterns | ||
|
||
Prompt users to pick a repository or team at workspace creation time and clone the selected repo(s) automatically into the workspace: | ||
|
||
1. Add a parameter to the template: | ||
|
||
```terraform | ||
data "coder_parameter" "project" { | ||
name = "project" | ||
display_name = "Choose a project" | ||
type = "string" | ||
default = "https://github.com/coder/coder.git" | ||
|
||
option { | ||
name = "coder/coder" | ||
value = "https://github.com/coder/coder.git" | ||
} | ||
option { | ||
name = "terraform-provider-coder" | ||
value = "https://github.com/coder/terraform-provider-coder.git" | ||
} | ||
} | ||
``` | ||
|
||
1. Change the `git-clone` module to accept the `value` as the `url`: | ||
|
||
```terraform | ||
module "git-clone" { | ||
count = data.coder_workspace.me.start_count | ||
source = "dev.registry.coder.com/modules/git-clone/coder" | ||
agent_id = coder_agent.main.id | ||
url = data.coder_parameter.project.value | ||
} | ||
``` |
23 changes: 23 additions & 0 deletions
23
docs/admin/templates/extending-templates/dev-containers-envbuilder.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Choose an Approach To Dev Containers | ||
|
||
Coder supports two independent ways to run Dev Containers inside a workspace. | ||
|
||
Both implement the [Dev Container specification](https://containers.dev/), but they differ in how the container is built, | ||
who controls it, and which runtime requirements exist. | ||
|
||
Use this page to decide which path fits your project or platform needs. | ||
|
||
## Options at a Glance | ||
|
||
| Capability / Trait | Dev Containers integration | Envbuilder | | ||
|------------------------------------------|--------------------------------------------|-------------------------------------------| | ||
| How it's built | `@devcontainers/cli` and Docker | Envbuilder transforms the workspace image | | ||
| Docker-in-Docker? | Yes (parent workspace and child container) | No (modifies the parent container) | | ||
| Multiple dev containers per workspace | Yes | No | | ||
| Rebuild when `devcontainer.json` changes | Yes - user-initiated | Requires full workspace restart | | ||
|
||
## Related Reading | ||
|
||
- [Dev Containers integration](./devcontainers.md) | ||
- [Dev Containers specification](https://containers.dev/) | ||
- [Envbuilder on GitHub](https://github.com/coder/envbuilder) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚫 [linkspector] reported by reviewdog 🐶
Cannot reach https://github.com/coder/coder/tree/docs-backend-contrib-guide/cli/cliui Status: 404