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

Simplified local docker setup for MVP site #237

Closed
wants to merge 2 commits into from
Closed

Conversation

robearlam
Copy link
Member

This commit simplifies the local docker setup for the MVP site.

As this was migrated from old site, which was hosted in AKS, we had some functionality that was no longer required. Also, as we had upgraded to .NET 6 some functionality that was custom built is now provided OOTB by the framework.

Changes include

  • Removing custom watch PowerShell script and changing to use .NET 6 Hot Reload
  • Simplifying MVP Host Dockerfile, it is no longer needed to differ build process based on build config as the built containers aren't used in AKS anymore.
  • Introduced different launchmodes for Docker vs VS

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I have read the Contributing guide.
  • My code/comments/docs fully adhere to the Code of Conduct.
  • My change is a code change.
  • My change is a documentation change and there are NO other updates required.

Closes #16

@sebastiantecsi
Copy link
Contributor

Tested on my local, but does not work well all the time.

This shows up sometimes:

Unable to apply hot reload because of a rude edit.
Do you want to restart your app - Yes (y) / No (n) / Always (a) / Never (v)?

image

then using the answer from here https://stackoverflow.com/a/70895415/856045 I've added an environment variable named DOTNET_WATCH_RESTART_ON_RUDE_EDIT to true in docker-compose.override.yml for mvp-rendering and then this happened, sometimes:

image

So I think this ticket has to be worked on a bit more.

cc: @robearlam @lovesitecore

@robearlam
Copy link
Member Author

Interesting @sebastiantecsi, do you have steps to reproduce both of the different errors you've seen above.

According to Google the Env Var should fix the rude error issue?

@sc-ivanlieckens
Copy link
Collaborator

In my case VS could no longer build due to the DLL files being locked by the dotnet process in the container:

Severity	Code	Description	Project	File	Line	Suppression State
Warning	MSB3026	Could not copy "C:\Code\XM-Cloud-Introduction\src\Feature\BasicContent\rendering\bin\Debug\netcoreapp6.0\Mvp.Feature.BasicContent.dll" to "bin\Debug\netcoreapp6.0\Mvp.Feature.BasicContent.dll". Beginning retry 1 in 1000ms. The process cannot access the file 'bin\Debug\netcoreapp6.0\Mvp.Feature.BasicContent.dll' because it is being used by another process. The file is locked by: "vmwp.exe (153220), vmmem (155272)"	Mvp.Project.MvpSite.Rendering	C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets	4862	

This caused issues with the intellisense. Beyond that I could see the hot reload in the logs but subsequent requests actually didn't reflect the edits.

@robearlam robearlam marked this pull request as draft April 20, 2023 02:16
@sebastiantecsi
Copy link
Contributor

@robearlam ,

Interesting @sebastiantecsi, do you have steps to reproduce both of the different errors you've seen above.

According to Google the Env Var should fix the rude error issue?

You can reproduce it usually when you have a bunch of files modified and saved all at the same time.
So for example, in file src\Project\MvpSite\rendering\Controllers\DefaultController.cs add this function

        [UseSitecoreRendering]
        public IActionResult Demo(LayoutViewModel model)
        {
            return null;
        }

Save the file. All should be good.
But then do a modification to the new function from public IActionResult Demo(LayoutViewModel model) to public IActionResult Demo(Route model) and you do another save of the file this is what I get in the docker

dotnet watch ⌚ Polling file watcher is enabled
dotnet watch 🔥 Hot reload enabled. For a list of supported edits, see https://aka.ms/dotnet/hot-reload.
💡 Press "Ctrl + R" to restart.

then using the answer from here https://stackoverflow.com/a/70895415/856045 I've added an environment variable named DOTNET_WATCH_RESTART_ON_RUDE_EDIT to true in docker-compose.override.yml for mvp-rendering and then this happened, sometimes:

So yes, the env var DOTNET_WATCH_RESTART_ON_RUDE_EDIT=1, helped a bit.
But I got similar error as @sc-ivanlieckens mentioned, but in docker when in env I had this DOTNET_WATCH_RESTART_ON_RUDE_EDIT=1

2023-05-05T16:04:36.943888000Z dotnet watch ⌚ File changed: .\Controllers\DefaultController.cs.
2023-05-05T16:04:37.344487900Z dotnet watch ⌚ Unable to apply hot reload because of a rude edit.
2023-05-05T16:04:37.369486500Z dotnet watch ⌚ Exited
2023-05-05T16:04:37.381485700Z dotnet watch 🔧 Building...
2023-05-05T16:04:38.670334400Z   Mvp.Feature.Navigation.Rendering -> C:\app\src\Feature\Navigation\rendering\bin\Debug\netcoreapp6.0\Mvp.Feature.Navigation.dll
2023-05-05T16:04:38.863855400Z   Mvp.Feature.Selections.Rendering -> C:\app\src\Feature\Selections\rendering\bin\Debug\netcoreapp6.0\Mvp.Feature.Selections.dll
2023-05-05T16:04:38.876859700Z   MVP.Feature.BasicContent.Rendering -> C:\app\src\Feature\BasicContent\rendering\bin\Debug\netcoreapp6.0\Mvp.Feature.BasicContent.dll
2023-05-05T16:04:39.002162100Z   Mvp.Feature.User.Rendering -> C:\app\src\Feature\User\rendering\bin\Debug\netcoreapp6.0\Mvp.Feature.User.dll
2023-05-05T16:04:39.026162600Z   Mvp.Foundation.Configuration.Rendering -> C:\app\src\Foundation\Configuration\rendering\bin\Debug\net6.0\Mvp.Foundation.Configuration.Rendering.dll
2023-05-05T16:04:39.238350000Z   Mvp.Feature.Social.Rendering -> C:\app\src\Feature\Social\rendering\bin\Debug\netcoreapp6.0\Mvp.Feature.Social.dll
2023-05-05T16:04:39.377418700Z   Mvp.Foundation.DataFetching.Rendering -> C:\app\src\Foundation\DataFetching\rendering\bin\Debug\netcoreapp6.0\Mvp.Foundation.DataFetching.dll
2023-05-05T16:04:39.589944700Z   Mvp.Feature.People.Rendering -> C:\app\src\Feature\People\rendering\bin\Debug\netcoreapp6.0\Mvp.Feature.People.dll
2023-05-05T16:04:39.829563400Z   
2023-05-05T16:04:39.829563400Z   WebCompiler: Begin compiling compilerconfig.json
2023-05-05T16:04:40.099638500Z   WebCompiler: Done compiling compilerconfig.json
2023-05-05T16:04:41.369620100Z C:\Program Files\dotnet\sdk\6.0.403\Microsoft.Common.CurrentVersion.targets(5097,5): warning MSB3026: Could not copy "C:\app\src\project\MvpSite\rendering\obj\Debug\netcoreapp6.0\apphost.exe" to "bin\Debug\netcoreapp6.0\Mvp.Project.MvpSite.exe". Beginning retry 1 in 1000ms. The process cannot access the file 'C:\app\src\project\MvpSite\rendering\bin\Debug\netcoreapp6.0\Mvp.Project.MvpSite.exe' because it is being used by another process.  [C:\app\src\project\MvpSite\rendering\Mvp.Project.MvpSite.Rendering.csproj]
2023-05-05T16:04:42.374679400Z C:\Program Files\dotnet\sdk\6.0.403\Microsoft.Common.CurrentVersion.targets(5097,5): warning MSB3026: Could not copy "C:\app\src\project\MvpSite\rendering\obj\Debug\netcoreapp6.0\apphost.exe" to "bin\Debug\netcoreapp6.0\Mvp.Project.MvpSite.exe". Beginning retry 2 in 1000ms. The process cannot access the file 'C:\app\src\project\MvpSite\rendering\bin\Debug\netcoreapp6.0\Mvp.Project.MvpSite.exe' because it is being used by another process.  [C:\app\src\project\MvpSite\rendering\Mvp.Project.MvpSite.Rendering.csproj]
2023-05-05T16:04:43.377725000Z C:\Program Files\dotnet\sdk\6.0.403\Microsoft.Common.CurrentVersion.targets(5097,5): warning MSB3026: Could not copy "C:\app\src\project\MvpSite\rendering\obj\Debug\netcoreapp6.0\apphost.exe" to "bin\Debug\netcoreapp6.0\Mvp.Project.MvpSite.exe". Beginning retry 3 in 1000ms. The process cannot access the file 'C:\app\src\project\MvpSite\rendering\bin\Debug\netcoreapp6.0\Mvp.Project.MvpSite.exe' because it is being used by another process.  [C:\app\src\project\MvpSite\rendering\Mvp.Project.MvpSite.Rendering.csproj]
2023-05-05T16:04:44.388672800Z C:\Program Files\dotnet\sdk\6.0.403\Microsoft.Common.CurrentVersion.targets(5097,5): warning MSB3026: Could not copy "C:\app\src\project\MvpSite\rendering\obj\Debug\netcoreapp6.0\apphost.exe" to "bin\Debug\netcoreapp6.0\Mvp.Project.MvpSite.exe". Beginning retry 4 in 1000ms. The process cannot access the file 'C:\app\src\project\MvpSite\rendering\bin\Debug\netcoreapp6.0\Mvp.Project.MvpSite.exe' because it is being used by another process.  [C:\app\src\project\MvpSite\rendering\Mvp.Project.MvpSite.Rendering.csproj]
2023-05-05T16:04:45.397711700Z C:\Program Files\dotnet\sdk\6.0.403\Microsoft.Common.CurrentVersion.targets(5097,5): warning MSB3026: Could not copy "C:\app\src\project\MvpSite\rendering\obj\Debug\netcoreapp6.0\apphost.exe" to "bin\Debug\netcoreapp6.0\Mvp.Project.MvpSite.exe". Beginning retry 5 in 1000ms. The process cannot access the file 'C:\app\src\project\MvpSite\rendering\bin\Debug\netcoreapp6.0\Mvp.Project.MvpSite.exe' because it is being used by another process.  [C:\app\src\project\MvpSite\rendering\Mvp.Project.MvpSite.Rendering.csproj]
2023-05-05T16:04:46.404694600Z C:\Program Files\dotnet\sdk\6.0.403\Microsoft.Common.CurrentVersion.targets(5097,5): warning MSB3026: Could not copy "C:\app\src\project\MvpSite\rendering\obj\Debug\netcoreapp6.0\apphost.exe" to "bin\Debug\netcoreapp6.0\Mvp.Project.MvpSite.exe". Beginning retry 6 in 1000ms. The process cannot access the file 'C:\app\src\project\MvpSite\rendering\bin\Debug\netcoreapp6.0\Mvp.Project.MvpSite.exe' because it is being used by another process.  [C:\app\src\project\MvpSite\rendering\Mvp.Project.MvpSite.Rendering.csproj]
2023-05-05T16:04:47.418683500Z C:\Program Files\dotnet\sdk\6.0.403\Microsoft.Common.CurrentVersion.targets(5097,5): warning MSB3026: Could not copy "C:\app\src\project\MvpSite\rendering\obj\Debug\netcoreapp6.0\apphost.exe" to "bin\Debug\netcoreapp6.0\Mvp.Project.MvpSite.exe". Beginning retry 7 in 1000ms. The process cannot access the file 'C:\app\src\project\MvpSite\rendering\bin\Debug\netcoreapp6.0\Mvp.Project.MvpSite.exe' because it is being used by another process.  [C:\app\src\project\MvpSite\rendering\Mvp.Project.MvpSite.Rendering.csproj]
2023-05-05T16:04:48.423229500Z C:\Program Files\dotnet\sdk\6.0.403\Microsoft.Common.CurrentVersion.targets(5097,5): warning MSB3026: Could not copy "C:\app\src\project\MvpSite\rendering\obj\Debug\netcoreapp6.0\apphost.exe" to "bin\Debug\netcoreapp6.0\Mvp.Project.MvpSite.exe". Beginning retry 8 in 1000ms. The process cannot access the file 'C:\app\src\project\MvpSite\rendering\bin\Debug\netcoreapp6.0\Mvp.Project.MvpSite.exe' because it is being used by another process.  [C:\app\src\project\MvpSite\rendering\Mvp.Project.MvpSite.Rendering.csproj]
2023-05-05T16:04:49.427768500Z C:\Program Files\dotnet\sdk\6.0.403\Microsoft.Common.CurrentVersion.targets(5097,5): warning MSB3026: Could not copy "C:\app\src\project\MvpSite\rendering\obj\Debug\netcoreapp6.0\apphost.exe" to "bin\Debug\netcoreapp6.0\Mvp.Project.MvpSite.exe". Beginning retry 9 in 1000ms. The process cannot access the file 'C:\app\src\project\MvpSite\rendering\bin\Debug\netcoreapp6.0\Mvp.Project.MvpSite.exe' because it is being used by another process.  [C:\app\src\project\MvpSite\rendering\Mvp.Project.MvpSite.Rendering.csproj]
2023-05-05T16:04:50.432819800Z C:\Program Files\dotnet\sdk\6.0.403\Microsoft.Common.CurrentVersion.targets(5097,5): warning MSB3026: Could not copy "C:\app\src\project\MvpSite\rendering\obj\Debug\netcoreapp6.0\apphost.exe" to "bin\Debug\netcoreapp6.0\Mvp.Project.MvpSite.exe". Beginning retry 10 in 1000ms. The process cannot access the file 'C:\app\src\project\MvpSite\rendering\bin\Debug\netcoreapp6.0\Mvp.Project.MvpSite.exe' because it is being used by another process.  [C:\app\src\project\MvpSite\rendering\Mvp.Project.MvpSite.Rendering.csproj]
2023-05-05T16:04:51.438935100Z C:\Program Files\dotnet\sdk\6.0.403\Microsoft.Common.CurrentVersion.targets(5097,5): error MSB3027: Could not copy "C:\app\src\project\MvpSite\rendering\obj\Debug\netcoreapp6.0\apphost.exe" to "bin\Debug\netcoreapp6.0\Mvp.Project.MvpSite.exe". Exceeded retry count of 10. Failed.  [C:\app\src\project\MvpSite\rendering\Mvp.Project.MvpSite.Rendering.csproj]
2023-05-05T16:04:51.438935100Z C:\Program Files\dotnet\sdk\6.0.403\Microsoft.Common.CurrentVersion.targets(5097,5): error MSB3021: Unable to copy file "C:\app\src\project\MvpSite\rendering\obj\Debug\netcoreapp6.0\apphost.exe" to "bin\Debug\netcoreapp6.0\Mvp.Project.MvpSite.exe". The process cannot access the file 'C:\app\src\project\MvpSite\rendering\bin\Debug\netcoreapp6.0\Mvp.Project.MvpSite.exe' because it is being used by another process. [C:\app\src\project\MvpSite\rendering\Mvp.Project.MvpSite.Rendering.csproj]
2023-05-05T16:04:52.558621700Z dotnet watch ⏳ Waiting for a file to change before restarting dotnet...

So, I guess this has to be investigated a bit more.

@robearlam
Copy link
Member Author

Looks like this is known issue with MS docker .net tools, and Hot Reload isn't supported in Docker yet. See microsoft/DockerTools#322

Closing this PR now, but issue #16 will remain open so we can revisit this when the functionality is available.

@robearlam robearlam closed this May 29, 2023
@robearlam robearlam deleted the dotnet-hot-reload branch November 21, 2023 03:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update Development.ps1 script used by Rendering hosts to leverage .NET6 hot reload functionality
3 participants