-
Notifications
You must be signed in to change notification settings - Fork 519
Docker + Webpack #806
Comments
Yes, it's possible to use it, but you have to change a few bits.
Than you have to expose the HMR port in the dockerfile:
(in this example I expose 5000 for http and 5001 for hmr traffic) modify your startup.cs to explicitly set the hmr port:
and finally, if you're using vs2017 docker tools, you have to change the docker-compose.override.yml:
Hope it helped! It works like charm with one exception: because the source files are mapped as a volume into the container, changing them outside of the container will not trigger file change detection. you have to reload the page. |
@retk, thanks for your answer. I've tried your suggestion. Now I have no error at startup and even Chrome dev tools said that [HRM] is connected, but changes to html or ts does not display even after hard reload. Only app restart helps with refresh. What I want to do is a couple of api apps like microservices, one app with Angular fron-end, everything as docker containers and nginx as reverse-proxy also as container. |
It seems that webpack does not play nice with newer nodejs versions. Reverting back to LTS should fix your issue. Apply the following change in dockerfile:
|
@retk, I've updated Dockerfile, but no luck again. Also I've noticed that HMR goes to port 5000 even if port 5001 specified in
I create repo with test project https://github.com/zeusapps/DockerWebpack |
Ok, it seems that either webpack or something else changed as webpack does not detect changes on reload too. FYI the underlying issue is this: moby/moby#30105 One possible solution could be to enable polling on webpack as mentioned in the linked issue, but not sure how to do this. about HMR: webpacks HMR module is downloaded from the application through http but it will use the port you've set to communicate. |
I believe that DOTNET_USE_POLLING_FILE_WATCHER=1 do the trick but it dont. I've try to manually go to http://localhost:5001/__webpack_hmr but only 5000 port get output back. |
Yes, the ASP.NET Core application receives the
I don't think that will help, because it's Node that needs to detect the file changes, not .NET. The workaround that angular-cli people recommend is to configure Webpack to poll for changes, rather than expecting the OS to issue change notifications. Apparently you can do that in your Webpack config using the Closing because this is an external issue (in Docker) and the workaround mentioned here ( |
@SteveSandersonMS , thanks for your reply. Could you please help where to put watchOptions? I add it to the sharedConfig, but it have no effect. UPDATE |
Hmm, I would have thought You could ask the Webpack folks to clarify their docs, or - for a quicker result - grep through the Webpack source code to see where it tries to read |
@SteveSandersonMS, I did a little bit of research and it looks like the I suppose a possibile solution would be to pass the |
Hi, @pglazkov. I also have no luck with making this work. What I came with is if you as me want to have container per task (front-end, api, nginx) it's just a metter of using wrong tool (meaning JavaScriptServices). I use Hope it help you. |
…leware (#806) This enables Docker HMR workflow and the workaround mentioned in this comment: #806 (comment)
Where to inform that when adding docker support to aspnetcore application in Visual Studio 2017 using react redux... it does not create Dockerfile file where node is included. |
Could MS provide a detailed article on how to configure VSCode, Docker, Angular, and HMR? The available information is scattered and scarced. |
@mxa0079 To request changes to docs, please post an issue at https://github.com/aspnet/docs |
For me the problem getting HMR to work was not any of the settings, but the issue with file changes on shared drives using Docker For Windows. I'm currently running Docker Watcher during dev when I want HMR I did not need to change any Docker, webpack or WebpackDevMiddlewareOptions config. (or rather I tried loads, found Docker Watcher, and removed all changes back to the OOB settings from the .NET Core / AngularX template. I did need to install node as part of the Docker setup otherwise webpack doesn't work, but didn't need to expose any ports or anything) |
Is it possible to use webapck and HMR with Docker?
Currently I've get exception when project start on
UseWebpackDevMiddleware
.May be I can somehow configure webpack to work with docker?
I use Docker for Windows:
I have installed Node locally and have try to install it to the docker image, but no luck.
The text was updated successfully, but these errors were encountered: