aspire icon indicating copy to clipboard operation
aspire copied to clipboard

#3332 add devcontainer

Open paule96 opened this issue 1 year ago • 9 comments

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

paule96 avatar Apr 09 '24 07:04 paule96

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.

paule96 avatar Apr 09 '24 07:04 paule96

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

danmoseley avatar Apr 09 '24 17:04 danmoseley

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

danmoseley avatar Apr 09 '24 17:04 danmoseley

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 avatar Apr 09 '24 19:04 kvenkatrajan

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 avatar Apr 10 '24 06:04 paule96

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.

paule96 avatar Apr 10 '24 07:04 paule96

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

kvenkatrajan avatar Apr 10 '24 16:04 kvenkatrajan

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

davidfowl avatar Jun 08 '24 13:06 davidfowl

ping @danmoseley and @timheuer :)

paule96 avatar Oct 02 '24 08:10 paule96

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 avatar Oct 30 '24 09:10 paule96

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.

davidfowl avatar Oct 30 '24 14:10 davidfowl

@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

paule96 avatar Oct 30 '24 14:10 paule96

@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.

mitchdenny avatar Oct 31 '24 02:10 mitchdenny