- Notifications
You must be signed in to change notification settings - Fork948
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
fb92c9f
5a4ca2f
d978111
736202d
09effa1
0b4ac18
bff7a37
dde4010
02b110f
0f47c56
0e8383e
4116768
6a6a49e
7a4719d
f88ecb8
5085d78
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
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, supportsdev 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 byreviewdog 🐶 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 byreviewdog 🐶 | ||
* [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/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 | ||
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 | ||
} | ||
``` |
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) |
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.