-
Notifications
You must be signed in to change notification settings - Fork 239
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
feat: support forwardPorts
config and --skip-forward-ports
flag
#859
base: main
Are you sure you want to change the base?
Conversation
Thanks for the PR! A few considerations: The Dev Containers extension for VS Code forwards the listed ports to a free port on the local machine (which might be different from where Docker runs). GitHub Codespaces also has its own port forwarding. Additionally using Could this be added behind a CLI option, so the above scenarios don't break? |
I would think that all of those scenarios should be handled already downstream, as the behavior is identical to
For a reference implementation, that seems pretty confusing to me: the spec is the source of truth, yet you also need a flag? That behavior would be "ignore the spec field by default unless I tell you otherwise", which is pretty confusing, esp for a reference implementation -- why would the reference ignore the spec? |
The extension uses VS Code's port forwarding which is temporary while VS Code is connected and also works when the VS Code window runs on a different machine than the Docker daemon. (It is not use Docker's port forwarding.) I think another approach would be to replicate the temporary forwarding as part of an additional CLI command which would keep running until the port forwarding is no longer required and only then would be terminated. |
Then it should already be ignoring this, no? As it already ignores
While this makes sense to me, this doesn't match the existing behavior of
But I don't think I realized I had also looked at microsoft/vscode-remote-release#1809, where you did say (almost 5 years ago):
and someone else said a bit further up in the thread:
So I assumed they're equivalent in a Docker-based implementation. I'm not sure if that's changed since then or that's specific to the VS Code extension, but since the devcontainer CLI is similarly Docker-based, I would think that applies the same?
This makes it sound like the extension is different these days (also is the extension not open source? I tried finding its implementation to compare), but I wonder if the same makes sense to apply to the CLI. At least in my usage, my devcontainer is only running ( |
Just to clarify: The Dev Containers extension for VS Code and GitHub Codespaces both use the Dev Containers CLI to create the dev container. We moved away ( |
A few questions for clarity:
Gotcha. And then they have their own forwarding implementation, right? How do they handle the existing
Yea that was my other concern -- with a separate command for this, it would be done while already running, meaning we can't use the Docker implementation and have to reimplement forwarding (which is a bit of a rabbit hole). Does it make sense to move/share the downstream implementations here? |
We left There is some basic forwarding code in the extension that is used to establish an initial connection for VS Code. VS Code then tunnels everything through that initial connection. That code assumes Node.js is available in the container - which is true when using VS Code and the VS Code Server. (The extension is not OSS.) |
Is there any progress on this ? On our side we are trying to leverage devcontainers for a pretty standard Rails app. The required ports are exposed through the Everything works fine for VSCode / Codespace (aka:Microsoft lead products) users but developers using vim/emcas or similar can't properly spin up a working devcontainer from their terminal. It feels weird to me that the documentation recommends an approach that is currently unsupported by the reference implementation. Additionally, some tools and services are apparently leveraging the cli behind the scene, and they are thus subject to the same limitations (we tried). At the moment it feels like using VSCode as the "devcontainer manager" is required to have |
reference implementation
Yea, I generally agree with both these statements per my above comments summary
Let me summarize the comments to address this (and refresh my memory and make sure everyone's on the same page):
As I understand, this basically means that the A separate command would be incompatible with Docker publishing and so requires re-implementing forwarding (which is a bit of a rabbit hole and may require various dependencies on the host and container). Both a separate command or behind a flag would make the reference implementation not quite correspond to the spec by default though. next stepsAs such, I would go back to my earlier proposal of an env var (or flag) to disable That might seem like a breaking change from the GH Codespaces / VS Code extension perspective, but it is a feature for the reference since it did not previously exist in the reference. I.e. those implementations relied on an out-of-tree addition to the spec that would now conflict with the reference without an explicit disable / opt-out @chrmarti would that proposal work? At this point, I'm also willing to re-write it as an opt-in flag just to get the behavior in the CLI, but that would still be odd as a reference implementation and so would not be my preference. |
- agilgur5 modification: rebased with `main`
- it doesn't cover all networking at this time Signed-off-by: Anton Gilgur <[email protected]>
Signed-off-by: Anton Gilgur <[email protected]>
Signed-off-by: Anton Gilgur <[email protected]>
Signed-off-by: Anton Gilgur <[email protected]>
Signed-off-by: Anton Gilgur <[email protected]>
a8b9491
to
d0df3bb
Compare
- per review comments, GH Codespaces and VS Code extension use their own implementation for `forwardPorts` and so would conflict with Docker publishing - so `--skip-forward-ports` allows for publishing of `forwardPorts` to be skipped by the CLI NOTE: passing `skipForwardPorts` around required drilling down through a lot of function arguments -- those could potentially be refactored, but that is out-of-scope for now
I added a The function arg drilling is not the most ideal, but changing that would require a lot of refactoring that I don't think I'm best suited to handle at this time. At this time, I followed the existing practices in the codebase for flags, naming, arg passing, etc without modifications. |
forwardPorts
configforwardPorts
config and --skip-forward-ports
flag
Summary
Fixes #186 by adding
-p
args for allforwardPorts
, not justappPort
Allows disabling this via the CLI flag
--skip-forward-ports
Details
normalizePorts
function used on bothappPort
andforwardPorts
concat
andflatMap
those two together into argsCredits to @MunsMan for the original variant listed in this comment #186 (comment): this commit: MunsMan@6909283
Newer bits
EDIT: After review comments:
--skip-forward-ports
, to allow disabling this behavior for alternate implementations that use the CLI under-the-hoodNotes for Reviewers
There didn't seem to be any existing tests for
appPort
that I could extend forforwardPorts
, afaict. Let me know if there's a proper place to add tests for this