-
Notifications
You must be signed in to change notification settings - Fork 135
Add experimental Dev Container support to Positron #10884
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
Open
jmcphers
wants to merge
78
commits into
main
Choose a base branch
from
feature/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.
Open
Changes from all commits
Commits
Show all changes
78 commits
Select commit
Hold shift + click to select a range
7c6a066
initial support
jmcphers 0b9e35b
mount workspace at /workspaces
jmcphers 53e1d38
don't rely on netcat
jmcphers 0e6d91a
build and rebuild in a terminal
jmcphers ed19e4d
beginning of devcontainer view registration
jmcphers ffb0230
improve server installer, work on rebuild
jmcphers 999344a
Merge remote-tracking branch 'origin/main' into feature/dev-containers
jmcphers 0741554
updates for container treeview
jmcphers 8196673
offer to reopen in container; remove dev volumes for now
jmcphers 02b96e0
impl show container log
jmcphers 2575f5a
start, stop, attach
jmcphers 9049270
connection test
jmcphers c03e9f3
clean all unimplemented commands
jmcphers 0d3f4ea
better compat with barebones images (still need glibc tho)
jmcphers 67bb39c
trap errors when building container
jmcphers 2fe4237
persistence of workspace path for rebuild
jmcphers 18f78c0
handle pending rebuilds
jmcphers b647aba
remove error trap after build succeeds
jmcphers caf4c77
encode devcontainer authority more thoroughly
jmcphers 194043c
mapping local/remote workspaces for trust
jmcphers e9b7f44
encoding url in authority is not going to work
jmcphers bce0a70
use positron dialogs for modal prompts
jmcphers 1593dc9
let docker assign container names
jmcphers dfebc3e
use vscode api to read files from inside container
jmcphers 3c6eb7c
fix a couple other problematic usages of nodejs fs api
jmcphers 975b919
show formatted remote status indicator
jmcphers b06d636
continue to improve workspace/container mapping
jmcphers bd7ec8d
remove unused details view; update resource formatter
jmcphers 8d5acd3
don't try to use docker with a remote
jmcphers 753d32b
Merge remote-tracking branch 'origin/main' into feature/dev-containers
jmcphers d8cf279
improve terminal experience for rebuild
jmcphers bff5263
show rebuild commands (WIP)
jmcphers 89a383e
action bar options for rebuild/reopen commands
jmcphers 306a13d
icons for rebuild/reopen commands
jmcphers 109b8a7
more reopen fixes; add log viewer for install errors
jmcphers 4c5c171
simplify dev container
jmcphers 3accef7
don't show attach command when already attached
jmcphers 4715be0
clean up logging
jmcphers 3786067
update lockfile
positron-bot[bot] 0d69508
remove positron markers from positron files
jmcphers 50a2c48
mark strings for loc
positron-bot[bot] 5f1e396
Merge remote-tracking branch 'origin/main' into feature/dev-containers
jmcphers 9a794c4
update branding
jmcphers 2e3c637
refresh view before declaring removal/stop complete
jmcphers 28c6a5b
use more integrated terminal building commands
jmcphers b816930
Merge remote-tracking branch 'origin/main' into feature/dev-containers
jmcphers c42400f
eliminate node-pty
jmcphers c94af21
add webpack config for release builds
jmcphers 3c034a7
progress towards supporting windows
jmcphers 588782a
support .devcontainer.json at project root
jmcphers ed36b2f
better error when installation fails
jmcphers cfe8636
improved server download error propagation
jmcphers cbd790a
add a default download url
jmcphers 0e56762
show progress while installing server
jmcphers 75775e5
add opt-in feature.
jmcphers de2337f
add some readmes & note license for src/spec
jmcphers e24777f
Merge remote-tracking branch 'origin/main' into feature/dev-containers
jmcphers db41d14
activate dynamically when enabled
jmcphers 905c9e2
update link; remove unused buildProgress.ts
jmcphers 4a51585
store pending rebuild in workspace state
jmcphers 21c54b7
basic support for features
jmcphers e71259b
Merge remote-tracking branch 'origin/main' into feature/dev-containers
jmcphers 5558a17
more robust execution of lifestyle hooks
jmcphers 04e142d
better filter for devcontainer.json
jmcphers 26c45c2
smoother startup if server is already installed
jmcphers 457fda4
Merge remote-tracking branch 'origin/main' into feature/dev-containers
jmcphers beca44a
make setting less experimentaly
jmcphers 42b6e8e
remove an unused setting and a lot of unused strings
jmcphers 27949bd
remove remaining unused settings
jmcphers fb18c48
clean up readme
jmcphers d24cbc8
disarm CLI in bundled code
jmcphers c16ad84
Merge remote-tracking branch 'origin/main' into feature/dev-containers
jmcphers 29e47dc
Merge remote-tracking branch 'origin/main' into feature/dev-containers
jmcphers f96f676
support mounts defined with JSON
jmcphers cb2ae26
disarm all commands when feature is off
jmcphers f17870b
use error marker instead of exit code
jmcphers 8f2a8f2
better error reporting when failing to detect docker
jmcphers 10b1120
Merge remote-tracking branch 'origin/main' into feature/dev-containers
jmcphers 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
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
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,109 @@ | ||
| # Dev Containers Extension for Positron | ||
|
|
||
| ## Overview | ||
|
|
||
| The Dev Containers extension enables you to open any folder or repository inside a Docker container and take advantage of Positron's full feature set within that containerized environment. This allows you to define your project's dependencies declaratively, install them in a lightweight container, and run the entire project inside the container with a consistent, reproducible development environment. | ||
|
|
||
| For compatibility with VS Code, this extension uses most of the same command IDs and setting names from VS Code's version of the extension. The extension itself is novel code, with the exception of the contents of the `spec` folder, which is adapted from the MIT-licensed [dev container reference implementation](https://github.com/devcontainers/cli). | ||
|
|
||
| ## Requirements | ||
|
|
||
| - Docker or Podman installed and running | ||
| - A workspace with a `.devcontainer.json` or `.devcontainer/devcontainer.json` file | ||
|
|
||
| ## Configuration | ||
|
|
||
| Enable the extension in your settings: | ||
|
|
||
| ```json | ||
| { | ||
| "dev.containers.enable": true | ||
| } | ||
| ``` | ||
|
|
||
| ## Usage | ||
|
|
||
| ### Opening a Folder in a Container | ||
|
|
||
| 1. Open a folder that contains a `.devcontainer.json` file | ||
| 2. Click the notification prompt, or | ||
| 3. Use the command palette: **Dev Containers: Reopen in Container** | ||
|
|
||
| ### Attaching to a Running Container | ||
|
|
||
| 1. Open the Remote Explorer view | ||
| 2. Expand the "Dev Containers" section | ||
| 3. Right-click a running container and select "Attach in Current Window" or "Attach in New Window" | ||
|
|
||
| ### Rebuilding a Container | ||
|
|
||
| When you've made changes to your `devcontainer.json` or `Dockerfile`: | ||
|
|
||
| - **Dev Containers: Rebuild Container** - Rebuild using cache | ||
| - **Dev Containers: Rebuild Without Cache** - Full rebuild from scratch | ||
| - **Dev Containers: Rebuild and Reopen in Container** - Rebuild and automatically reopen | ||
|
|
||
| ### Key Components | ||
|
|
||
| #### Extension Entry Point (`extension.ts`) | ||
| - Activates the extension when enabled | ||
| - Registers commands, views, and authority resolvers | ||
| - Initializes core managers and services | ||
| - Handles pending rebuild requests | ||
|
|
||
| #### Remote Authority Resolver (`remote/authorityResolver.ts`) | ||
| - Resolves `dev-container://` and `attached-container://` URIs | ||
| - Manages connections to containers | ||
| - Handles workspace folder resolution | ||
| - Implements VS Code's remote development protocol | ||
|
|
||
| #### Connection Manager (`remote/connectionManager.ts`) | ||
| - Manages active connections to containers | ||
| - Tracks connection state and lifecycle | ||
| - Handles connection failures and recovery | ||
| - Coordinates with port forwarding | ||
|
|
||
| #### Dev Container Manager (`container/devContainerManager.ts`) | ||
| - Creates and starts containers from `devcontainer.json` | ||
| - Handles container building and rebuilding | ||
| - Manages container lifecycle (start, stop, remove) | ||
| - Retrieves container information and logs | ||
|
|
||
| #### Server Installer (`server/serverInstaller.ts`) | ||
| - Downloads the Positron server for the container platform | ||
| - Installs and configures the server inside containers | ||
| - Generates connection tokens for secure communication | ||
| - Handles server updates and versioning | ||
|
|
||
| #### Workspace Mapping Storage (`common/workspaceMappingStorage.ts`) | ||
| - Persists mappings between container IDs and workspace paths | ||
| - Enables proper workspace resolution across window reloads | ||
| - Provides cleanup for stale mappings | ||
|
|
||
| #### Dev Container Reference CLI (spec/) | ||
| - Copy of the Microsoft Dev Container Reference CLI | ||
| - Used to manage containers and form Docker commands | ||
|
|
||
| ### Remote Development Flow | ||
|
|
||
| The workflow typically looks like this; | ||
|
|
||
| 1. User invokes "Reopen in Container" | ||
| 2. Extension reads `devcontainer.json` and creates/starts container | ||
| 3. Positron server is downloaded and installed in container | ||
| 4. VS Code resolves the remote authority and establishes connection | ||
| 5. Extension maps local paths to container paths | ||
| 6. Necessary ports are forwarded from container to host | ||
| 7. User can now work with code inside the container | ||
|
|
||
| ## Known Limitations | ||
|
|
||
| - Requires glibc-based Linux since Positron Server builds of Linux require glibc (e.g. Alpine will not work) | ||
| - Doesn't support "Create from template"; you need to create Dockerfiles / devcontainer JSON files by hand | ||
| - Doesn't support development volumes (popular feature from VS Code's implementation, used for e.g. faster I/O) | ||
| - Container management views and features are not available if you are inside a container/remote | ||
| - Currently experimental and requires explicit enablement | ||
| - Requires Docker or Podman to be installed and running | ||
| - GPU support is platform-dependent | ||
| - Some features have limited support in containers | ||
|
|
||
17 changes: 17 additions & 0 deletions
17
extensions/positron-dev-containers/extension.webpack.config.js
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,17 @@ | ||
| /*--------------------------------------------------------------------------------------------- | ||
| * Copyright (C) 2025 Posit Software, PBC. All rights reserved. | ||
| * Licensed under the Elastic License 2.0. See LICENSE.txt for license information. | ||
| *--------------------------------------------------------------------------------------------*/ | ||
|
|
||
| //@ts-check | ||
|
|
||
| 'use strict'; | ||
|
|
||
| const withDefaults = require('../shared.webpack.config.mjs').default; | ||
|
|
||
| module.exports.default = withDefaults({ | ||
| context: __dirname, | ||
| entry: { | ||
| extension: './src/extension.ts', | ||
| } | ||
| }); |
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.
I'm gonna use OrbStack, wish me luck
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.
it worked! (it's basically the same as docker haha)