Skip to content
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

#3332 add devcontainer #3520

Closed
wants to merge 13 commits into from
Closed

Conversation

paule96
Copy link
Contributor

@paule96 paule96 commented Apr 9, 2024

This PR adds the first try to enable DevContainers for the Aspire project.
Currently, the functionality in the codespaces of GitHub is very limited. It's enough to write tests and debug them. But to run the playground examples it's not enough because something with the dashboard is wrong there.
For DevContainers on a local installation, it works quite well, if you can provide enough memory.

Currently what takes quite long when you first start the DevContainer are two things:

  • creating all the base layers that will add docker / powershell / dapr
  • the restore of all the projects in the repository after the devcontainer is up and running
Microsoft Reviewers: Open in CodeFlow

@dotnet-issue-labeler dotnet-issue-labeler bot added the area-integrations Issues pertaining to Aspire Integrations packages label Apr 9, 2024
@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Apr 9, 2024
@paule96
Copy link
Contributor Author

paule96 commented Apr 9, 2024

There is also the issue, that for the playground things to work, you need to set in the launch.json the ASPNETCORE_URLS. I don't know if this is currently a bug in all playground samples or if this should be working.

@danmoseley
Copy link
Member

@eerhardt you did the codespaces for dotnet/runtime. Does this look reasonable?

@danmoseley
Copy link
Member

As far as prebuild, I think (?) after this goes in I just go switch it on?

Just start the Codespaces in your fork. The initialisation of the code space takes around 5 mins. After that you can open the solution.
This will take on the free version of Codesapce around 10 mins.

> Warning: With the free version of Codespaces the development experience is not nice. We recommend using at least a Codespace with 16GB of RAM or use your local VSCode / DevContainers instance.
Copy link
Member

Choose a reason for hiding this comment

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

I think there is a setting somewhere that I can use to increase this (billed to the .NET foundation..)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't know how it works for members of the .NET foundation or Microsoft employees. But for people like me you get billed for it or you don't use it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

image
This is how you can configure. because It don't want to invest money I didn't try what will happen if you click create :D

Copy link
Member

Choose a reason for hiding this comment

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

If I remember right, we can simply add as dotnet org members folks like you who want to use this. Then the foundation pays.

.gitignore Outdated Show resolved Hide resolved
@kvenkatrajan
Copy link
Member

kvenkatrajan commented Apr 9, 2024

Overall this looks good. To allow for debugging of playground apps additional considerations would need to be applied :

  • version of C# dev kit > 1.5.10
    Its currently in pre-release
    image
    This version has some changes to debug/run in C# dev kit that would help the dev inner loop for aspire apps and we are yet to push the changes to release
  • currently while running the TestShop app in codespaces : System.AggregateException: One or more errors occurred. (Unable to configure HTTPS endpoint. No server certificate was specified, and the default developer certificate could not be found or is out of date. Since current launch behavior is defaulted to https. Here is some documentation on how to configure : https://hub.docker.com/_/microsoft-devcontainers-dotnet
  • To default to http, environment variable : ALLOW_UNSECURED_TRANSPORT (not recommended) would need to be set.

Rest looks good to me.

CC: @baronfel for additional review.

.devcontainer/devcontainer.json Show resolved Hide resolved
"customizations": {
"vscode": {
"extensions": [
"ms-dotnettools.vscodeintellicode-csharp"
Copy link
Member

Choose a reason for hiding this comment

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

why this extension instead of just devkit?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because it installs the devkit and you get better autocomplete.

Copy link
Member

Choose a reason for hiding this comment

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

.devcontainer/devcontainer.json Outdated Show resolved Hide resolved
"features": {
"ghcr.io/devcontainers/features/docker-in-docker:2": {},
"ghcr.io/devcontainers/features/powershell:1": {},
"ghcr.io/dapr/cli/dapr-cli": {
Copy link
Member

Choose a reason for hiding this comment

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

Why do we need the dapr-cli? It should only be needed if someone is actually working on the dapr extension/playground app, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes I agree. This is for me a big question mark too. On the other hand, should someone who wants to contribute, think about that stuff, or should it be just there?

I mean that's the nice thing about devcontainers that you can just start developing, because someone else took care of installing all the tools you need.

So I don't know what todo here.
If we install dapr we should maybe install other stuff too. (azure emulators, other CLIs, etc....)

Copy link
Member

Choose a reason for hiding this comment

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

I suggest just the basics in this PR and we can add more as requested/needed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@danmoseley what are the basics for you? Dapr cli and Azure cli? Just Azure cli? None of both? More?

Copy link
Member

Choose a reason for hiding this comment

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

Ha, good point, this repo explicitly isn't cloud specific. @eerhardt any opinion?

Copy link
Member

Choose a reason for hiding this comment

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

I've never used the dapr cli and I work in the repo every day.

My opinion would be to not include the dapr cli or the Azure cli initially.

If someone wants these, they can customize their own container right? https://docs.github.com/codespaces/setting-your-user-preferences/personalizing-github-codespaces-for-your-account

@paule96
Copy link
Contributor Author

paule96 commented Apr 10, 2024

Overall this looks good. To allow for debugging of playground apps additional considerations would need to be applied :

  • version of C# dev kit > 1.5.10
    Its currently in pre-release
    image
    This version has some changes to debug/run in C# dev kit that would help the dev inner loop for aspire apps and we are yet to push the changes to release
  • currently while running the TestShop app in codespaces : System.AggregateException: One or more errors occurred. (Unable to configure HTTPS endpoint. No server certificate was specified, and the default developer certificate could not be found or is out of date. Since current launch behavior is defaulted to https. Here is some documentation on how to configure : https://hub.docker.com/_/microsoft-devcontainers-dotnet
  • To default to http, environment variable : ALLOW_UNSECURED_TRANSPORT (not recommended) would need to be set.

Rest looks good to me.

CC: @baronfel for additional review.

@kvenkatrajan for your issue with the HTTPS endpoint then you could run dotnet dev-certs https. That should generate the missing certificate.
In your browser you will still get a certificate warning, because your local machine is not knowing / trusting the certificate root. But the CLI can export the generated cert. (dotnet dev-certs https --export-path ~/mydevcert.pfx --password "securePassword") This can be then applied as a trusted root on your OS. (depends on your local OS how)

@paule96
Copy link
Contributor Author

paule96 commented Apr 10, 2024

Overall this looks good. To allow for debugging of playground apps additional considerations would need to be applied :

  • version of C# dev kit > 1.5.10
    Its currently in pre-release
    image
    This version has some changes to debug/run in C# dev kit that would help the dev inner loop for aspire apps and we are yet to push the changes to release

The problem there is, that I currently don't see a way to specify the use of prerelease version of extensions in devcontainers. If you take a look into the spec of devcontianers, the extensions property is a list of extension ids without version numbers.

@kvenkatrajan
Copy link
Member

The problem there is, that I currently don't see a way to specify the use of prerelease version of extensions in devcontainers. If you take a look into the spec of devcontianers, the extensions property is a list of extension ids without version numbers.

I think this should be fine but just giving a headsup that debugging might not work for playground apps in codespaces till this version is live. Maybe worth specifying that in the machine-requirements.md

{
"name": "C# (.NET)",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/devcontainers/dotnet:1-8.0-bookworm",
Copy link
Member

Choose a reason for hiding this comment

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

We should just use the 8.0 SDK image here.

Copy link
Member

Choose a reason for hiding this comment

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

The main differences currently between the devcontainers image and the official dotnet SDK image is that

  • NuGet packages will get xmldocs in the devcontainers image (which we want), and
  • The devcontainers image includes Powershell Core

I think those are enough of a value-add (especially the XMLDocs) to justify using this base image.

Copy link
Member

Choose a reason for hiding this comment

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

Educate me -- why doesn't the SDK image get the xmldocs?

RE: Powershell -- easy add-on as a feature (which is in this as well)

No objections really either, just felt like the actual SDK image felt like a better base -- it's what I use exclusively and just add features.

Copy link
Member

Choose a reason for hiding this comment

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

Educate me -- why doesn't the SDK image get the xmldocs?

dotnet/dotnet-docker#2790

TLDR is "performance".

Copy link
Member

Choose a reason for hiding this comment

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

Funnily enough, I was just going to the source and noticed that powershell core is already on the SDK images - so that removes one of the benefits of the devcontainers image. Kinda feels like we're all over the place with these images, thematically :)

Copy link
Member

Choose a reason for hiding this comment

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

Yep, noticed that too -- this devcontainer image looks to take a patch to the powershell also though, which i would expect the powershell feature latest to have also. Anyhow, thanks for the edu on the xmldocs -- seems odd our sdk image doesn't really match the sdk, but at least now I know!

Copy link
Member

Choose a reason for hiding this comment

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

seems odd our sdk image doesn't really match the sdk

It was super surprising to me too when I learned this too. I understand the constraints and get it adds a lot of value to the "non-human-interactive" use cases. So it seems when a human is involved, its best to start with the dev container image.

"customizations": {
"vscode": {
"extensions": [
"ms-dotnettools.vscodeintellicode-csharp",
Copy link
Member

@timheuer timheuer Apr 10, 2024

Choose a reason for hiding this comment

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

recommend changing this to ms-dotnettools.csdevkit

Copy link
Contributor Author

Choose a reason for hiding this comment

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

are there reasons to it? had the same recommendation from @baronfel.
Isn't the intellicode extension just the more advanced one?

Copy link
Contributor

Choose a reason for hiding this comment

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

https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.vscodeintellicode-csharp
image
seemed we should install ms-dotnettools.csdevkit to keep it working

Copy link
Contributor Author

@paule96 paule96 May 10, 2024

Choose a reason for hiding this comment

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

If you open the extension page in visual studio code you see it will install the C# extension by itself:

Image showing the dependencies of the IntelliCode extension including C# and C# DevKit extension

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@WeihanLi It's the same like for the C# extension. That extension will install .NET Install Tool Extension.

@eerhardt eerhardt added area-engineering-systems and removed area-integrations Issues pertaining to Aspire Integrations packages labels Apr 12, 2024
Comment on lines +28 to +30
// "5001": {
// "protocol": "https"
// }
Copy link
Member

Choose a reason for hiding this comment

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

[nit] please change tabs to spaces

Copy link
Contributor Author

@paule96 paule96 Apr 22, 2024

Choose a reason for hiding this comment

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

@RussKie I had the same discussion earlier with @danmoseley here. And we agreed on doing it the same as the runtime team is doing. Is there any new information that was discussed internally?

Copy link
Member

Choose a reason for hiding this comment

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

The rest of the file uses spaces, and this part uses tabs. It just looks inconsistent. That's all.

docs/machine-requirements.md Outdated Show resolved Hide resolved
docs/machine-requirements.md Outdated Show resolved Hide resolved
docs/machine-requirements.md Outdated Show resolved Hide resolved
@davidfowl
Copy link
Member

@danmoseley @timheuer Is there anything missing from this? It would be great to have this merged.

@paule96
Copy link
Contributor Author

paule96 commented Oct 2, 2024

ping @danmoseley and @timheuer :)

@paule96
Copy link
Contributor Author

paule96 commented Oct 30, 2024

Okay I will close this PR because I saw on twitter that someone else added dev container support. :/ A bit sad about the not existing communication at the end...

#6491

@paule96 paule96 closed this Oct 30, 2024
@davidfowl
Copy link
Member

mea culpa @paule96, we should have integrated this PR! There were other changes that included making this aspire work in codespaces that were done as well but that's not an excuse.

@@ -26,3 +30,24 @@ When you install, ensure that both:
* [Windows](https://podman.io/docs/installation#windows)
* [macOS](https://podman.io/docs/installation#macos)
* [Linux](https://podman.io/docs/installation#installing-on-linux)

## (Windows / Linux / Mac) DevContainer in VS Code
Copy link
Member

Choose a reason for hiding this comment

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

@paule96 This would still be very useful to merge

cc @mitchdenny

@paule96
Copy link
Contributor Author

paule96 commented Oct 30, 2024

@davidfowl yes but probably a new pullrequest would be better, because merging this now is I guess a bit wrong. Let me see if I find the time today to reopen a new PR with just the changes that are left. My quick analysis is:

  • migrate the docs
  • add the dapr init post command
  • maybe change the base image to the Ubuntu version (has only benefits on windows as far as I know, in combination with the SshD service)
  • add the intellicode extension
  • add the editorconfig extension

@mitchdenny
Copy link
Member

@paule96 sorry I didn't see your PR here when I merged mine. I did the work on improving the codespaces support so that the dashboard would show the port forwarded URLs. If you do put up another PR with these changes feel free to tag me in it so we can do a quick review.

@paule96 paule96 mentioned this pull request Oct 31, 2024
18 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-engineering-systems community-contribution Indicates that the PR has been added by a community member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants