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

Skip to content

feat(agent): add devcontainer autostart support #17076

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 15 commits into from
Mar 27, 2025

Conversation

mafredri
Copy link
Member

@mafredri mafredri commented Mar 24, 2025

This change adds support for devcontainer autostart in workspaces. The preconditions for utilizing this feature are:

  1. The coder_devcontainer resource must be defined in Terraform
  2. By the time the startup scripts have completed,
    • The @devcontainers/cli tool must be installed
    • The given workspace folder must contain a devcontainer configuration

Example Terraform:

resource "coder_devcontainer" "coder" {
  agent_id         = coder_agent.main.id
  workspace_folder = "/home/coder/coder"
  config_path      = ".devcontainer/devcontainer.json" # (optional)
}

Closes #16423

Demo of an auto-started Dev Container (logs, timings):

image

Demo of devcontainer defined in Terraform, but not enabled on the agent:

image

Demo of errors being propagated via script:

image

mafredri added a commit that referenced this pull request Mar 25, 2025
In the presence of multiple devcontainers, it would be nice to
differentiate them by name. This change inherits the resource name from
terraform.

Refs #17076
@mafredri mafredri force-pushed the mafredri/feat-agent-devcontainer-autostart branch from cfea2b6 to 779c763 Compare March 25, 2025 13:14
@mafredri mafredri force-pushed the mafredri/feat-agent-devcontainer-autostart branch from 779c763 to e1048b1 Compare March 25, 2025 13:16
@mafredri mafredri force-pushed the mafredri/feat-agent-devcontainer-autostart branch from 41fddac to 1c5a1db Compare March 26, 2025 12:50
@mafredri mafredri force-pushed the mafredri/feat-agent-devcontainer-autostart branch from 1c5a1db to 2d93ee3 Compare March 26, 2025 12:52
@mafredri mafredri changed the title wip: feat(agent): add devcontainer autostart support feat(agent): add devcontainer autostart support Mar 26, 2025
@mafredri mafredri marked this pull request as ready for review March 26, 2025 13:01
@mafredri mafredri force-pushed the mafredri/feat-agent-devcontainer-autostart branch 2 times, most recently from c78665a to ffc2981 Compare March 26, 2025 13:41
@mafredri mafredri force-pushed the mafredri/feat-agent-devcontainer-autostart branch from ffc2981 to 9c1bf01 Compare March 26, 2025 13:43
Copy link
Member

@johnstcn johnstcn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing blocking from my side!

@@ -80,6 +80,21 @@ func New(opts Options) *Runner {

type ScriptCompletedFunc func(context.Context, *proto.WorkspaceAgentScriptCompletedRequest) (*proto.WorkspaceAgentScriptCompletedResponse, error)

type runnerScript struct {
runOnPostStart bool
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: this is fine for now, but I could see this being an option on WorkspaceAgentScript in future.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a good call-out 👍. I hope we figure out a better way to define dependencies or ordering for start scripts, though.

@mafredri mafredri force-pushed the mafredri/feat-agent-devcontainer-autostart branch from 3e0c2a0 to 55c5c46 Compare March 26, 2025 16:37
Copy link
Contributor

@DanielleMaywood DanielleMaywood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me :shipit:

@mafredri mafredri merged commit 7d4b3c8 into main Mar 27, 2025
30 checks passed
@mafredri mafredri deleted the mafredri/feat-agent-devcontainer-autostart branch March 27, 2025 10:31
@github-actions github-actions bot locked and limited conversation to collaborators Mar 27, 2025
@matifali
Copy link
Member

/cherry-pick release/2.21

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Agent: allow automatically starting a devcontainer defined in template
4 participants